I'm really getting annoyed with this problem. I'm using Visual C++ 2005 Express. Every time I try to load an icon or bitmap from a file, it won't allow it. It keeps telling me to check my resources. It seems as if it will only accept embedded media without allowing the loading of my media from the hard drive. I really don't want to have to add all of my content to my resources, and I can't even get that to work with a simple png file anyway.
Does anyone have any ideas on what I need to change so that I will be able to load image files?
Visual C++ 2005 won't load images from file Topic is solved
-
- Earned some good credits
- Posts: 102
- Joined: Thu Dec 28, 2006 5:12 pm
- Location: Indiana, US
-
- Earned some good credits
- Posts: 102
- Joined: Thu Dec 28, 2006 5:12 pm
- Location: Indiana, US
In my frame constructor, I have this:
wxString dir = wxGetCwd() + "\\exit.png";
wxBitmap quit(dir);
I also tried:
wxBitmap quit;
quit.LoadFile(dir);
Neither one worked.
I've tried using wxImage, which seems to allow me to load a file, but it keeps saying "No handler found for image type" no matter what type I use.
wxString dir = wxGetCwd() + "\\exit.png";
wxBitmap quit(dir);
I also tried:
wxBitmap quit;
quit.LoadFile(dir);
Neither one worked.
I've tried using wxImage, which seems to allow me to load a file, but it keeps saying "No handler found for image type" no matter what type I use.
For the image handler issue, did you initialize the image handler for the type you want to use?
you could stick this:
into your wxApp::OnInit() function if you didn't.
you could stick this:
Code: Select all
::wxInitAllImageHandlers();
-
- Earned some good credits
- Posts: 102
- Joined: Thu Dec 28, 2006 5:12 pm
- Location: Indiana, US
Thank you. I didn't know to do that. I'm just starting to learn this and I'm going through the intermediate tutorial on making a toolbar. When I type the code how they have it, it doesn't work.
So I initialized all image handlers. Then I had to load the file into a wxImage and send that to a wxBitmap to use in the toolbar.
Thank you. I've found that the intermediate tutorials are more confusing than they need to be and they don't tell you everything you need to know. I wish there were a more complete tutorial somewhere that is easy to follow.
So I initialized all image handlers. Then I had to load the file into a wxImage and send that to a wxBitmap to use in the toolbar.
Thank you. I've found that the intermediate tutorials are more confusing than they need to be and they don't tell you everything you need to know. I wish there were a more complete tutorial somewhere that is easy to follow.
-
- Earned some good credits
- Posts: 102
- Joined: Thu Dec 28, 2006 5:12 pm
- Location: Indiana, US
Well, I have another problem after I already marked it solved.
I can get the image into the toolbar even without converting it to a wxBitmap. But the image isn't shrunk to fit the toolbar. It only shows the upper right corner of the image. Do you know how to get it to be sized to the toolbar? It seems like that if I resize my image to fit my toolbar, it may not be right on another platform.
I can get the image into the toolbar even without converting it to a wxBitmap. But the image isn't shrunk to fit the toolbar. It only shows the upper right corner of the image. Do you know how to get it to be sized to the toolbar? It seems like that if I resize my image to fit my toolbar, it may not be right on another platform.
I have not used Toolbars, but I would think that you need to resize the image to the correct dimensions. If you are worried about resizing to the right size, call GetToolBitmapSize() on the toolbar and resize to the size it gives you.
The wxImage size can be changed with image.Rescale(width, height)
The wxImage size can be changed with image.Rescale(width, height)
-
- Earned some good credits
- Posts: 102
- Joined: Thu Dec 28, 2006 5:12 pm
- Location: Indiana, US