]> git.saurik.com Git - wxWidgets.git/commitdiff
store palette information from XPM in wxImage (#9763)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Aug 2008 10:31:07 +0000 (10:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Aug 2008 10:31:07 +0000 (10:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/xpmdecod.cpp

index a752ead86f44ad8e758bd29c00b9c33b258639ce..ae43e513fdee898bf755fcf10166d3f7a27901c6 100644 (file)
@@ -809,7 +809,23 @@ wxImage wxXPMDecoder::ReadData(const char* const* xpm_data)
             img_data[2] = entry->second.B;
         }
     }
+#if wxUSE_PALETTE
+    unsigned char* r = new unsigned char[colors_cnt];
+    unsigned char* g = new unsigned char[colors_cnt];
+    unsigned char* b = new unsigned char[colors_cnt];
 
+    for (it = clr_tbl.begin(), i = 0; it != clr_tbl.end(); it++, i++)
+    {
+        r[i] = it->second.R;
+        g[i] = it->second.G;
+        b[i] = it->second.B;
+    }
+    wxASSERT(i == colors_cnt);
+    img.SetPalette(wxPalette(colors_cnt, r, g, b));
+    delete[] r;
+    delete[] g;
+    delete[] b;
+#endif // wxUSE_PALETTE
     return img;
 }