PNG file save (SOLVED)

Thank you for all your help. @britzl!! :grin:
I downloaded png, saved it, and loaded it. But I also have two questions…

  • The first is the ‘WARNING: GUI: Failed to create dynamic gui texture (-6)’ issue in gui.new_texture. I’m developing the action to bring the stored image when I touch it. The first touch will be gui.set_texture, but it will not work after that.

WARNING:GUI: Failed to create dynamic gui texture (-6)
DEBUG:SCRIPT: ICON NEW TEXTURE ERROR!

local path = sys.get_save_file("image_speaker", icon .. ".png")
	local f = io.open(path, "rb")
	local s = f:read("*a")
		
	f:close()
	local img = image.load(s)
	
	if gui.new_texture("icon", img.width, img.height, "rgba", img.buffer) then -- error here
		
		gui.set_texture(node, "icon")
		
	else
		print("ICON NEW TEXTURE ERROR!")
	end
  • The second is about the image type. I downloaded a png file with an alpha value, but the type of the saved png file is rgb. Is there a problem saving the image?


(my image)
image
(in game image)

This is a image save code.

http.request(URL .. "images/speaker/" .. speaker_data[i].name .. ".png", "GET", function(self, _, response) 
				
		if response.status >= 200 or response.status < 300 then
					
			local path = sys.get_save_file("image_speaker", speaker_data[i].name .. ".png")
			local f = assert(io.open(path, "wb"))
					
			f:write(response.response)
			f:flush()
			f:close()
					
			self.currentdownload = self.currentdownload + 1
			print(self.currentdownload)
					
		end
	end, headers)
1 Like