Page 1 of 1
Get image from gallery in android?
Posted: Tue Feb 04, 2020 9:16 am
I want to know if there's a way I can request to get an image from love2d out of the gallery in android. I say android because I don't think it would be cross compatible, but if it is then that's also good. My idea is just to select an image as you do in many apps, and load it into love2d in a drawable format. If the image can be selected, I doubt it will be drawable straight away.
Re: Get image from gallery in android?
Posted: Sat Feb 15, 2020 2:09 pm
Not sure if this is possible with plain Lua. You always have to interact with Java code, but here's the overall steps
1. Write code which loads default image picker (usually gallery, provided by system in recent OS) and return its contents.
2. Write a JNI bridge for that function.
3. Write a Lua binding for that function. If you know how to create LOVE Data
object, prefer that. Otherwise, just return it as plain string.
4. Call it from LOVE code, and if you return raw string instead of LOVE Data object, use love.filesystem.newFileData(contents, "")
5. Once you have the Data object, simply pass that data object to first argument of love.graphics.newImage
to get a drawable image.