Hello,
I’m trying to download an image from a server and display it in a sprite.
Here is my code:
local url = "https://blablabla.ams3.digitaloceanspaces.com/image.png"
http.request(url, "GET", function(self, id, res)
if res.status ~= 200 and res.status ~= 304 then
print("Unable to get image", res.response)
return
end
local img = image.load(res.response)
if not img then
print("Unable to load image")
else
local img_resource = imageloader.load{data = res.response}
pprint(img_resource)
resource.set_texture( go.get("test_card#sprite", "texture0"), img_resource.header, img_resource.buffer )
end
end)
Problem is, the image doesn’t “fit” into the sprite. It appears much bigger.
Here is the sprite, with the image loaded from its atlas (as part of the game resource):
Here is when I download and change the texture,with the same image:
Can anyone help me about how what’s going on?