Advertisement
Guest User

Vg5000_8x10_320x250pictConv_01.sdlbas

a guest
Mar 14th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. finp$="TopPolynesiaCook3_740x555.jpg"
  2.  
  3. fout$=finp$+"_.bmp"
  4. foutscr$=finp$+"_.scr"
  5. '- sdlbasic version 0708072157
  6. '- from firstbasic version: 0201310133
  7. '- conversor tem erros - verificar - ciano é visto como preto (?)
  8. '- please be sure the picture source is a .png
  9.  
  10. '- sudo apt-get install xawtv vgrabbj imagemagick pzxtools music123 lame mpg123
  11.  
  12. dim zxdisp[32768]
  13.  
  14. xed=320:yed=250
  15. close #1:setdisplay(xed,yed,32,1):paper(8^8-1):ink(0):pen(0):cls:Loadimage(finp$,1):pasteicon(0,0,1)
  16. dim clust[8,16],r0[8,16],g0[8,16],b0[8,16],plte[16]
  17. plte[ 0]=0x000000:plte[ 2]=0x0000FF:plte[ 1]=0xFF0000:plte[ 3]=0xFF00FF
  18. plte[ 4]=0x00FF00:plte[ 6]=0x00FFFF:plte[ 5]=0xFFFF00:plte[ 7]=0xFFFFFF
  19. plte[ 8]=0x000000:plte[10]=0x0000FF:plte[ 9]=0xFF0000:plte[11]=0xFF00FF
  20. plte[12]=0x00FF00:plte[14]=0x00FFFF:plte[13]=0xFFFF00:plte[15]=0xFFFFFF
  21. '- "00,12,03,15,08,04,11,07,02,14,01,13,10,06,09,05."
  22. '- "00,06,08,14,02,12,04,10,08,14,00,06,04,10,02,12."
  23. 'clstr$="00,06,08,14,02,12,04,10,08,14,00,06,04,10,02,12."
  24. 'clstr$="00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15."
  25. 'clstr$="00,04,08,12,10,14,02,06,00,04,08,12,10,14,02,06."
  26.  
  27. clstr$="00,04,08,12,08,12,00,04,00,04,08,12,08,12,00,04,"
  28.  
  29. for y2=0 to 3:for x2=0 to 3:clust[x2,y2]=val(mid$(clstr$,((y2*4+x2)*3)+1,2)):next:next
  30. hbedge=255 '- halfbright attr edge -zx32=218, zx32fs=153 , realthing=180?
  31. rgrsp=30:ggrsp=30:bgrsp=30 '- for r, g and b saturation levels
  32. for y1=0 to int(yed/10):for x1=0 to int(xed/8)
  33.     for y2=0 to 9:for x2=0 to 7
  34.         y=y1*10+y2:x=x1*8+x2
  35.         zzz=point(x,y)
  36.         r0[x2,y2]=bitwiseand(zzz,255):zzz=int(zzz/256)
  37.         g0[x2,y2]=bitwiseand(zzz,255):zzz=int(zzz/256)
  38.         b0[x2,y2]=bitwiseand(zzz,255)
  39.         next:next
  40.     bi=0:ri=0:gi=0
  41.     for y2=0 to 9:for x2=0 to 7
  42.         x=(x1*8)+x2:y=(y1*10)+y2
  43.         bi=bi+b0[x2,y2]:gi=gi+g0[x2,y2]:ri=ri+r0[x2,y2]
  44.         next:next
  45.     b=bi/80:g=gi/80:r=ri/80:xrreg=0
  46.     hbrite=0:if (r<hbedge) and(g<hbedge) and(b<hbedge) then:hbrite=1:end if
  47.     hbampl=255-(hbrite*(255-hbedge))
  48.     if b>(hbampl/2) then:b=(hbampl-b):xrreg=bitwiseor(xrreg,1):end if
  49.     if r>(hbampl/2) then:r=(hbampl-r):xrreg=bitwiseor(xrreg,2):end if
  50.     if g>(hbampl/2) then:g=(hbampl-g):xrreg=bitwiseor(xrreg,4):end if
  51.     halbr=(r*rgrsp)/100:halbg=(g*ggrsp)/100:halbb=(b*bgrsp)/100:vlik=7
  52.     if((r>halbb) and(g<=halbb)) or((b<=halbr) and(g<=halbr))then:vlik=3:end if
  53.     if((g>halbb) and(r<=halbb)) or((b<=halbg) and(r<=halbg))then:vlik=5:end if
  54.     if((g>halbr) and(b<=halbr)) or((r<=halbg) and(b<=halbg))then:vlik=6:end if
  55.     if((r<=halbb) and(g<=halbb)) then: vlik=1:end if
  56.     if((b<=halbr) and(g<=halbr)) then: vlik=2:end if
  57.     if((b<=halbg) and(r<=halbg)) then: vlik=4:end if
  58.     brattr=1-hbrite:ikattr=bitwisexor(vlik,xrreg):paattr=xrreg
  59.     if ikattr<paattr then:tmpr=ikattr:ikattr=paattr:paattr=tmpr:end if
  60.     atvl=bitwiseor((ikattr*8),paattr):atvl=bitwiseor(atvl,(brattr*64))
  61.     zxdisp[6144+x1+(y1*32)]=atvl
  62.     ikval=ikattr+(bitwiseand(ikattr,6)/2)
  63.     paval=paattr+(bitwiseand(paattr,6)/2)
  64.     lumik=(ikval*255)/10:lumpa=(paval*255)/10
  65.     if brattr<1 then:lumik=(lumik*hbedge)/255:lumpa=(lumpa*hbedge)/255:end if
  66.     dflum=lumik-lumpa
  67.     for y2=0 to 9
  68.       dbny=0
  69.       for x2=0 to 7
  70.         y=y1*10+y2:x=x1*8+x2:b=b0[x2,y2]:g=g0[x2,y2]:r=r0[x2,y2]
  71.         vlue=((b+(r*3)+(g*6))/10)
  72.         patgf=(((clust[bitwiseand(x2,3),bitwiseand(y2,3)]+1)*255)/16)
  73.         varnd=((patgf*dflum)/255)+lumpa
  74.         ik=ikattr+(8*brattr)
  75.         if varnd>vlue then:
  76.           ik=paattr+(8*brattr)
  77.           dbny=dbny+(2^(7-x2))
  78.           end if
  79.         ink(plte[ik]):dot(x,y)
  80.         next
  81. '      yf=(bitwiseand(y,7)*8) or (bitwiseand(y,56)/8) or bitwiseand(y,192)
  82.  
  83.       yf=bitwiseor(bitwiseand(y,7)*8,bitwiseand(y,56)/8)
  84.       yf=bitwiseor(bitwiseand(y,192),yf)
  85.  
  86.       zxdisp[(yf*32)+x1]=dbny
  87.       next:next:next
  88. grab (1,0,0,xed,yed):saveimage(fout$,1)
  89. 'open foutscr$ for output as #1
  90. 'for i=0 to 6911
  91. '  writebyte (1,zxdisp[i])
  92. '  next
  93. 'close #1
  94.  
  95. waitkey
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement