X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c284bc61bd0a8699342e311427b7b1806f443523..b404a8f3b072129c107c6d9a5e0f6f53cd34807b:/src/common/xpmdecod.cpp diff --git a/src/common/xpmdecod.cpp b/src/common/xpmdecod.cpp index a752ead86f..744a5db1e8 100644 --- a/src/common/xpmdecod.cpp +++ b/src/common/xpmdecod.cpp @@ -108,6 +108,7 @@ license is as follows: #include "wx/hashmap.h" #include "wx/stream.h" #include "wx/image.h" + #include "wx/palette.h" #endif #include @@ -121,8 +122,6 @@ bool wxXPMDecoder::CanRead(wxInputStream& stream) if ( !stream.Read(buf, WXSIZEOF(buf)) ) return false; - stream.SeekI(-(wxFileOffset)WXSIZEOF(buf), wxFromCurrent); - return memcmp(buf, "/* XPM */", WXSIZEOF(buf)) == 0; } @@ -619,7 +618,7 @@ static bool GetRGBFromName(const char *inname, bool *isNone, static const char *ParseColor(const char *data) { - static const char *targets[] = + static const char *const targets[] = {"c ", "g ", "g4 ", "m ", "b ", "s ", NULL}; const char *p, *r; @@ -809,7 +808,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; }