I’m still out on deep water, on my quest to learn this fantastic tool. Now I’m missing the final touch on this feature, before I can move along.
So far I’ve been able to connect to Facebook, download the players(me in this case) profile picture, saved it to the device file system (using io.open() (another great adventure)), and also been able to read the file from the file system. I’ve checked the values, and they are similar both at download and read, and I’ve also checked it physicaly, by checking at app bundle via xcode. The image is there, in all its glory.
Now I would like to assign that image to a texture, to use on my box node. The problem is, that it fail when i try to create the new texture, with the error:
ERROR:GUI: Invalid image buffer size. Expected 30000, got 3718
WARNING:GUI: Failed to create dynamic gui texture (-7)
I thought it was time to call for help, since I’ve spent too much time one it, trying to solve it by Google.
My function:
local function set_fb_pic()
pprint("Setting FB avatar")
local file = assert(io.open(shared_data.home .. shared_data.avatar_file, "r"))
local w, h = getsize(file)
pprint(w)
pprint(h)
local size = file:seek("end")
file:seek("set", 0)
local data = file:read("*a")
data = string.gsub(data, "\r\n", "\n")
assert(file:close())
pprint(file)
--local img = assert(image.load(data))
--print(img)
if gui.new_texture("avatar_tx", w, h, "rgb", data) then
local n = gui.get_node("fb_pic")
pprint(n)
end
end
Sorry for the messy code.