LÖVE Image Transformations

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

LÖVE Image Transformations

Post 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 129 times
image-transform.png
image-transform.png (241.88 KiB) Viewed 2314 times
Last edited by TechnoCat on Sun Jul 10, 2011 9:11 pm, edited 2 times in total.
User avatar
tido170
Prole
Posts: 13
Joined: Sat Dec 12, 2009 1:42 am

Re: LÖVE Image Transformations

Post 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!
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: LÖVE Image Transformations

Post 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)
User avatar
tido170
Prole
Posts: 13
Joined: Sat Dec 12, 2009 1:42 am

Re: LÖVE Image Transformations

Post 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.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: LÖVE Image Transformations

Post by TechnoCat »

No longer all crashy. Also pads images for odd graphics chipsets.
ImageTranform.love
0.6
(15.43 KiB) Downloaded 161 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: LÖVE Image Transformations

Post by Robin »

TechnoCat wrote: Also pads images for odd graphics chipsets.
Nice. :)
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests