画像を8色にします。
RANDOMIZE OPTION BASE 0 PUBLIC NUMERIC BIWIDTH, M2(-1 TO 1,1),M(-2 TO 2,2), LEVEL DIM R(7), G(7), B(7) FOR I=0 TO 7 READ G(I),R(I),B(I) NEXT I DATA 0,0,0 DATA 0,0,255 DATA 0,255,0 DATA 0,255,255 DATA 255,0,0 DATA 255,0,255 DATA 255,255,0 DATA 255,255,255
FILE GETNAME N$, "BMP,JPG,GIFファイル|*.BMP;*.JPG;*.GIF" IF N$="" THEN STOP CALL PICTURELOAD(N$,BIWIDTH,BIHEIGHT) DIM VM(BIWIDTH,BIHEIGHT) ASK PIXEL ARRAY(0,0) VM INPUT PROMPT "MODE ディザ (1) ランダムディザ (2) 誤差拡散法 (3) 固定閾値法 (4) ": MODE LET LEVEL = 128 SELECT CASE MODE CASE 1 DIM MAT(15, 15) RESTORE 100 FOR I = 0 TO 3 FOR J = 0 TO 3 READ MAT(I, J) NEXT J NEXT I CALL MAKEMAT(MAT, 4) CASE 2 INPUT PROMPT "度合い (1 - 255)=": HL !'INPUT PROMPT "LEVEL (0 - 255) =": LEVEL CASE 3 DIM BUFR(BIWIDTH - 1, 2), BUFG(BIWIDTH - 1, 2), BUFB(BIWIDTH - 1, 2) !'INPUT PROMPT "LEVEL (0 - 255) =": LEVEL INPUT PROMPT "MODE JARVIS(1) OR FLOYD(2) ": MD SELECT CASE MD CASE 1 RESTORE 10 FOR J = 0 TO 2 FOR I = -2 TO 2 READ M(I, J) NEXT I NEXT J CASE 2 RESTORE 20 FOR J = 0 TO 1 FOR I = -1 TO 1 READ M2(I, J) NEXT I NEXT J END SELECT 10 DATA 5,7,0,0,0 DATA 3,5,7,5,3 DATA 1,3,5,3,1 20 DATA 7,0,0 DATA 1,5,3 CASE 4 INPUT PROMPT "LEVEL (0 - 255) =": LEVEL END SELECT FOR Y = 0 TO BIHEIGHT - 1 FOR X = 0 TO BIWIDTH - 1 LET CC=VM(X,Y) CALL RGB(CC,R1,G1,B1) LET C = 0 SELECT CASE MODE CASE 1 IF MAT(MOD(X , 16) , MOD(Y , 16))<B1 OR B1=255 THEN LET C = C + 1 IF MAT(MOD(X , 16) , MOD(Y , 16))<R1 OR R1=255 THEN LET C = C + 2 IF MAT(MOD(X , 16) , MOD(Y , 16))<G1 OR G1=255 THEN LET C = C + 4 CASE 2 LET BB = B1 + (RND - .5) * 128 + HL * (B1 / 255) ^ 4 IF BB > LEVEL THEN LET C = C + 1 LET RR = R1 + (RND - .5) * 128 + HL * (R1 / 255) ^ 4 IF RR > LEVEL THEN LET C = C + 2 LET GG = G1 + (RND - .5) * 128 + HL * (G1 / 255) ^ 4 IF GG > LEVEL THEN LET C = C + 4
|