Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function khan(filename,scriptname,squaresize) -- Type in your luasocket or whatever "khan(Name of image,name of
- -- created script,squaresize)" Without the quotes. It works well if pic
- -- is less than 200x200 pix. It only works with 24-bit BMPs though.
- -- Squaresize: Size of the pixels.
- local file=io.open(filename,'rb')
- local f=io.open(scriptname,'w')
- file:seek('set',18)
- local y=string.byte(file:read(1))+string.byte(file:read(1))*256+string.byte(file:read(1))*65536+string.byte(file:read(1))*16777216
- local x=string.byte(file:read(1))+string.byte(file:read(1))*256+string.byte(file:read(1))*65536+string.byte(file:read(1))*16777216
- file:seek('set',54)
- local r,g,b=0,0,0
- for j=0,x-1 do
- for i=0,y-1 do
- b,g,r=string.byte(file:read(1)),string.byte(file:read(1)),string.byte(file:read(1))
- if i*squaresize<401 and (x-j)*squaresize<401 then
- f:write("stroke(",r,",",g,",",b,");\n")
- f:write("rect(",i*squaresize,",",(x-j)*squaresize,",",squaresize,",",squaresize,");\n")
- end
- end
- end
- for i=1,y%4 do file:read(1) end
- file:close()
- end
Advertisement
Add Comment
Please, Sign In to add comment