Converting premultiplied to non-premultiplied

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
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Converting premultiplied to non-premultiplied

Post by grump »

Canvas:newImageData returns an image with premutliplied alpha. What is the best way to convert to an image that is not premultiplied? This is how I'm currently doing it:

Code: Select all

local img = canvas:newImageData()
img:mapPixel(function(x, y, r, g, b, a)
	return r / a * 255, g / a * 255, b / a * 255, a
end)
Is there a better/easier/faster way to achieve this?
Post Reply

Who is online

Users browsing this forum: No registered users and 54 guests