OPTION CHARACTER BYTE FILE GETNAME F$, "BMP,JPG,GIFファイル|*.BMP;*.JPG;*.GIF" CALL PICTURELOAD(F$,XSIZE,YSIZE) INPUT PROMPT "SAVE FILENAME(.BMP)=":F$ CALL BMPSAVEFULL(F$,0,0,XSIZE-1,YSIZE-1) END
EXTERNAL SUB BMPSAVEFULL(F$,XS,YS,XE,YE) OPTION CHARACTER BYTE IF F$="" THEN STOP IF POS(F$,".")=0 THEN LET F$=F$ & ".BMP" LET BFTYPE$="BM" LET OFFSET=54 LET HEADERSIZE=40 LET PLANE=1 LET BITCOLOR=24 LET XSIZE=XE-XS+1 LET YSIZE=YE-YS+1 LET BW=3*XSIZE+3 LET BW=INT(BW/4)*4 LET BFSIZE=BW*YSIZE+OFFSET OPEN #1:NAME F$,ACCESS OUTPUT PRINT #1:BFTYPE$; PRINT #1:MKL$(BFSIZE); PRINT #1:MKI$(0); PRINT #1:MKI$(0); PRINT #1:MKL$(OFFSET); PRINT #1:MKL$(HEADERSIZE); PRINT #1:MKL$(XSIZE); PRINT #1:MKL$(YSIZE); PRINT #1:MKI$(PLANE); PRINT #1:MKI$(BITCOLOR); PRINT #1:REPEAT$(CHR$(0),24); FOR Y=YE TO YS STEP -1 FOR X=XS TO XE CALL GETPOINT(X,Y,R,G,B) LET C$=C$ & CHR$(B) & CHR$(G) & CHR$(R) NEXT X LET C$=LEFT$(C$ & REPEAT$(CHR$(0),4),BW) PRINT #1:C$; LET C$="" NEXT Y CLOSE #1 END SUB
EXTERNAL SUB BMPSAVE256(F$,XS,YS,XE,YE) OPTION CHARACTER BYTE OPTION BASE 0 IF F$="" THEN STOP DIM R(255),G(255),B(255) LET RN=INT(255/6) LET GN=INT(255/5) LET BN=INT(255/5) FOR GG = 0 TO 255 STEP GN FOR RR = 0 TO 255 STEP RN FOR BB = 0 TO 255 STEP BN LET R(N)=RR LET G(N)=GG LET B(N)=BB LET N = N + 1 NEXT BB NEXT RR NEXT GG IF POS(F$,".")=0 THEN LET F$=F$ & ".BMP" LET BFTYPE$="BM" LET OFFSET=54+4*256 LET HEADERSIZE=40 LET PLANE=1 LET BITCOLOR=8 LET XSIZE=XE-XS+1 LET YSIZE=YE-YS+1 LET BW=XSIZE+3 LET BW=INT(BW/4)*4 LET BFSIZE=BW*YSIZE+OFFSET OPEN #1:NAME F$,ACCESS OUTPUT PRINT #1:BFTYPE$; PRINT #1:MKL$(BFSIZE); PRINT #1:MKI$(0); PRINT #1:MKI$(0); PRINT #1:MKL$(OFFSET); PRINT #1:MKL$(HEADERSIZE); PRINT #1:MKL$(XSIZE); PRINT #1:MKL$(YSIZE); PRINT #1:MKI$(PLANE); PRINT #1:MKI$(BITCOLOR); PRINT #1:REPEAT$(CHR$(0),24); FOR I=0 TO 255 PRINT #1:CHR$(B(I)); PRINT #1:CHR$(G(I)); PRINT #1:CHR$(R(I)); PRINT #1:CHR$(0); NEXT I FOR Y=YE TO YS STEP -1 FOR X=XS TO XE CALL GETPOINT(X,Y,RR,GG,BB) LET RR=INT(RR/RN)*RN LET GG=INT(GG/GN)*GN LET BB=INT(BB/BN)*BN FOR N=0 TO 255 IF R(N)=RR AND B(N)=BB AND G(N)=GG THEN LET C$=C$ & CHR$(N) EXIT FOR END IF NEXT N CALL PSET(X,Y,R(N),G(N),B(N)) NEXT X LET C$=LEFT$(C$ & REPEAT$(CHR$(0),4),BW) PRINT #1:C$; LET C$="" NEXT Y CLOSE #1 END SUB
|