SDL: Include transparency information for icon.png in the image data

From 6f3d0c13371a3b1432a169868a2a9cc4a8588df8 Mon Sep 17 00:00:00 2001
From: Cameron Cawley <[EMAIL REDACTED]>
Date: Tue, 18 Aug 2026 20:03:36 +0100
Subject: [PATCH] Include transparency information for icon.png in the image
 data

---
 VisualC-GDK/tests/testgdk/src/testgdk.cpp |   2 +-
 src/test/SDL_test_common.c                |   5 ----
 test/icon.h                               |  29 +++++++++---------
 test/icon.png                             | Bin 183 -> 200 bytes
 test/icon2x.png                           | Bin 195 -> 213 bytes
 test/testaudio.c                          |   2 +-
 test/testcustomcursor.c                   |  35 ++--------------------
 test/testffmpeg.c                         |   3 --
 test/testgeometry.c                       |   2 +-
 test/testgpu_spinning_cube.c              |   3 --
 test/testgpurender_effects.c              |   4 +--
 test/testgpurender_msdf.c                 |   2 +-
 test/testime.c                            |   2 +-
 test/testnative.c                         |   2 +-
 test/testrendercopyex.c                   |   4 +--
 test/testrendertarget.c                   |   4 +--
 test/testscale.c                          |   4 +--
 test/testshape.c                          |   8 -----
 test/testsprite.c                         |   2 +-
 test/testspriteminimal.c                  |   3 --
 test/testspritesurface.c                  |   3 --
 test/testutils.c                          |  33 +-------------------
 test/testutils.h                          |   2 +-
 test/testviewport.c                       |   2 +-
 test/testwaylandcustom.c                  |   3 --
 25 files changed, 35 insertions(+), 124 deletions(-)

diff --git a/VisualC-GDK/tests/testgdk/src/testgdk.cpp b/VisualC-GDK/tests/testgdk/src/testgdk.cpp
index 1ac2033b3e2df..e3dff71f3aab2 100644
--- a/VisualC-GDK/tests/testgdk/src/testgdk.cpp
+++ b/VisualC-GDK/tests/testgdk/src/testgdk.cpp
@@ -188,7 +188,7 @@ static bool LoadSprite(const char *file)
 
     for (i = 0; i < state->num_windows; ++i) {
         /* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */
-        sprites[i] = LoadTexture(state->renderers[i], file, true);
+        sprites[i] = LoadTexture(state->renderers[i], file);
         if (!sprites[i]) {
             return false;
         }
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 17539f2d52bde..4ac5ae3c22184 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1097,11 +1097,6 @@ static SDL_Surface *SDLTest_LoadIcon(const char *file)
         return NULL;
     }
 
-    if (icon->format == SDL_PIXELFORMAT_INDEX8) {
-        /* Set the colorkey */
-        SDL_SetSurfaceColorKey(icon, 1, *((Uint8 *)icon->pixels));
-    }
-
     return icon;
 }
 
diff --git a/test/icon.h b/test/icon.h
index 8344617cf010e..1fb435d044157 100644
--- a/test/icon.h
+++ b/test/icon.h
@@ -2,18 +2,19 @@ unsigned char icon_png[] = {
   0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
   0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20,
   0x02, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x14, 0x92, 0x67, 0x00, 0x00, 0x00,
-  0x09, 0x50, 0x4c, 0x54, 0x45, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff,
-  0xff, 0x00, 0x53, 0xed, 0x60, 0xc2, 0x00, 0x00, 0x00, 0x69, 0x49, 0x44,
-  0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0xa0, 0x18, 0x84, 0x86, 0x42, 0x68,
-  0xd6, 0x55, 0xab, 0x02, 0xc0, 0x0c, 0xa9, 0x55, 0xab, 0x96, 0x80, 0x19,
-  0x59, 0xab, 0x56, 0xad, 0x04, 0xd1, 0x8c, 0xab, 0x80, 0xc0, 0x01, 0xc8,
-  0x60, 0x03, 0x31, 0x26, 0x80, 0x18, 0x4b, 0xa3, 0x96, 0x46, 0x81, 0x18,
-  0x52, 0x4b, 0x81, 0x70, 0x09, 0x98, 0x01, 0x14, 0x59, 0x02, 0xd1, 0x0d,
-  0xd1, 0x8f, 0xc4, 0x58, 0x99, 0x85, 0xce, 0x80, 0x4a, 0x21, 0x0c, 0x9c,
-  0xba, 0x6a, 0x55, 0x18, 0x88, 0xc1, 0xb8, 0x34, 0x34, 0x34, 0x0a, 0x64,
-  0x17, 0x43, 0x66, 0x68, 0x68, 0x26, 0xc4, 0x3d, 0x53, 0xc3, 0x96, 0xa0,
-  0xba, 0x10, 0xee, 0x66, 0x82, 0x00, 0x00, 0x0b, 0x4e, 0x32, 0x71, 0x69,
-  0x34, 0x3a, 0xd6, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
-  0x42, 0x60, 0x82
+  0x0c, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
+  0x00, 0x00, 0xff, 0xff, 0xff, 0x5a, 0x53, 0x1b, 0x29, 0x00, 0x00, 0x00,
+  0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00,
+  0x00, 0x6a, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0xa0, 0x18,
+  0xac, 0x5a, 0x05, 0xa1, 0xb9, 0x42, 0x43, 0x17, 0x80, 0x19, 0xaa, 0xa1,
+  0xa1, 0x11, 0x60, 0xc6, 0xd4, 0xd0, 0xd0, 0x30, 0x10, 0xcd, 0x14, 0x0a,
+  0x04, 0x0d, 0x40, 0x06, 0x27, 0x88, 0x91, 0x00, 0x62, 0x44, 0x2d, 0x8d,
+  0x5a, 0x0a, 0x62, 0xa8, 0x46, 0x3d, 0x8d, 0x7a, 0x1a, 0x01, 0x66, 0x00,
+  0x45, 0x22, 0x20, 0xba, 0x21, 0xfa, 0x91, 0x18, 0x61, 0x53, 0xd1, 0x19,
+  0x50, 0x29, 0x84, 0x81, 0x59, 0xa1, 0xa1, 0x2b, 0x41, 0x0c, 0xa6, 0xa8,
+  0x55, 0xab, 0x96, 0x82, 0xec, 0x62, 0x98, 0xb6, 0x6a, 0xd5, 0x34, 0x88,
+  0x7b, 0xb2, 0x56, 0x46, 0xa0, 0xba, 0x10, 0xee, 0x66, 0x82, 0x00, 0x00,
+  0xe2, 0x90, 0x27, 0xdc, 0x70, 0xc2, 0x01, 0x8a, 0x00, 0x00, 0x00, 0x00,
+  0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
 };
-unsigned int icon_png_len = 183;
+unsigned int icon_png_len = 200;
diff --git a/test/icon.png b/test/icon.png
index 8bcb6e951a39d16d581033b7a8774485f0c1b497..ecd03cb4e588a065c6f7ee47d0d729cada67586a 100644
GIT binary patch
delta 172
zcmdnac!F_)N<B}2Plzi61H=FSKmthqj|!I71hN=Qg8YIR9G=}s19GxFT^vIsE+;1}
zkXRGNx^SnHvv`B#s)Y*$6OLWEaKS*}tOyqiuLGNU$3%uC7v0_{uA~)iw!KwSjA;z6
zN(#Fae@&D~48ABCpxM$Gxp1MjBhRuGp{u7gy-Av(x-ILfNk{djFt-J}1m2}JF)%!u
Vpnj*|5Mvj}Ii9Y5F6*2UngCQ>KJNek

delta 155
zcmX@XxSer=N<C+QPl)UP|Nj{n7=T3Z+k`_vR;H(mV~E7%<b(whEp1L2*Fsk_9pG6R
zx_VlJWaR3wwJaBVRyQ1AJdwa`sMa9iy?B~iqePH*V*%$3Mv+LSi@X>6k3`IDJ=fr+
z$TMeGR;WbB!5t<hCR{1v&S@DLYDa8?4^LaLOW<8v69a<?x1UjAris-xpsfs^u6{1-
HoD!M<`!PGH

diff --git a/test/icon2x.png b/test/icon2x.png
index f62ef23e0df2a45a1957c3b65510263881459d02..8b166529ba73cd393403f21e17790ddf1b9ffb2c 100644
GIT binary patch
delta 185
zcmX@ic$IO2N<B}2Plzi61H=FSKmthqj|!I71hN=Qg8YIR9G=}s19HkeT^vI!PCvb5
z$k(92!y1tG?)uW@$uBP{Tm4)r#dz7Pq~L>kY+R7S7R|o~T`db*G8krNb@3-1(0e1B
zexCIS!#Br|MpM`=g2h)qYTn9nVgDP=4SU)@Oq(g6Y$UyO#{|#pSvz?)d{ww~rmV$B
l;N`dEhTpQYZ(M%AnaQ_r@#nv>hcZEK^K|udS?83{1ONk2P)q;-

delta 167
zcmV;Y09gOk0mA{1B!3A|OjJex|Nj600RR60Q|(~F0001WNkl<ZILqbIF%G~W2nA3V
z@8`n8{a83<f7PZ+12yf?p+8}H32KCtei%YRAVnyEtTn|4ZXho7j<e?ie1P~scp1tA
zoJqZk53MDD`DIT*_&tQTto)d?QL+nJsb-jqfxQReVYU{sLLhkB4+Hl*wy>w)X9Gqi
V%$+1n>CXTF002ovPDHLkV1nqENfH16

diff --git a/test/testaudio.c b/test/testaudio.c
index 9d282babd0795..5f2f44370131d 100644
--- a/test/testaudio.c
+++ b/test/testaudio.c
@@ -718,7 +718,7 @@ static Texture *CreateTexture(const char *fname)
     if (!tex) {
         SDL_Log("Out of memory!");
     } else {
-        tex->texture = LoadTexture(state->renderers[0], fname, true);
+        tex->texture = LoadTexture(state->renderers[0], fname);
         if (!tex->texture) {
             SDL_Log("Failed to load '%s': %s", fname, SDL_GetError());
             SDL_free(tex);
diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c
index 4fb7ad5b87925..6ac5306595df8 100644
--- a/test/testcustomcursor.c
+++ b/test/testcustomcursor.c
@@ -118,40 +118,9 @@ static const char *cross[] = {
     "16,16"
 };
 
-static SDL_Surface *load_image_file(const char *file)
-{
-    SDL_Surface *surface = SDL_LoadSurface(file);
-    if (surface) {
-        if (SDL_GetSurfacePalette(surface)) {
-            const Uint8 bpp = SDL_BITSPERPIXEL(surface->format);
-            const Uint8 mask = (1 << bpp) - 1;
-            if (SDL_PIXELORDER(surface->format) == SDL_BITMAPORDER_4321)
-                SDL_SetSurfaceColorKey(surface, 1, (*(Uint8 *)surface->pixels) & mask);
-            else
-                SDL_SetSurfaceColorKey(surface, 1, ((*(Uint8 *)surface->pixels) >> (8 - bpp)) & mask);
-        } else {
-            switch (SDL_BITSPERPIXEL(surface->format)) {
-            case 15:
-                SDL_SetSurfaceColorKey(surface, 1, (*(Uint16 *)surface->pixels) & 0x00007FFF);
-                break;
-            case 16:
-                SDL_SetSurfaceColorKey(surface, 1, *(Uint16 *)surface->pixels);
-                break;
-            case 24:
-                SDL_SetSurfaceColorKey(surface, 1, (*(Uint32 *)surface->pixels) & 0x00FFFFFF);
-                break;
-            case 32:
-                SDL_SetSurfaceColorKey(surface, 1, *(Uint32 *)surface->pixels);
-                break;
-            }
-        }
-    }
-    return surface;
-}
-
 static SDL_Surface *load_image(const char *file)
 {
-    SDL_Surface *surface = load_image_file(file);
+    SDL_Surface *surface = SDL_LoadSurface(file);
     if (surface) {
         /* Add a 2x version of this image, if available */
         SDL_Surface *surface2x = NULL;
@@ -166,7 +135,7 @@ static SDL_Surface *load_image(const char *file)
             } else {
                 SDL_strlcat(file2x, "2x", len);
             }
-            surface2x = load_image_file(file2x);
+            surface2x = SDL_LoadSurface(file2x);
             SDL_free(file2x);
         }
         if (surface2x) {
diff --git a/test/testffmpeg.c b/test/testffmpeg.c
index 8ff1b93a49c84..da1420e14ae24 100644
--- a/test/testffmpeg.c
+++ b/test/testffmpeg.c
@@ -236,9 +236,6 @@ static SDL_Texture *CreateTexture(SDL_Renderer *r, unsigned char *data, unsigned
     if (src) {
         surface = SDL_LoadPNG_IO(src, true);
         if (surface) {
-            /* Treat white as transparent */
-            SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255));
-
             texture = SDL_CreateTextureFromSurface(r, surface);
             *w = surface->w;
             *h = surface->h;
diff --git a/test/testgeometry.c b/test/testgeometry.c
index a45b35feaa752..96586cd5e2a6c 100644
--- a/test/testgeometry.c
+++ b/test/testgeometry.c
@@ -52,7 +52,7 @@ static int LoadSprite(const char *file)
 
     for (i = 0; i < state->num_windows; ++i) {
         /* This does the SDL_LoadPNG step repeatedly, but that's OK for test code. */
-        sprites[i] = LoadTexture(state->renderers[i], file, true);
+        sprites[i] = LoadTexture(state->renderers[i], file);
         if (!sprites[i]) {
             return -1;
         }
diff --git a/test/testgpu_spinning_cube.c b/test/testgpu_spinning_cube.c
index 843d514001975..c06e93afa5cd4 100644
--- a/test/testgpu_spinning_cube.c
+++ b/test/testgpu_spinning_cube.c
@@ -126,9 +126,6 @@ static SDL_Texture *CreateSpriteTexture(SDL_Renderer *renderer, unsigned char *d
     if (src) {
         surface = SDL_LoadPNG_IO(src, true);
         if (surface) {
-            /* Treat white as transparent */
-            SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255));
-
             texture = SDL_CreateTextureFromSurface(renderer, surface);
             SDL_DestroySurface(surface);
         }
diff --git a/test/testgpurender_effects.c b/test/testgpurender_effects.c
index a593890c47677..acd90ba73106e 100644
--- a/test/testgpurender_effects.c
+++ b/test/testgpurender_effects.c
@@ -263,13 +263,13 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
         return SDL_APP_FAILURE;
     }
 
-    background = LoadTexture(renderer, "sample.png", false);
+    background = LoadTexture(renderer, "sample.png");
     if (!background) {
         SDL_Log("Couldn't create background: %s", SDL_GetError());
         return SDL_APP_FAILURE;
     }
 
-    sprite = LoadTexture(renderer, "icon.png", true);
+    sprite = LoadTexture(renderer, "icon.png");
     if (!sprite) {
         SDL_Log("Couldn't create sprite: %s", SDL_GetError());
         return SDL_APP_FAILURE;
diff --git a/test/testgpurender_msdf.c b/test/testgpurender_msdf.c
index 32520744b0b0d..2ba095a5d99a5 100644
--- a/test/testgpurender_msdf.c
+++ b/test/testgpurender_msdf.c
@@ -57,7 +57,7 @@ static GlyphInfo glyphs[128];
 
 static bool LoadFontTexture(void)
 {
-    font_texture = LoadTexture(renderer, "msdf_font.png", false);
+    font_texture = LoadTexture(renderer, "msdf_font.png");
     if (!font_texture) {
         SDL_Log("Failed to create font texture: %s", SDL_GetError());
         return false;
diff --git a/test/testime.c b/test/testime.c
index 9005f17f5054f..d5ff7c91dfca1 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -1018,7 +1018,7 @@ int main(int argc, char *argv[])
         ctx->window = window;
         ctx->renderer = renderer;
         ctx->rendererID = i;
-        ctx->settings_icon = LoadTexture(renderer, "icon.png", true);
+        ctx->settings_icon = LoadTexture(renderer, "icon.png");
         if (ctx->settings_icon) {
             ctx->settings_rect.w = (float)ctx->settings_icon->w;
             ctx->settings_rect.h = (float)ctx->settings_icon->h;
diff --git a/test/testnative.c b/test/testnative.c
index 5df1b6616874f..dcc648ecd23f3 100644
--- a/test/testnative.c
+++ b/test/testnative.c
@@ -168,7 +168,7 @@ int main(int argc, char *argv[])
     SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
     SDL_RenderClear(renderer);
 
-    sprite = LoadTexture(renderer, "icon.png", true);
+    sprite = LoadTexture(renderer, "icon.png");
     if (!sprite) {
         quit(6);
     }
diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c
index ce19fa12d9f74..c161470cb87fb 100644
--- a/test/testrendercopyex.c
+++ b/test/testrendercopyex.c
@@ -135,8 +135,8 @@ int main(int argc, char *argv[])
 
         drawstate->window = state->windows[i];
         drawstate->renderer = state->renderers[i];
-        drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png", true);
-        drawstate->background = LoadTexture(drawstate->renderer, "sample.png", false);
+        drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png");
+        drawstate->background = LoadTexture(drawstate->renderer, "sample.png");
         if (!drawstate->sprite || !drawstate->background) {
             quit(2);
         }
diff --git a/test/testrendertarget.c b/test/testrendertarget.c
index 019b0638859d6..08dad4df0f0c4 100644
--- a/test/testrendertarget.c
+++ b/test/testrendertarget.c
@@ -252,8 +252,8 @@ int main(int argc, char *argv[])
 
         drawstate->window = state->windows[i];
         drawstate->renderer = state->renderers[i];
-        drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png", true);
-        drawstate->background = LoadTexture(drawstate->renderer, "sample.png", false);
+        drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png");
+        drawstate->background = LoadTexture(drawstate->renderer, "sample.png");
         if (!drawstate->sprite || !drawstate->background) {
             quit(2);
         }
diff --git a/test/testscale.c b/test/testscale.c
index 08eee2e48d723..caabeac507822 100644
--- a/test/testscale.c
+++ b/test/testscale.c
@@ -153,8 +153,8 @@ int main(int argc, char *argv[])
 
         drawstate->window = state->windows[i];
         drawstate->renderer = state->renderers[i];
-        drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png", true);
-        drawstate->background = LoadTexture(drawstate->renderer, "sample.png", false);
+        drawstate->sprite = LoadTexture(drawstate->renderer, "icon.png");
+        drawstate->background = LoadTexture(drawstate->renderer, "sample.png");
         if (!drawstate->sprite || !drawstate->background) {
             quit(2);
         }
diff --git a/test/testshape.c b/test/testshape.c
index 610792d1ed88b..c8da41593e110 100644
--- a/test/testshape.c
+++ b/test/testshape.c
@@ -91,14 +91,6 @@ int main(int argc, char *argv[])
         goto quit;
     }
 
-    if (!SDL_ISPIXELFORMAT_ALPHA(shape->format)) {
-        /* Set the colorkey to the top-left pixel */
-        Uint8 r, g, b, a;
-
-        SDL_ReadSurfacePixel(shape, 0, 0, &r, &g, &b, &a);
-        SDL_SetSurfaceColorKey(shape, 1, SDL_MapSurfaceRGBA(shape, r, g, b, a));
-    }
-
     if (!resizable) {
         /* Set the hit test callback so we can drag the window */
         if (!SDL_SetWindowHitTest(window, ShapeHitTest, shape)) {
diff --git a/test/testsprite.c b/test/testsprite.c
index 575be116303fc..6ce66fa60a275 100644
--- a/test/testsprite.c
+++ b/test/testsprite.c
@@ -60,7 +60,7 @@ static bool LoadSprite(const char *file)
         if (sprites[i]) {
             SDL_DestroyTexture(sprites[i]);
         }
-        sprites[i] = LoadTexture(state->renderers[i], file, true);
+        sprites[i] = LoadTexture(state->renderers[i], file);
         if (sprites[i]) {
             sprite_w = (float)sprites[i]->w;
             sprite_h = (float)sprites[i]->h;
diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c
index 9d9bed336acaf..20860431d0112 100644
--- a/test/testspriteminimal.c
+++ b/test/testspriteminimal.c
@@ -41,9 +41,6 @@ static SDL_Texture *CreateTexture(SDL_Renderer *r, unsigned char *data, unsigned
     if (src) {
         surface = SDL_LoadPNG_IO(src, true);
         if (surface) {
-            /* Treat white as transparent */
-            SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255));
-
             texture = SDL_CreateTextureFromSurface(r, surface);
             *w = surface->w;
             *h = surface->h;
diff --git a/test/testspritesurface.c b/test/testspritesurface.c
index 69ff27dccb7e8..71756042e8b14 100644
--- a/test/testspritesurface.c
+++ b/test/testspritesurface.c
@@ -40,9 +40,6 @@ static SDL_Surface *CreateSurface(unsigned char *data, unsigned int len, int *w,
     if (src) {
         surface = SDL_LoadPNG_IO(src, true);
         if (surface) {
-            /* Treat white as transparent */
-            SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255));
-
             *w = surface->w;
             *h = surface->h;
         }
diff --git a/test/testutils.c b/test/testutils.c
index 79d5abfecab3e..c9139d48268a3 100644
--- a/test/testutils.c
+++ b/test/testutils.c
@@ -123,13 +123,11 @@ char *GetResourceFilename(const char *user_specified, const char *def)
  * Load the .png file whose name is file, from the SDL_GetBasePath() if
  * possible or the current working directory if not.
  *
- * If transparent is true, set the transparent colour from the top left pixel.
- *
  * If width_out is non-NULL, set it to the texture width.
  *
  * If height_out is non-NULL, set it to the texture height.
  */
-SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, bool transparent)
+SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file)
 {
     SDL_Surface *temp = NULL;
     SDL_Texture *texture = NULL;
@@ -145,35 +143,6 @@ SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, bool transpar
     if (!temp) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
     } else {
-        /* Set transparent pixel as the pixel at (0,0) */
-        if (transparent) {
-            if (SDL_GetSurfacePalette(temp)) {
-                const Uint8 bpp = SDL_BITSPERPIXEL(temp->format);
-                const Uint8 mask = (1 << bpp) - 1;
-                if (SDL_PIXELORDER(temp->format) == SDL_BITMAPORDER_4321)
-                    SDL_SetSurfaceColorKey(temp, true, (*(Uint8 *)temp->pixels) & mask);
-                else
-                    SDL_SetSurfaceColorKey(temp, true, ((*(Uint8 *)temp->pixels) >> (8 - bpp)) & mask);
-            } else {
-                switch (SDL_BITSPERPIXEL(temp->format)) {
-                case 15:
-                    SDL_SetSurfaceColorKey(temp, true,
-                                    (*(Uint16 *)temp->pixels) & 0x00007FFF);
-                    break;
-                case 16:
-                    SDL_SetSurfaceColorKey(temp, true, *(Uint16 *)temp->pixels);
-                    break;
-                case 24:
-                    SDL_SetSurfaceColorKey(temp, true,
-                                    (*(Uint32 *)temp->pixels) & 0x00FFFFFF);
-                    break;
-                case 32:
-                    SDL_SetSurfaceColorKey(temp, true, *(Uint32 *)temp->pixels);
-                    break;
-                }
-            }
-        }
-
         texture = SDL_CreateTextureFromSurface(renderer, temp);
         if (!texture) {
             SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s", SDL_GetError());
diff --git a/test/testutils.h b/test/testutils.h
index 83d7c295a33bb..e4da0a517bbe0 100644
--- a/test/testutils.h
+++ b/test/testutils.h
@@ -20,7 +20,7 @@
 extern "C" {
 #endif
 
-extern SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, bool transparent);
+extern SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file);
 extern char *GetNearbyFilename(const char *file);
 extern char *GetResourceFilename(const char *user_specified, const char *def);
 
diff --git a/test/testviewport.c b/test/testviewport.c
index 0c05b8a47f100..9b989af91e25f 100644
--- a/test/testviewport.c
+++ b/test/testviewport.c
@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
         quit(2);
     }
 
-    sprite = LoadTexture(state->renderers[0], "icon.png", true);
+    sprite = LoadTexture(state->renderers[0], "icon.png");
     if (!sprite) {
         quit(2);
     }
diff --git a/test/testwaylandcustom.c b/test/testwaylandcustom.c
index 248204f3f0f3f..138d1177f960a 100644
--- a/test/testwaylandcustom.c
+++ b/test/testwaylandcustom.c
@@ -38,9 +38,6 @@ static SDL_Texture *CreateTexture(SDL_Renderer *r, unsigned char *data, unsigned
     if (src) {
         surface = SDL_LoadPNG_IO(src, true);
         if (surface) {
-            /* Treat white as transparent */
-            SDL_SetSurfaceColorKey(surface, true, SDL_MapSurfaceRGB(surface, 255, 255, 255));
-
             texture = SDL_CreateTextureFromSurface(r, surface);
             *w = surface->w;
             *h = surface->h;