+
+#if wxUSE_PALETTE
+ if (color_type == PNG_COLOR_TYPE_PALETTE)
+ {
+ const size_t ncolors = info_ptr->num_palette;
+ unsigned char* r = new unsigned char[ncolors];
+ unsigned char* g = new unsigned char[ncolors];
+ unsigned char* b = new unsigned char[ncolors];
+
+ for (size_t j = 0; j < ncolors; j++)
+ {
+ r[j] = info_ptr->palette[j].red;
+ g[j] = info_ptr->palette[j].green;
+ b[j] = info_ptr->palette[j].blue;
+ }
+
+ image->SetPalette(wxPalette(ncolors, r, g, b));
+ delete[] r;
+ delete[] g;
+ delete[] b;
+ }
+#endif // wxUSE_PALETTE
+