TGAファイルを作る
FILE GETNAME F$, "BMP,JPG,GIFファイル|*.BMP;*.JPG;*.GIF" IF F$="" THEN STOP CALL PICTURELOAD(F$,XSIZE,YSIZE) INPUT PROMPT "SAVE FILENAME(.TGA)=":F$ IF POS(F$,".")=0 THEN LET F$=F$ & ".TGA" CALL TGASAVEFULL(F$,0,0,XSIZE-1,YSIZE-1) END
EXTERNAL SUB TGASAVEFULL(F$,XS,YS,XE,YE) OPTION CHARACTER BYTE IF F$="" THEN STOP LET XSIZE=XE-XS+1 LET YSIZE=YE-YS+1 OPEN #1:NAME F$,ACCESS OUTPUT PRINT #1:CHR$(0); PRINT #1:CHR$(0); PRINT #1:CHR$(2); PRINT #1:MKI$(0); PRINT #1:MKI$(0); PRINT #1:CHR$(0); PRINT #1:MKI$(0); PRINT #1:MKI$(0); PRINT #1:MKI$(XSIZE); PRINT #1:MKI$(YSIZE); PRINT #1:CHR$(24); PRINT #1:CHR$(0); FOR Y=YE TO YS STEP -1 FOR X=XS TO XE CALL GETPOINT(X,Y,R,G,B) PRINT #1:CHR$(B); PRINT #1:CHR$(G); PRINT #1:CHR$(R); NEXT X NEXT Y CLOSE #1 END SUB
EXTERNAL FUNCTION MKI$(A) OPTION CHARACTER BYTE DECLARE STRING A$,B$ IF A<0 THEN LET A=A+65536 LET A$=CHR$(MOD(A,256)) LET B$=CHR$(INT(A/256)) LET MKI$=A$ & B$ END FUNCTION
EXTERNAL FUNCTION MKL$(A) OPTION CHARACTER BYTE DECLARE STRING A$,B$,C$,D$ IF A<0 THEN LET A=A+2^32 LET A$=CHR$(MOD(A,256)) LET B$=CHR$(MOD(INT(A/256),256)) LET C$=CHR$(MOD(INT(A/65536),256)) LET D$=CHR$(MOD(INT(A/16777216),256)) LET MKL$=A$ & B$ & C$ & D$ END FUNCTION
EXTERNAL SUB RGB(X,R,G,B) LET B=MOD(INT(X/65536),256) LET G=MOD(INT(X/256),256) LET R=MOD(X,256) END SUB
EXTERNAL SUB GETPOINT(X,Y,R,G,B) ASK PIXEL VALUE (X,Y) C CALL RGB(C,R,G,B) END SUB
EXTERNAL SUB PSET(X,Y,R,G,B) SET COLOR COLORINDEX(R/255,G/255,B/255) PLOT POINTS: X , Y END SUB
EXTERNAL SUB PICTURELOAD(N$,XSIZE,YSIZE) SET COLOR MODE "NATIVE" CLEAR SET POINT STYLE 1 GLOAD N$ LET XSIZE=PIXELX(1)+1 LET YSIZE=PIXELY(1)+1 SET BITMAP SIZE XSIZE,YSIZE SET WINDOW 0,XSIZE-1,YSIZE-1,0 END SUB
|