Page 1 of 1

LÖVE Image Transformations

Posted: Mon Dec 14, 2009 7:40 am
by TechnoCat
This library attempts to add some simple photo-manipulation functions into LÖVE.
It includes: black and white, saturation, brightness, color shift, and invert.


I am unsure if my saturation function is correct, it appears to have a similar result to other saturation functions out there.

Code: Select all

r, g, b ,a = imageData:getPixel(i, j)
			avg = (r+g+b)/3
			r = math.max(0, math.min(255, avg+(r-126)*saturation))
			g = math.max(0, math.min(255, avg+(g-126)*saturation))
			b = math.max(0, math.min(255, avg+(b-126)*saturation))
ImageTranform.love
(15.43 KiB) Downloaded 222 times
image-transform.png
image-transform.png (241.88 KiB) Viewed 4328 times

Re: LÖVE Image Transformations

Posted: Tue Dec 15, 2009 12:39 am
by tido170
You are reading my mind!
I'm working on a megaman game and I was wondering if we could change the color of megaman without having to create a new image!

Re: LÖVE Image Transformations

Posted: Tue Dec 15, 2009 1:46 am
by TechnoCat
tido170 wrote:You are reading my mind!
I'm working on a megaman game and I was wondering if we could change the color of megaman without having to create a new image!
To change the color, you should also look at color modulation. love.graphics.setColor(r, g, b, a)

Re: LÖVE Image Transformations

Posted: Tue Dec 15, 2009 2:18 am
by tido170
I think I have all what I need, I have to check the color of the pixel and if it is the right blue, I change it to the desired color.

Re: LÖVE Image Transformations

Posted: Wed Dec 16, 2009 1:23 am
by TechnoCat
No longer all crashy. Also pads images for odd graphics chipsets.
ImageTranform.love
0.6
(15.43 KiB) Downloaded 233 times

Re: LÖVE Image Transformations

Posted: Wed Dec 16, 2009 6:54 am
by Robin
TechnoCat wrote: Also pads images for odd graphics chipsets.
Nice. :)