We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1766 - no colorkey in surfaces loaded from *.png
Summary: no colorkey in surfaces loaded from *.png
Status: RESOLVED FIXED
Alias: None
Product: SDL_image
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86_64 All
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-21 08:41 UTC by Peter Kosyh
Modified: 2013-03-24 12:58 UTC (History)
0 users

See Also:


Attachments
indexed png (289 bytes, image/png)
2013-03-21 08:41 UTC, Peter Kosyh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Kosyh 2013-03-21 08:41:07 UTC
Created attachment 1075 [details]
indexed png

While linking with SDL 2.0 (taken from hg) i got a problem.

After loading indexed (not RGB!) png, i found, that SDL_GetColorKey is always returns -1. I attached png, that gives the problem. Just load it and do SDL_GetColorKey. So, while blitting such Surface we will get black background, instead of transparency.

I tried to debug SDL_image, but all what i got is no SDL_COPY_COLORKEY in surface->map->info.flags just after loading from png.

Of course, if i manually set colorkey with SDL_SetColorKey (for example, taking pixel from 0,0), all is fine, but without knowing png structure i can not found what color key is transparent.

I have no problem with SDL 1.2. Hope, my report will help.
Comment 1 Sam Lantinga 2013-03-23 16:40:02 UTC
I think this is fixed, can you check it?
http://hg.libsdl.org/SDL_image/rev/326a602521f2

Thanks!
Comment 2 Peter Kosyh 2013-03-24 01:37:44 UTC
Thank you! I have pulled from hg and found, that image is transparent now, but, currently only white color is visible. I do not see black borders in image that i attached. 

Just see image in gimp, there are two colors (black, white) and transparent. While blitting i see only white. I am not sure if it is another bug?
Comment 3 Sam Lantinga 2013-03-24 11:53:57 UTC
It's because there are three entries in the palette and only two distinct RGB colors. I'll have to think about the best fix for this.
Comment 4 Sam Lantinga 2013-03-24 12:58:27 UTC
Okay, this is fixed! This required changes both in SDL and SDL_image.
Thanks!