Getting Image Data of Image

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Drakkahn
Prole
Posts: 28
Joined: Sat Jan 17, 2015 11:09 pm

Getting Image Data of Image

Post by Drakkahn »

I've been looking through the love api and I can't seem to find a way to get the ImageData from an image. I know you can replace it with (Image:replacePixels()) and you used to be able to get it with (Image:getData()). Was that feature removed, or is there just something I'm missing?
User avatar
steVeRoll
Party member
Posts: 140
Joined: Sun Feb 14, 2016 1:13 pm

Re: Getting Image Data of Image

Post by steVeRoll »

GVovkiv wrote: Sat Mar 06, 2021 10:05 pm I guess you talking about https://love2d.org/wiki/(Image):getData
If you read the big red warning at the top, you'll see that this function is removed since love 11.0. And like the warning suggests, there is no way to get an ImageData from an Image anymore - instead, you should first create an ImageData, and then create the Image from that, while still keeping a reference of the original ImageData around.
eliddell
Prole
Posts: 20
Joined: Sat Dec 10, 2016 6:38 pm

Re: Getting Image Data of Image

Post by eliddell »

Or you could cheat: draw the Image to a Canvas of the same size, and use Canvas:newImageData() to get what you want. Following the wiki's recommendation is probably more efficient, though.
User avatar
GVovkiv
Party member
Posts: 686
Joined: Fri Jan 15, 2021 7:29 am

Re: Getting Image Data of Image

Post by GVovkiv »

steVeRoll wrote: Sat Mar 06, 2021 10:17 pm
GVovkiv wrote: Sat Mar 06, 2021 10:05 pm I guess you talking about https://love2d.org/wiki/(Image):getData
If you read the big red warning at the top, you'll see that this function is removed since love 11.0. And like the warning suggests, there is no way to get an ImageData from an Image anymore - instead, you should first create an ImageData, and then create the Image from that, while still keeping a reference of the original ImageData around.
yeah
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests