## Transparency issues

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Lord Tim
Prole
Posts: 30
Joined: Sun Jul 20, 2008 4:07 am

### Transparency issues

Hello, all.

I've been working on my latest game in none other than the wonderous Löve, and I've come across a strange glitch. Some of my sprites have thin magenta borders around them, while other do not. I am using magenta as the transparency color, but the other parts that are magenta are transparent as they should be. I am using mtPaint to create my images (.png).

Here's an example:
(The guy on the top's x/y/a is connected to a physics object, the bottom is a static sprite, both are drawn from love.graphics.draw(sprite,x,y,a) with the same Image object)

Is this because of the way I'm making the actual image? Or is it a Löve/Lua/OpenGL issue? Any way to fix it?

qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

### Re: Transparency issues

Anti-aliasing?

Are the bordered images JPG? (Well, if you say PNG, apparently not)

Curiosity: Why do you use a color instead of real transparency?

PS: Perhaps it has to do with 'indexed' status of the images.

lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)

rude
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

### Re: Transparency issues

This is probably due to how PNG handles transparent textures when scaled/rotated/translated. I added a feature a while back (which noone cared about at the time) which took care of this problem. I tested it a while ago, and it seems to be broken in 0.5.0. Typical.

You can try it if you want, maybe I'm mistaken. Load the image like this:

Code: Select all

image = love.graphics.newImage("fist.png", love.image_optimize)

If you math.floor the x,y-position before drawing the sprite, the problem will go away, though. (Unless you scale/rotate it). Of course, that will also lead to non-smooth movement.

Lord Tim
Prole
Posts: 30
Joined: Sun Jul 20, 2008 4:07 am

### Re: Transparency issues

Cool, thanks for that.

I had already tried out the optimize setting before, but yeah, doesn't fix the problem.

Is there a better way to add the transparency to images? I'm a bit new at that, and the index option seemed the easiest.

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Transparency issues

Gimp has an option to convert a color to alpha, don't know exactly if it works as you need it to, it is located under color (and is called color to alpha, or something similar).

Lord Tim
Prole
Posts: 30
Joined: Sun Jul 20, 2008 4:07 am

### Re: Transparency issues

Would a different image format not have this problem? Like if I used .gif instead?

qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

### Re: Transparency issues

bartbes wrote:Gimp has an option to convert a color to alpha, don't know exactly if it works as you need it to, it is located under color (and is called color to alpha, or something similar).
I do it by right-clicking the layer (in the layer dialog) and clicking "add alpha to layer" then, when you erase or delete (DEL) pixels, they are transparent.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)

rude
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

### Re: Transparency issues

If you fill the magenta areas with black and use a TGA transparency mask for the transparent areas it will probably solve your problem.

Lord Tim
Prole
Posts: 30
Joined: Sun Jul 20, 2008 4:07 am

### Re: Transparency issues

Ah. Thanks. Using .tga fixes this.

### Who is online

Users browsing this forum: cazura and 16 guests