Using bitmaps with wxWidgets

This entry begins a new series to catalogue knowledge I obtain while working with the wxWidgets C++ Framework. I’ll be posting my thoughts on TrollTech QT versus wxWindows frameworks shortly. Both are fantastic, but I went with wxWindows for reasons I’ll describe in a different article. For now…Bitmaps.

When working with my purchase of DialogBlocks (a GUI dialog/frame builder for wxWindows), I was having problem working with the following code:

wxBitmap item5Bitmap(_T(“image_bin/tw_logo.png”), wxBITMAP_TYPE_PNG); wxStaticBitmap* item5 = new wxStaticBitmap( item1, twID_ABOUTLOGO, item5Bitmap, wxDefaultPosition, wxSize(32, 32), 0 ); item4->Add(item5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); I kept getting an error “No Image Handler for type 15” every time I loaded the About Dialog box I was working with. Being the novice that I am, I did not realize that the image handlers needed to be loaded prior to working with the bitmaps. So, I added wxInitAllImageHandlers() in the code before it. After that, I got all kinds of “unresolved external symbol” errors. Which meant that I wasn’t linking against the right libraries. After several attempts I realized that I needed to add the following libararies to my linker’s “additional dependencies”: pngd.lib, jpegd.lib, tiffd.lib, zlibd.lib. Once that was done, I was able to load the PNG image I needed correctly. So to reiterate, here are the steps for loading a bitmap (to be expanded later…):

  1. Add #include to your header file
  2. Add wxInitAllImageHandlers() or a variant such as wxImage::AddHandler(wxPNGHandler)
  3. Make sure the appropriate libraries are listed in your linker’s “dependencies” area

Of course, this is highly simplified, but suffices to remind me of where I made my mistake.

WordPress database error: [Table './austintech_wp/wp_comments' is marked as crashed and last (automatic?) repair failed]
SELECT * FROM wp_comments WHERE comment_post_ID = '12' AND comment_approved = '1' ORDER BY comment_date

Leave a Comment