Creating an instance of the Image class from C++ and pushing it to Lua
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Creating an instance of the Image class from C++ and pushing it to Lua
Hello, I am trying to create an instance of the Image class with raw data read from downloading an image file from a URL on the C/C++ side of things and push it to Lua when needed. I am looking through the C code, but I see no clear way of doing this. Can someone help me out here?
Re: Creating an instance of the Image class from C++ and pushing it to Lua
One way would be to pass the raw image data to Lua as a string, so you can use love.image.newImageData from Lua to turn it into an ImageData object that you can easily convert to Image.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Creating an instance of the Image class from C++ and pushing it to Lua
This is kind of vague, what do you want to know? You can definitely just instantiate an Image. Are you looking for luax_pushtype?
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: Creating an instance of the Image class from C++ and pushing it to Lua
Yeah, this is what I'm starting thinking of doing since I don't see a clear way of doing that on the C side of things. Maybe I'm just blind.pgimeno wrote: ↑Sat Jun 30, 2018 2:49 am One way would be to pass the raw image data to Lua as a string, so you can use love.image.newImageData from Lua to turn it into an ImageData object that you can easily convert to Image.
I download an image from a URL via C, and it gets stored on the memory as raw data, which I then would like to use to create an Image object. The downloaded image can be either a .jpg or .png file. I'm having trouble finding an easy way of creating an image from the data I've downloaded that isn't pushing the string to Lua and then calling the necessary methods from there.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Creating an instance of the Image class from C++ and pushing it to Lua
Well, you create a FileData from the downloaded data, then create an ImageData from that, you then use that ImageData to create an Image::Slices object, and use that to create an Image.
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Creating an instance of the Image class from C++ and pushing it to Lua
To be honest, my first question would be why exactly are you going the C route for downloading the images? That should be possible from löve as well.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest