libsdl-org/SDL_image

PNG Transparency stopped working with v2.8.0 without setting the color key

dstarosta opened this issue · 6 comments

The "image" variable is an SDL_Surface containing a PNG image with transparent pixels. Previously, the following code would work correctly.

SDL_BlitSurface(image, NULL, current_target_surface, &rect);

Now transparent pixels are rendered as black pixels unless I set the color key before the "SDL_BlitSurface" call as follows:

SDL_SetColorKey(image, SDL_TRUE, SDL_MapRGBA(image->format, 0, 0, 0, 0));

Did you mean to close this? If so, what was the issue? Was it that your PNG files had a palette?

It was an indexed PNG file.

Was the PNG tagged as transparent? If so, can you please attach a sample image and reopen this bug? We should be setting the color key internally if the image is transparent.

I attached a couple of files that we be drawn with transparency without setting the color key in the older versions of the library.

graphics.zip

Fixed, thanks!

Actually, I tested the case where the surface is converted to a texture. Blitting should also work, but can you verify that?