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?
Transparency issues
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- 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)
Please upload a working and a not-working image.
Curiosity: Why do you use a color instead of real transparency?
PS: Perhaps it has to do with 'indexed' status of the images.
PPS: Maybe uploading the code would help too.
Are the bordered images JPG? (Well, if you say PNG, apparently not)
Please upload a working and a not-working image.
Curiosity: Why do you use a color instead of real transparency?
PS: Perhaps it has to do with 'indexed' status of the images.
PPS: Maybe uploading the code would help too.
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)
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
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:
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.
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)
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.
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).
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
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.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).
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)
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
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.
Re: Transparency issues
Ah. Thanks. Using .tga fixes this.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest