Commit db4246f695074745d1ffb60c8b90b07f95c722d0

Sylvain Becker 2020-05-17T21:23:17

Only set colorkey, if converted surface has no alpha channel (2979)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index 7c2d04b..085d9ff 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -1116,9 +1116,13 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
                 /* The palette is identical, just set the same colorkey */
                 SDL_SetColorKey(convert, 1, surface->map->info.colorkey);
             } else if (!format->palette) {
-                set_colorkey_by_color = SDL_TRUE;
-                /* Was done by 'palette_ck_transform' */
-                convert_colorkey = SDL_FALSE;
+                if (format->Amask) {
+                    /* No need to add the colorkey, transparency is in the alpha channel*/
+                } else {
+                    /* Only set the colorkey information */
+                    set_colorkey_by_color = SDL_TRUE;
+                    convert_colorkey = SDL_FALSE;
+                }
             } else {
                 set_colorkey_by_color = SDL_TRUE;
             }