Progress?
This commit is contained in:
parent
8d00d53b88
commit
a1ead55053
30
demo.lua
30
demo.lua
|
@ -1,5 +1,17 @@
|
|||
local bitmap = require'bitmap' --used to read its content
|
||||
|
||||
function int_exa(nb)
|
||||
output = "0123456789abcdef"
|
||||
first_digit = 0
|
||||
while nb > 15 do
|
||||
nb = nb - 16
|
||||
first_digit = first_digit + 1
|
||||
end
|
||||
return output:sub(first_digit + 1, 1)..output:sub(nb + 1, 1)
|
||||
end
|
||||
|
||||
io.write("from casioplot import set_pixel, show_screen as S, R\n")
|
||||
|
||||
do --open image
|
||||
local cairo = require'cairo' --used to open the file
|
||||
local image = cairo.load_png(arg[1])
|
||||
|
@ -7,4 +19,20 @@ do --open image
|
|||
image_bitmap = image:bitmap()
|
||||
end
|
||||
local getpixel, setpixel = bitmap.pixel_interface(image_bitmap)
|
||||
print(image_infos.width, image_infos.height)
|
||||
|
||||
pallet = {} --will store colors
|
||||
pallet_last = 0
|
||||
|
||||
|
||||
for j = 1, image_infos.height, 1 do
|
||||
for i = 1, image_infos.width, 1 do
|
||||
r, g, b = getpixel(i, j)
|
||||
if not pallet[r.." "..g.." "..b] then
|
||||
pallet[r.." "..g.." "..b] = pallet_last
|
||||
pallet_last = pallet_last + 1
|
||||
end
|
||||
io.write(int_exa(pallet[r.." "..g.." "..b]))
|
||||
end
|
||||
end
|
||||
|
||||
io.write("\nR()")
|
||||
|
|
Loading…
Reference in New Issue