| Summary: | PNG w/transparency breaks in SDL 2.0.10 but works in SDL 2.0.9 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Hugo Hromic <hhromic> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | sylvain.becker |
| Version: | 2.0.10 | Keywords: | target-2.0.12 |
| Hardware: | x86_64 | ||
| OS: | Windows 7 | ||
| Attachments: |
First Sample: Mr Grump test image
Second Sample: Dialog box test image Screenshot of wrong output of first image in SDL 2.0.10 |
||
|
Description
Hugo Hromic
2019-09-09 21:33:03 UTC
Created attachment 3961 [details]
Second Sample: Dialog box test image
I attached now a second example image that is also affected.
The black area is supposed to be opaque and displays correctly in SDL 2.0.9 (or below), however when you display it using SDL 2.0.10 the black area becomes transparent because the black color is treated as a transparent color.
You image has a palette (index8 pixel format), and a colorkey (40).
So your image has some transparent zone (where color is 40) and you see the background color.
This seems expected to me.
Log: format=SDL_PIXELFORMAT_INDEX8 key=40 ret=0
int key = 0;
int ret = SDL_GetColorKey(image, &key);
SDL_Log("format=%s key=%d ret=%d", SDL_GetPixelFormatName(image->format->format), key, ret);
if you want to remove the colorkey, you can add: SDL_SetColorKey(image, SDL_FALSE, 0);
Created attachment 3963 [details]
Screenshot of wrong output of first image in SDL 2.0.10
Hello Sylvain, Thanks for your reply. Indeed the sample images have indexed palette and have color keys because they are supposed to have transparency pixels. However, pixels inside the character in the image are not supposed to be transparent, only the background around the character. I now attached a screenshot where you can see how it looks in SDL 2.0.10. If you compare that to how it looks for example in your browser or in SDL < 2.0.10 you will see that the character doesn't have any transparent pixels inside, for example in his shirt. Therefore we don't want to remove the color key information, which is necessary to render the transparent background around the character. It feels like a rendering bug to me, specially because it doesn't occur in SDL < 2.0.10 nor other software that displays the same image. I'm not certain is this is an SDL rendering issue or maybe SDL_image is not reading the image correctly and it was "obscured" in previous versions of SDL. I don't think this is a sdl_image (I have tried to various combination of libs). In fact: - palette color 40 is r=255 g=255 b=255 a=255 (the surrounding) - palette color 1 is also r=255 g=255 b=255 a=255 (the inside, the shirt) - colorkey is 40. In the end both regions, with 40 and 1, ends up being transparent. because there is an intermediate conversion to argb, also for the colorkey. First the image is resolved, then the resolved colour key is transformed to transparency. Indeed, it's an issue ... I think this is introduced in https://hg.libsdl.org/SDL/rev/884f99b039f0 (bug 3827) because, with previous version palette color 40 was reported as r=255 g=255 b=255 a=0. Thanks for looking into this so promptly. Appreciated. Let me know of any action needed from my side to help resolving this issue. I think this is fixed now in: https://hg.libsdl.org/SDL/rev/0c66be754e29 I just compiled a test SDL library with your change and I'm happy to confirm it fully solves the reported issue. Many thanks! I will patiently wait for SDL 2.0.11 to migrate from SDL 2.0.9. This bug can be closed as resolved. Thanks again. Great, marked as resolved! We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc). As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change! Thanks, --ryan. We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc). As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change! Thanks, --ryan. |