# include "wx/defs.h"
#endif
-#if wxUSE_IMAGE && wxUSE_XPM
+#if wxUSE_XPM
#include "wx/imagxpm.h"
#include "wx/wfstream.h"
bool wxXPMHandler::LoadFile(wxImage *image,
wxInputStream& stream,
- bool verbose, int WXUNUSED(index))
+ bool WXUNUSED(verbose), int WXUNUSED(index))
{
wxXPMDecoder decoder;
// 2. write the header:
char tmpbuf[200];
- // VS: 200b is safe upper bound for anything produced by sprintf bellow
+ // VS: 200b is safe upper bound for anything produced by sprintf below
// (101 bytes the string, neither %i can expand into more than 10 chars)
sprintf(tmpbuf,
"/* XPM */\n"
// 3. create color symbols table:
wxHashTable table(wxKEY_INTEGER);
+ table.DeleteContents(TRUE);
image->ComputeHistogram(table);
char *symbols_data = new char[cols * (chars_per_pixel+1)];
tmp = wxT("};\n");
stream.Write(tmp.mb_str(), 3);
+ // Clean up:
delete[] symbols;
delete[] symbols_data;
+ // FIXME: it will be better to use macros-based wxHashTable & DeleteContents(TRUE)
+ table.BeginFind();
+ while ((node = table.Next()) != NULL)
+ {
+ delete (wxHNode *) node->GetData();
+ }
+
return TRUE;
}
#endif // wxUSE_STREAMS
-#endif // wxUSE_XPM && wxUSE_IMAGE
+#endif // wxUSE_XPM