FeynmanTech

Image Plotting in Script Module

Mar 27th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. local f=io.open(filename,'rb')
  2. f:seek('set',18)
  3. local y=string.byte(f:read(1))+string.byte(f:read(1))*256+string.byte(f:read(1))*65536+string.byte(f:read(1))*16777216
  4. local x=string.byte(f:read(1))+string.byte(f:read(1))*256+string.byte(f:read(1))*65536+string.byte(f:read(1))*16777216
  5. f:seek('set',54)
  6. local r,g,b=0,0,0
  7. for j=0,x-1 do
  8.  for i=0,y-1 do
  9.   b,g,r=string.byte(f:read(1)),string.byte(f:read(1)),string.byte(f:read(1))
  10.   if i<612 and x-j<380 and(not(r==0 and g==0 and b==0)) then
  11.    tpt.create(i,x-j,elemtype)
  12.    tpt.set_property('dcolour',r*65536+g*256+b+16777216*255,i,x-j)
  13.    tpt.set_property(proptype,(r + g + b),i,x-j)
  14.    if scale > 0  then
  15.     tpt.set_property(proptype,(r + g + b) * scale,i,x-j)
  16. end
  17. end
  18.   end
  19.  end
  20.  for i=1,y%4 do f:read(1) end
  21. f:close()
Advertisement
Add Comment
Please, Sign In to add comment