Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Display image from URL — Gideros Forum

Display image from URL

Hey guys! So recently I've run into the need to display from an URL.

I have this so far, yet I get the same error.
"|D|image.jpg: Error while reading image file."

Here is the code, I would appreciate any help. Thanks in advance!
local loader = UrlLoader.new("https://picsum.photos/200/300/?random")

local function onComplete(event)
local out = io.open("|D|image.png", "wb")
out:write(event.data)
out:close()

local b = Bitmap.new(Texture.new("|D|image.png"))
stage:addChild(b)
end

local function onError()
print("error")
end

local function onProgress(event)
print("progress: " .. event.bytesLoaded .. " of " .. event.bytesTotal)
end

loader:addEventListener(Event.COMPLETE, onComplete)
loader:addEventListener(Event.ERROR, onError)
loader:addEventListener(Event.PROGRESS, onProgress)


Also, I tried jpeg as well. I don't think the type is the problem here.
Tagged:

Comments

Sign In or Register to comment.