Sign in to follow this  

How do I load images with wxImage?

This topic is 4340 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
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

This topic is 4340 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this