Jump to content
  • Advertisement
Sign in to follow this  
DarkCybo1

How do I load images with wxImage?

This topic is 4644 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I do something like:
wxImage img;
img.LoadFile("thisfile.jpg", wxBITMAP_TYPE_JPEG);

wxBitmap bm(img);

I get a "no handler found for image type" error though. It works fine when I load a .bmp using wxBitmap though. Help?

Share this post


Link to post
Share on other sites
Advertisement
wxWindows has image handlers, that handle the loading of various image file formats. I don't recall the method name off-hand (I'm sure you can find it quickly in the documentation), but there is a method you can call that will initialize all known image handlers. Just call that function once in the beginning of your app, and you should be good to go.

Share this post


Link to post
Share on other sites
Adding an image handler is very easy. Here is an example to get you started:

wxImageHandler * jpegLoader = new wxJPEGHandler();
wxImage::AddHandler(jpegLoader);

wxBitmap bitmap;
bitmap.LoadFile("thisfile.jpg", wxBITMAP_TYPE_JPEG);


Note that some file formats have handlers that do not support saving of images (eg. GIF).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!