X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..523050b607cfb5e6f9dfcb1544eb4f49ec1978cd:/src/common/imagbmp.cpp

diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp
index 600d800ff9..5819bd7ec6 100644
--- a/src/common/imagbmp.cpp
+++ b/src/common/imagbmp.cpp
@@ -286,13 +286,26 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
      */
     if (bpp < 16 && ncolors != 0)
     {
+        unsigned char* r = new unsigned char[ncolors];
+        unsigned char* g = new unsigned char[ncolors];
+        unsigned char* b = new unsigned char[ncolors];
         for (int j = 0; j < ncolors; j++)
         {
             stream.Read( bbuf, 4 );
             cmap[j].b = bbuf[0];
             cmap[j].g = bbuf[1];
             cmap[j].r = bbuf[2];
+
+            r[j] = cmap[j].r;
+            g[j] = cmap[j].g;
+            b[j] = cmap[j].b;
         }
+        // Set the palette for the wxImage
+        image->SetPalette(wxPalette(ncolors, r, g, b));
+
+        delete[] r;
+        delete[] g;
+        delete[] b;
     }
     else if (bpp == 16 || bpp == 32)
     {