Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Load B64 images — Gideros Forum

Load B64 images

brigosxbrigosx Member
edited April 2013 in Game & application design
Hi all,

I need to apply a Base64 encoded image (it is downloaded from my site) to a Gideros Texture or Bitmap class. Is that possible? I have found a bit slow lua decoder but I cannot apply it to any of the Gideros availble classes since it is in raw data format after the decoding.

Comments

  • ar2rsawseenar2rsawseen Maintainer
    @brigosx look at the Image Loader example in the Networking section in Gideros IDE, where it downloads raw image saves it and uses it.
    You can do the same. You can save the raw data as :
    --decoding some base64 encoded data with your lua decoder
    local rawdata = decode(base64encodeddata)
     
    --save raw data as image
    local out = io.open("|D|image.png", "wb")
    out:write(rawdata)
    out:close()
     
    --use it as texture
    local b = Bitmap.new(Texture.new("|D|image.png"))
    b:setAnchorPoint(0.5, 0.5)
    b:setPosition(160, 240)
    stage:addChild(b)
  • Thanks for your immidiate response ar2rsawseen. Actually the problem seems to be the Lua base64 decoder. Can you propose me of a good one because the one I found on the net has bugs and is very slow.
  • ar2rsawseenar2rsawseen Maintainer
    Haven't used any, so can't suggest any specific one.
    Better search google for http://www.google.lv/search?q=Base64+lua
  • Whell finally I found a good one at the following URL (search for "Base64 in less code"):
    http://facepunch.com/showthread.php?t=1135811
    It is a bit slow for image files decoding but with the use of a coroutine I managed to overcome the pausing of Gideros player.

    I have attached the library in that post for anyone that may be interested in.
    zip
    zip
    base64.zip
    551B
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.