Closed hexagonrecursion closed 6 months ago
Thanks for the report!
The showimage test program will also demonstrate this issue with the following patch:
diff --git a/examples/showimage.c b/examples/showimage.c
index d544869..faa597c 100644
--- a/examples/showimage.c
+++ b/examples/showimage.c
@@ -104,12 +104,24 @@ int main(int argc, char *argv[])
continue;
}
+#if 1
+ SDL_Surface *surface = IMG_Load(argv[i]);
+ if (surface) {
+ SDL_Surface *tmp = SDL_CreateSurface(surface->w, surface->h, SDL_PIXELFORMAT_RGBA32);
+ if (SDL_BlitSurface(surface, NULL, tmp, NULL) < 0) {
+ SDL_Log("SDL_BlitSurface() failed: %s\n", SDL_GetError());
+ return(2);
+ }
+ texture = SDL_CreateTextureFromSurface(renderer, tmp);
+ }
+#else
/* Open the image file */
texture = IMG_LoadTexture(renderer, argv[i]);
if (!texture) {
SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError());
continue;
}
+#endif
SDL_QueryTexture(texture, NULL, NULL, &w, &h);
/* Save the image file, if desired */
This will be fixed for the SDL 2.8.2 release. Thanks for the excellent bug report!
Did you mean SDL_image 2.8.2? Because SDL is already at 2.28.5
Yes, sorry, I meant SDL_image 2.8.2.
SDL_image >= 2.8.0 loads png files with a palette as a surface with a palette (SDL_PIXELFORMAT_INDEX8). If one or more of the colours in the palette has transparency, the blend mode is set to SDL_BLENDMODE_BLEND, the ColorKey is not set and AlphaMod is not set. This causes issues because SDL_BlitSurface from a surface with this exact combination of options is not supported in SDL.
I consider this a regression because previously we could IMG_Load() those files and use them as a source for blitting, but now we can't.
To show that this exact combination of options is not supported:
Prints:
main.cpp:
To show that png files with a palette that contains colours with transparency trigger this:
Prints:
main.cpp:
Here is the png file I used to test this: bug.png
This code in SDL_blit_1.c is missing
case SDL_COPY_BLEND
:Version information: