Defold PNG - Inspect, load and save PNG files

Yes, but not using my extension. You can use:

local file = io.open("my.png", "rb")
local bytes = file:read("*a")
local png = image.load(bytes)
gui.new_texture("my.png", png.width, png.height, "rgba", png.buffer)

Complete example: publicexamples/examples/loadtexture/load_texture/loadtexture.gui_script at master · britzl/publicexamples · GitHub

Now, I could ofc add support for returning decoded image as a string instead of a buffer, but I reasoned that since image.load() exists there was no need for it.

5 Likes