Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- finp$="lena_80x200.png"
- if argc>=3 then:finp$=command$(3):end if
- '- original qbasic version - 0112141818
- '- sdlbasic version - 0405111338
- '- halftone picture converter (bmp 4/8/24bit)
- xed=0:yed=0:open finp$ for input as #1:for i=1 to 16:n=readbyte(1):next:for i=1 to 2:n=readbyte(1):next
- xed=readbyte(1)*256:xed=xed+readbyte(1):for i=1 to 2:n=readbyte(1):next:yed=readbyte(1)*256:yed=yed+readbyte(1)
- close #1
- setdisplay(xed,yed,32,1):paper(8^8-1):ink(0):pen(0):cls:
- '- opens the image
- loadimage(finp$,1):pasteicon(0,0,1)
- dim clust[16,16] '-,o4b[2]
- '-- define cluster
- a$="00,09,02,11,04,13,06,15,08,01,10,03,12,05,14,07," '- 8x2 matrix
- 'a$="00,06,08,14,02,12,04,10,08,14,00,06,04,10,02,12"
- for y2=0 to 7:for x2=0 to 1
- lc=(y2*2)+x2
- clust[x2,y2]=val(mid$(a$,(lc*3)+1,2)):next:next
- dim cor[16]
- cor[0]=0x000000:cor[1]=0x0000FF:cor[2]=0xFF0000:cor[3]=0xFF00FF
- cor[4]=0x00FF00:cor[5]=0x00FFFF:cor[6]=0xFFFF00:cor[7]=0xFFFFFF
- for y=0 to yed-1
- for x=0 to xed-1
- ind=point(x,y)
- b=ind mod 256:ind=int(ind/256)
- g=ind mod 256:ind=int(ind/256)
- r=ind mod 256
- b2=int(b/86)
- g2=int(g/37)
- r2=int(r/37)
- b3=int((b mod 86)*3)
- g3=int((g mod 37)*7)
- r3=int((r mod 37)*7)
- k=int(((b*11)+(r*30)+(g*59))/100)
- k2=int(((b2*11)+(r2*30)+(g2*59))/100)
- k3=int(((b3*11)+(r3*30)+(g3*59))/100)
- patgf=(((clust[x mod 2,y mod 8]+1)*255)/16)
- rpat=0:if r>patgf then:rpat=1:end if
- gpat=0:if g>patgf then:gpat=1:end if
- bpat=0:if b>patgf then:bpat=1:end if
- kpat=0:if k>patgf then:kpat=1:end if
- rpat2=0:if r2>patgf then:rpat2=1:end if
- gpat2=0:if g2>patgf then:gpat2=1:end if
- bpat2=0:if b2>patgf then:bpat2=1:end if
- kpat2=0:if k2>patgf then:kpat2=1:end if
- rpat3=0:if r3>patgf then:rpat3=1:end if
- gpat3=0:if g3>patgf then:gpat3=1:end if
- bpat3=0:if b3>patgf then:bpat3=1:end if
- kpat3=0:if k3>patgf then:kpat3=1:end if
- o4b=(bpat+(rpat*2)+(gpat*4)) mod 8
- 'ink(0):if kpat<>0 then:ink(0xFFFFFF):end if
- 'ink(cor[o4b])
- ink(rgb((r2+rpat3)*35,(g2+gpat3)*35,(b2+bpat3)*85))
- dot(x,y)
- next:next
- '- saves the image
- fout$=finp$+".bmp"
- grab (1,0,0,xed,yed):saveimage(fout$,1)
- shell ("convert "+finp$+".bmp "+finp$+".png")
- shell ("rm "+finp$+".bmp")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement