Page 1 of 1

Does Love support this (Nothing in the docs)?

Posted: Fri Dec 28, 2012 6:41 am
by Carterly
I know there is a SDL_SetColorKey function. Can I create an image from something.gif and then make anything that is pink (255,0,255) transparent? Pixel images are easy to edit in MSPaint :D

Re: Does Love support this (Nothing in the docs)?

Posted: Fri Dec 28, 2012 7:08 am
by slime
Color keys are an old 90's software rendering technique. LÖVE uses post-millenium OpenGL (GPU-accelerated rendering), which doesn't have inherent support for that but does have full support for separate alpha channels in images.

You can load the image as imagedata (love.image.newImageData(filename)), and then use ImageData:mapPixel to find pixels of a specified color and replace them with pure transparency, before loading the imagedata to an OpenGL image with love.graphics.newImage(imagedata).

Re: Does Love support this (Nothing in the docs)?

Posted: Fri Dec 28, 2012 10:56 am
by monsieur_h
slime wrote: You can load the image as imagedata (love.image.newImageData(filename)), and then use ImageData:mapPixel to find pixels of a specified color and replace them with pure transparency, before loading the imagedata to an OpenGL image with love.graphics.newImage(imagedata).
Or you can simply put your image in <insert your favorite image editor here> and replace the given color by a fully transparent one, once for all. That way, what you will see is what is displayed get. Bonus: you don't bother your program with any heavy pixel-replacing function. :megagrin: