Loading image from file (SOLVED)

Here’s the code:

		local file = io.open("assets/images/scene-backgrounds/card.png", "rb")
	local bytes = file:read("*a")
	local png = image.load(bytes)
	gui.new_texture("bgimage", png.width, png.height, "rgba", png.buffer)
	local bgnode = gui.get_node("TOTALbackground")	
	gui.set_texture(bgnode, "bgimage")

but I’m getting…

ERROR:GUI: Invalid image buffer size. Expected 10962000, got 8221500
WARNING:GUI: Failed to create dynamic gui texture (-7)

Fixed it… rgb vs. rgba

1 Like