SDL_image: IMG_bmp.c: Add support for 24 bits ICO/CUR images

From e639e64494a473961671454fbb3120dbd0cfce2e Mon Sep 17 00:00:00 2001
From: Ion Agorria <[EMAIL REDACTED]>
Date: Sun, 25 Jul 2021 14:29:37 +0200
Subject: [PATCH] IMG_bmp.c: Add support for 24 bits ICO/CUR images

This adds support for decoding images with 24 bits colors
that are similar to 32 bits without the alpha channel, the
mask is used for visibility instead.
---
 IMG_bmp.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/IMG_bmp.c b/IMG_bmp.c
index c0e2f62..9654cf5 100644
--- a/IMG_bmp.c
+++ b/IMG_bmp.c
@@ -248,6 +248,9 @@ LoadICOCUR_RW(SDL_RWops * src, int type, int freesrc)
         case 8:
             ExpandBMP = 8;
             break;
+        case 24:
+            ExpandBMP = 24;
+            break;
         case 32:
             Rmask = 0x00FF0000;
             Gmask = 0x0000FF00;
@@ -316,6 +319,10 @@ LoadICOCUR_RW(SDL_RWops * src, int type, int freesrc)
         bmpPitch = biWidth;
         pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
         break;
+    case 24:
+        bmpPitch = biWidth * 3;
+        pad = (((bmpPitch) % 4) ? (4 - ((bmpPitch) % 4)) : 0);
+        break;
     default:
         bmpPitch = biWidth * 4;
         pad = 0;
@@ -343,6 +350,26 @@ LoadICOCUR_RW(SDL_RWops * src, int type, int freesrc)
                 }
             }
             break;
+        case 24:
+            {
+                Uint32 pixel;
+                Uint8 channel;
+                for (i = 0; i < surface->w; ++i) {
+                    pixel = 0;
+                    for (int j = 0; j < 3; ++j) {
+                        //Load each color channel into pixel
+                        if (!SDL_RWread(src, &channel, 1, 1)) {
+                            IMG_SetError("Error reading from ICO");
+                            was_error = SDL_TRUE;
+                            goto done;
+                        }
+                        pixel |= (channel << (j * 8));
+    
+                    }
+                    *((Uint32 *) bits + i) = pixel;
+                }
+            }
+            break;
 
         default:
             if (SDL_RWread(src, bits, 1, surface->pitch)