]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/imagpcx.cpp
added xpmdecod.cpp
[wxWidgets.git] / src / common / imagpcx.cpp
index 0f1db2771444d536297b9dc0a62416eb8881225a..d03735e4c5ec0b851221d9684e6e43844bd3fef5 100644 (file)
@@ -23,7 +23,7 @@
 #  include "wx/defs.h"
 #endif
 
-#if wxUSE_STREAMS && wxUSE_PCX
+#if wxUSE_IMAGE && wxUSE_STREAMS && wxUSE_PCX
 
 #include "wx/imagpcx.h"
 #include "wx/wfstream.h"
@@ -276,6 +276,18 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
             *(p++) = pal[3 * index + 1];
             *(p++) = pal[3 * index + 2];
         }
+
+        unsigned char* r = new unsigned char[256];
+        unsigned char* g = new unsigned char[256];
+        unsigned char* b = new unsigned char[256];
+        for (i = 0; i < 256; i++)
+        {
+            r[i] = pal[3*i + 0];
+            g[i] = pal[3*i + 1];
+            b[i] = pal[3*i + 2];
+        }
+        image->SetPalette(wxPalette(256, r, g, b));
+        delete[] r; delete[] g; delete[] b;
     }
 
     return wxPCX_OK;