Page 1 of 1

Runtime errors with PNG, GIF, XPM bitmaps

Posted: Mon Jun 10, 2013 5:25 am
by smitchell
First, thanks for developing a great IDE & wxCrafter!
I'm using 5.1 with wxCrafter 1.1 (registered), on Win7-x64 machine, (codelite-5.1.0-mingw4.7.1-wx2.9.4.exe bundle).

Currently I am experiencing a problem with images associated with wxToolbook pages (and probably other places too).
If I add XPM, GIF, or PNG 16x16 image files to the wxToolbook page toolbar (through "Control Specific Settings"),
they look fine in preview and the code generation completes OK, and the program compiles OK.

When I run the program I get an assert from wxWidgets:
../../src/msw/dib.cpp(140): assert "hbmp" failed in Create():
wxDIB::Create(): invalid bitmap

Pressing Cancel, then leads to another error message box:
"Couldn't add an image to the image list.
Details >>
> Unknown image data format
> XRC error: cannot create bitmap from "gui_dbgentech_bitmaps.cpp$....image_file.gif
> Couldn't add an image to the image list."

If I use 16x16 BMP image files, then I don't see the errors and the graphics display correctly.

Is there something in my configuration that might cause this?

Thanks,
-Stan

Re: Runtime errors with PNG, GIF, XPM bitmaps

Posted: Mon Jun 10, 2013 8:07 am
by eranif
It seems like you did not add the proper image handler

If you use PNG or any other format, you should make sure you add the proper handlers to wxImage
In your wxApp derived class, add these lines in the OnInit() function:

Code: Select all

// Add the common image handlers
wxImage::AddHandler( new wxPNGHandler );
wxImage::AddHandler( new wxJPEGHandler );
wxImage::AddHandler( new wxGIFHandler );
Eran

Re: Runtime errors with PNG, GIF, XPM bitmaps

Posted: Mon Jun 10, 2013 10:02 am
by smitchell
Thanks, that was it.
I used wxInitAllImageHandlers() from OnInit() to get all image types the library supports.
-Stan