Advertisement
Guest User

incompleto.sdlbas

a guest
May 7th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/sdlbrt
  2. finp$="q2_49474899_1769271099846253_8522749926122192896_n.jpg"
  3. if argc>=3 then:finp$=command$(3):end if
  4.  
  5. dim dpvl[8]
  6. function hexvl(a$)
  7.    e=asc(ucase$(a$))
  8.    hexvl=abs(((e>=48 and e<=57)*(e-48))+((e>=65 and e<=70)*(e-55)))
  9.  end function
  10. sub hexvpr(a$)
  11.      lngta=len(a$):i=1
  12.   while i<=lngta
  13.      m1$=mid$(a$,i,1):m2$=mid$(a$,i+1,1)
  14.      b=(hexvl(m1$)*16)+hexvl(m2$):WriteByte(1,b):i+=2
  15.    end while
  16.  end sub
  17. function bthx$(a)
  18.   b$="00"+hex$(a):bthx$=right$(b$,2)
  19.  end function
  20.  
  21.  
  22. shell("rm _t9.gif _tmp_.png")
  23. shell("convert -size 32x32 xc:#020002 _tmp_.png")
  24. shell("convert _tmp_.png -stroke none -fill '#00680C' -draw 'rectangle 8,0 32,32' _tmp_.png")
  25. shell("convert _tmp_.png -stroke none -fill '#212BBD' -draw 'rectangle 16,0 32,32' _tmp_.png")
  26. shell("convert _tmp_.png -stroke none -fill '#0D9ED5' -draw 'rectangle 24,0 32,32' _tmp_.png")
  27. shell("convert _tmp_.png -stroke none -fill '#85096C' -draw 'rectangle 0,8 32,32' _tmp_.png")
  28. shell("convert _tmp_.png -stroke none -fill '#757376' -draw 'rectangle 8,8 32,32' _tmp_.png")
  29. shell("convert _tmp_.png -stroke none -fill '#AF36FF' -draw 'rectangle 16,8 32,32' _tmp_.png")
  30. shell("convert _tmp_.png -stroke none -fill '#9BA9FF' -draw 'rectangle 24,8 32,32' _tmp_.png")
  31. shell("convert _tmp_.png -stroke none -fill '#514700' -draw 'rectangle 0,16 32,32' _tmp_.png")
  32. shell("convert _tmp_.png -stroke none -fill '#42BD00' -draw 'rectangle 8,16 32,32' _tmp_.png")
  33. shell("convert _tmp_.png -stroke none -fill '#707470' -draw 'rectangle 16,16 32,32' _tmp_.png")
  34. shell("convert _tmp_.png -stroke none -fill '#5DF47A' -draw 'rectangle 24,16 32,32' _tmp_.png")
  35. shell("convert _tmp_.png -stroke none -fill '#E5541D' -draw 'rectangle 0,24 32,32' _tmp_.png")
  36. shell("convert _tmp_.png -stroke none -fill '#D7CB19' -draw 'rectangle 8,24 32,32' _tmp_.png")
  37. shell("convert _tmp_.png -stroke none -fill '#FF81F2' -draw 'rectangle 16,24 32,32' _tmp_.png")
  38. shell("convert _tmp_.png -stroke none -fill '#FDFFFC' -draw 'rectangle 24,24 32,32' _tmp_.png")
  39. shell("convert _tmp_.png _t9.gif")
  40. shell("rm _tmp_.png")
  41.  
  42.  
  43. clstr=0 '- 0..3
  44. xed=160:yed=200:wdwd=1
  45. shell("rm _t*.png")
  46. shell("convert "+finp$+" -scale "+str$(xed*4)+"x"+str$(yed*4)+"! _t2.png")
  47. shell("convert "+finp$+" +dither -colors 16 _t4.png")
  48. shell("convert _t4.png +dither -posterize 8 _t5.png")
  49. shell("convert _t5.png +dither -colors 16 _t6.png")
  50. 'shell("convert _t2.png -quantize CMY -remap _t6.png -dither Riemersma _t3.png")
  51. shell("convert _t2.png -quantize CMY -remap _t9.gif -dither Riemersma _t3.png")
  52. shell("convert _t3.png -unique-colors -scale 400% _t4.png")
  53.  
  54. setdisplay(xed*4,yed*4,32,wdwd):paper(8^8-1):ink(0):pen(0):cls
  55. loadimage("_t3.png",1):pasteicon(0,0,1)
  56.  
  57. dim p1[16],k1[16]
  58.  
  59. function grayscale(ct):
  60.   cq=ct
  61.   bq=bitwiseand(cq,255):cq=int(cq/256)
  62.   gq=bitwiseand(cq,255):cq=int(cq/256)
  63.   rq=bitwiseand(cq,255):cq=int(cq/256)
  64.   return int(((rq*30)+(gq*59)+(bq*11))/100)
  65.   end function
  66.  
  67. for y2=0 to yed-1
  68.   setcaption(str$(int(100*(y2/yed)))+"%")
  69.   for x2=0 to xed-1
  70.     for y1=0 to 3:for x1=0 to 3
  71.       xq=y1*4+x1
  72.       p1[xq]=point(x2*4+x1,y2*4+y1)
  73.       next:next
  74.     for i=0 to 15
  75.       k1[i]=grayscale(p1[i])
  76.       next
  77.     for j=0 to 14:for i=0 to 14
  78.       if k1[i]>k1[i+1] then:
  79.         tm=k1[i]:k1[i]=k1[i+1]:k1[i+1]=tm
  80.         tm=p1[i]:p1[i]=p1[i+1]:p1[i+1]=tm
  81.         end if
  82.       next:next
  83.  
  84.     if clstr=0 then:
  85.     ink(p1[ 0]):dot(x2*4+0,y2*4+0)
  86.     ink(p1[ 6]):dot(x2*4+1,y2*4+0)
  87.     ink(p1[ 9]):dot(x2*4+2,y2*4+0)
  88.     ink(p1[15]):dot(x2*4+3,y2*4+0)
  89.     ink(p1[ 4]):dot(x2*4+0,y2*4+1)
  90.     ink(p1[10]):dot(x2*4+1,y2*4+1)
  91.     ink(p1[ 3]):dot(x2*4+2,y2*4+1)
  92.     ink(p1[13]):dot(x2*4+3,y2*4+1)
  93.     ink(p1[ 8]):dot(x2*4+0,y2*4+2)
  94.     ink(p1[14]):dot(x2*4+1,y2*4+2)
  95.     ink(p1[ 1]):dot(x2*4+2,y2*4+2)
  96.     ink(p1[ 7]):dot(x2*4+3,y2*4+2)
  97.     ink(p1[ 2]):dot(x2*4+0,y2*4+3)
  98.     ink(p1[12]):dot(x2*4+1,y2*4+3)
  99.     ink(p1[ 5]):dot(x2*4+2,y2*4+3)
  100.     ink(p1[11]):dot(x2*4+3,y2*4+3)
  101.     end if
  102.  
  103.     if clstr=1 then:
  104.     ink(p1[ 0]):dot(x2*4+0,y2*4+0)
  105.     ink(p1[ 4]):dot(x2*4+1,y2*4+0)
  106.     ink(p1[ 8]):dot(x2*4+2,y2*4+0)
  107.     ink(p1[12]):dot(x2*4+3,y2*4+0)
  108.     ink(p1[10]):dot(x2*4+0,y2*4+1)
  109.     ink(p1[14]):dot(x2*4+1,y2*4+1)
  110.     ink(p1[ 2]):dot(x2*4+2,y2*4+1)
  111.     ink(p1[ 6]):dot(x2*4+3,y2*4+1)
  112.     ink(p1[ 1]):dot(x2*4+0,y2*4+2)
  113.     ink(p1[ 5]):dot(x2*4+1,y2*4+2)
  114.     ink(p1[ 9]):dot(x2*4+2,y2*4+2)
  115.     ink(p1[13]):dot(x2*4+3,y2*4+2)
  116.     ink(p1[11]):dot(x2*4+0,y2*4+3)
  117.     ink(p1[15]):dot(x2*4+1,y2*4+3)
  118.     ink(p1[ 3]):dot(x2*4+2,y2*4+3)
  119.     ink(p1[ 7]):dot(x2*4+3,y2*4+3)
  120.     end if
  121.  
  122.     if clstr=2 then:
  123.     ink(p1[ 0]):dot(x2*4+0,y2*4+0)
  124.     ink(p1[10]):dot(x2*4+1,y2*4+0)
  125.     ink(p1[ 1]):dot(x2*4+2,y2*4+0)
  126.     ink(p1[11]):dot(x2*4+3,y2*4+0)
  127.     ink(p1[ 4]):dot(x2*4+0,y2*4+1)
  128.     ink(p1[14]):dot(x2*4+1,y2*4+1)
  129.     ink(p1[ 5]):dot(x2*4+2,y2*4+1)
  130.     ink(p1[15]):dot(x2*4+3,y2*4+1)
  131.     ink(p1[ 8]):dot(x2*4+0,y2*4+2)
  132.     ink(p1[ 2]):dot(x2*4+1,y2*4+2)
  133.     ink(p1[ 9]):dot(x2*4+2,y2*4+2)
  134.     ink(p1[ 3]):dot(x2*4+3,y2*4+2)
  135.     ink(p1[12]):dot(x2*4+0,y2*4+3)
  136.     ink(p1[ 6]):dot(x2*4+1,y2*4+3)
  137.     ink(p1[13]):dot(x2*4+2,y2*4+3)
  138.     ink(p1[ 7]):dot(x2*4+3,y2*4+3)
  139.     end if
  140.  
  141.     if clstr=3 then:
  142.     ink(p1[ 0]):dot(x2*4+0,y2*4+0)
  143.     ink(p1[12]):dot(x2*4+1,y2*4+0)
  144.     ink(p1[ 3]):dot(x2*4+2,y2*4+0)
  145.     ink(p1[15]):dot(x2*4+3,y2*4+0)
  146.     ink(p1[ 8]):dot(x2*4+0,y2*4+1)
  147.     ink(p1[ 4]):dot(x2*4+1,y2*4+1)
  148.     ink(p1[11]):dot(x2*4+2,y2*4+1)
  149.     ink(p1[ 7]):dot(x2*4+3,y2*4+1)
  150.     ink(p1[ 2]):dot(x2*4+0,y2*4+2)
  151.     ink(p1[14]):dot(x2*4+1,y2*4+2)
  152.     ink(p1[ 1]):dot(x2*4+2,y2*4+2)
  153.     ink(p1[13]):dot(x2*4+3,y2*4+2)
  154.     ink(p1[10]):dot(x2*4+0,y2*4+3)
  155.     ink(p1[ 6]):dot(x2*4+1,y2*4+3)
  156.     ink(p1[ 9]):dot(x2*4+2,y2*4+3)
  157.     ink(p1[ 5]):dot(x2*4+3,y2*4+3)
  158.     end if
  159.  
  160.     x1=x2 mod 4:y1=y2 mod 4
  161.     u=point(x2*4+x1,y2*4+y1)
  162.     ink(u):dot(x2,y2)
  163.     next:next
  164.  
  165. loadimage("_t4.png",1):pasteicon(xed,0,1)
  166. shell("rm _t*.png")
  167.  
  168. '-------------------------------------------------------------------------------
  169.  
  170. for y2=0 to yed-1
  171.   setcaption(str$(int(100*(y2/yed)))+"%")
  172.   for x2=0 to xed-1
  173.     u=point(x2,y2)
  174.     for c2=15 to 0 step -1
  175.       cp=point(xed+c2*4,0)
  176.       if (u=cp) then:
  177.  
  178.         ink(0xFFFFFF)
  179.         if bitwiseand(c2,1)<>0 then:ink(0):end if
  180.         dot((xed*0)+x2,yed+y2)
  181.  
  182.         ink(0xFFFFFF)
  183.         if bitwiseand(c2,2)<>0 then:ink(0):end if
  184.         dot((xed*1)+x2,yed+y2)
  185.  
  186.         ink(0xFFFFFF)
  187.         if bitwiseand(c2,4)<>0 then:ink(0):end if
  188.         dot((xed*2)+x2,yed+y2)
  189.  
  190.         ink(0xFFFFFF)
  191.         if bitwiseand(c2,8)<>0 then:ink(0):end if
  192.         dot((xed*3)+x2,yed+y2)
  193.  
  194.         end if
  195.       next
  196.     next:next
  197.  
  198.  
  199. '-------------------------------------------------------------------------------
  200.  
  201. open finp$+".bin" for output as #1
  202.  
  203. for x0=0 to 3
  204.   for y2=0 to 143
  205.     for x1=0 to 159 step 8
  206.       setcaption(str$(y2)+"/144")
  207.       y=yed+y2
  208.       for x2=0 to 7:dpvl[x2]=0:next
  209.       for x2=0 to 7:xp=(x0*160)+x1+x2
  210.         g=bitwiseand(point(xp,y),0x00FF00)/256
  211.         if g<128 then:dpvl[x2]=1:end if
  212.         next
  213.       dpvb=0
  214.       for x2=0 to 7:dpvb=dpvb+(dpvl[x2]*(2^(7-x2))):next
  215.       writebyte(1,dpvb)
  216.       next:next:next
  217.  
  218. for x0=0 to 15
  219.   u=point(xed+(x0*4),0)
  220.   r=bitwiseand(u,0xF00000)/0x100000
  221.   g=bitwiseand(u,0x00F000)/0x100
  222.   b=bitwiseand(u,0x0000F0)/0x10
  223.   writebyte(1,b)
  224.   writebyte(1,bitwiseor(g,r))
  225.   next
  226.  
  227. close #1
  228.  
  229. '-------------------------------------------------------------------------------
  230.  
  231. open finp$+".hex" for output as #1:open finp$+".bin" for input as #2
  232.   print #1,"goto bin01end"
  233.   print #1,"bin01:"
  234.   print #1,"asm"
  235.   a$="  defb "
  236.    while not(eof(2))
  237.         aln=len(a$)
  238.      if aln>=68 then
  239.         tzl=len(a$):a$=left$(a$,tzl-1):print #1,a$:a$="  defb "
  240.       end if
  241.      u=readbyte(2)
  242.      a$=a$+"$"+bthx$(u):a$=a$+","
  243.    end while
  244.         aln=len(a$)
  245.      if aln>0 then
  246.         tzl=len(a$):a$=left$(a$,tzl-1):print #1,a$:a$="  defb "
  247.       end if
  248.   print #1,"  end asm"
  249.   print #1,"bin01end:"
  250.  close #1:close #2
  251.  
  252. '-------------------------------------------------------------------------------
  253.  
  254.  
  255. 'waitkey
  256.  
  257. grab(1,0,0,xed,yed):saveimage("_.bmp",1):shell("convert _.bmp "+finp$+".png && rm _.bmp" )
  258. shell("convert "+finp$+".png  -colors 16 -compress None "+finp$+".ilbm ")
  259. shell("convert "+finp$+".png _.ppm && ppmtopi1 _.ppm > "+finp$+".pi1 && rm _.ppm")
  260.  
  261. 'waitkey
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement