]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/imagbmp.cpp
some stupid attempts to make utf8 work - it doesn't, but the code does no harm and...
[wxWidgets.git] / src / common / imagbmp.cpp
index 600d800ff9dee6160d7cfd2ea430615a4b3a9b1c..5819bd7ec69ce66f0e50b464405fff80d56a030d 100644 (file)
@@ -286,13 +286,26 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
      */
     if (bpp < 16 && ncolors != 0)
     {
      */
     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];
         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)
     {
     }
     else if (bpp == 16 || bpp == 32)
     {