Does Love support this (Nothing in the docs)?

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
Carterly
Prole
Posts: 1
Joined: Fri Dec 28, 2012 6:12 am
Contact:

Does Love support this (Nothing in the docs)?

Post 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
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

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

Post 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).
User avatar
monsieur_h
Citizen
Posts: 65
Joined: Tue Oct 30, 2012 4:43 pm

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

Post 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:
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests