• parse(): is called once on spawn. It converts the hex string into a table containing the rgba values for each picture
  • paPi(): paints one pixel in the specified color
  • clrM: a constant that makes the colors look realistic (reduces the glow effect)
  • xO and yO: the x and y offsets of the image. This will be the upper left corner of the painted image
  • startL: an additional offset (used for big images that need more then one lua script)
  • hx: the minified textstring containing the imagedata
  • rpl, rplc: tables that contain information how to "unzip" the imagedata textstring

Adjust the code below to your personal requirements:

e=string p=tonumber x=screen --yyy-- function a(b) c=1 while d[c]do b=e.gsub(b,d[c][2],d[c][1]) c=c+1 end c=1 while f[c]do b=e.gsub(b,f[c][2],f[c][1]) c=c+1 end g={} h=1 i=0 j=e.find(b,";" ) while j do g[h]={} k=e.sub(b,i+1,j) l=1 m=0 while m< e.len(k)do n=e.sub(k,m+1,m+1) o=e.sub(k,m+1,m+8) if not(o==";" )then c=p("0x" ..e.sub(o,1,2)) q=p("0x" ..e.sub(o,3,4)) r=p("0x" ..e.sub(o,5,6)) s=p("0x" ..e.sub(o,7,8)) if s==0 then g[h][l]=false else g[h][l]={}g[h][l][1]=c g[h][l][2]=q g[h][l][3]=r g[h][l][4]=s end end m=m+8 l=l+1 end i=j j=e.find(b,";" ,j+1) h=h+1 end return g end t=0.4 function u(v,w,c,q,r,s) if not c then c=0 end if not q then q=0 end if not r then r=0 end if not s then s=0 end x.setColor(c*t,q*t,r*t,s) x.drawRectF(v-1,w-1,1,1) end y=0 z=0 function onDraw() A=x.getWidth() B=x.getHeight() if not C then return end k=1 while not(C[k]==nil)do o=1 while not(C[k][o]==nil)do if not C[k][o]==false then u(y+o,z+D-1+k,C[k][o][1],C[k][o][2],C[k][o][3],C[k][o][4]*E) end o=o+1 end k=k+1 end end E=1 function onTick() --E=input.getNumber(1) end D=___START___ f=___SRPL___ H=___HEX___ d=___DRPL___ C=a(H)

The not minified and easy to read version of the above code:

(copy this to the upper codearea to use it for code generation)

function parse(hex) r = 1 while drpl[r] do hex = string.gsub( hex, drpl[r][2], drpl[r][1]) r = r +1 end r = 1 while srpl[r] do hex = string.gsub( hex, srpl[r][2], srpl[r][1]) r = r +1 end img = {} liC = 1 lasCol = 0 colPo = string.find(hex, ";") while colPo do img[liC] = {} ln = string.sub(hex, lasCol + 1, colPo) i = 1 c = 0 while c < string.len(ln) do first = string.sub(ln, c+1, c+1) clr = string.sub(ln, c+1, c+8) if not (clr == ";") then r = tonumber("0x"..string.sub(clr,1,2)) g = tonumber("0x"..string.sub(clr,3,4)) b = tonumber("0x"..string.sub(clr,5,6)) a = tonumber("0x"..string.sub(clr,7,8)) if a == 0 then img[liC][i] = false else img[liC][i] = {} img[liC][i][1] = r img[liC][i][2] = g img[liC][i][3] = b img[liC][i][4] = a end end c = c + 8 i = i + 1 end lasCol = colPo colPo = string.find(hex, ";", colPo + 1) liC = liC + 1 end return img end clM = 0.4 function paPi(x, y, r, g, b, a) if not r then r = 0 end if not g then g = 0 end if not b then b = 0 end if not a then a = 0 end screen.setColor(r*clM, g*clM, b*clM, a) screen.drawRectF(x-1,y-1,1,1) end xO = 0 yO = 0 function onDraw() sW = screen.getWidth() sH = screen.getHeight() if not image then return end ln = 1 while not( image[ln] == nil) do clr = 1 while not( image[ln][clr] == nil) do if not image[ln][clr] == false then paPi(xO+clr, yO+(startL-1)+ln, image[ln][clr][1], image[ln][clr][2], image[ln][clr][3], image[ln][clr][4]*alpha) end clr = clr + 1 end ln = ln + 1 end end alpha=1 function onTick() --alpha = input.getNumber(1) end startL = ___START___ srpl = ___SRPL___ hx = ___HEX___ drpl = ___DRPL___ image = parse(hx)
Source Code