| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 | 1. png files and toolbar #4742 Posted by: 2004-07-07 15:47:37 | Hi,
i would like to create a toolbar and use png files instead of bitmaps.
I create the GUI with wxGlade and i can compile the code. But the png files are not included in the .exe and therefore i see this prompt: "Can't load image from file...."
What can i do? Can i create xpm files with transparent background?
Thanks a lot... | 2. Re: png files and toolbar #4744 Posted by: upCASE 2004-07-07 16:12:47 | Hi! Yes, XPM files can have a transparent background. In fact XPM files are just plain text files that define a static char* array with the image data. Open it with your favorite texteditor and change the "sign" that corresponds to the transparent colour to "none".
Example (up.xpm from wxWidgets itself): static char * up_xpm[] = { "16 16 5 1", " c None", ". c #000000", "+ c #C0E4CB", "@ c #808080", "# c #77C490", " ", " . ", " .+.@ ", " .+++.@ ", " .++##+.@ ", " .++####+.@ ", " ....+##....@ ", " .+##.@@@@@ ", " .+##.@ ", " .+##.@ ", " .+##.@ ", " .+##.@ ", " .+##.@ ", " .....@ ", " ", " "};
All spaces will be transparent.
upCASE ----------------------------------- If it was hard to write, it should be hard to read!- Do. Or do not. There is no try! | 3. Re: png files and toolbar #4745 Posted by: upCASE 2004-07-07 16:16:27 | Hi! I forgot: I think with PNG it should work if you load them as a wxImage in use wxImage::ConvertToBitmap() on them. Be sure to init the PNG handler first.
upCASE ----------------------------------- If it was hard to write, it should be hard to read!- Do. Or do not. There is no try! | 4. Re: png files and toolbar #4748 Posted by: 2004-07-07 20:25:02 | Hi...
first of all..thanks...
If learned much about the xpm file format...but when i try to use a xpm file with MSW, i got the the message "undefined symbol 'cut_xpm'..."
I have included the file with this lines in the header...
#define USE_XPM_BITMAPS 1
#define wxUSE_XPM_IN_MSW 1
#if USE_XPM_BITMAPS && defined(__WXMSW__) && !wxUSE_XPM_IN_MSW
#error You need to enable XPM support to use XPM bitmaps with toolbar!
#endif
#include "icons/cut.xpm"
and within the cpp file
wxBitmap * toolBarBitmaps[1];
toolBarBitmaps[0] = new wxBitmap( cut_xpm );
I hope this is enough example code...
I would prefer the solution with the xpm files....but if this not work: How can i include the png file? Is the png file compiled into the executable, if i load it with wxImage?
Thanks... funlovin | 5. Re: png files and toolbar #4754 Posted by: upCASE 2004-07-08 02:12:53 | Hi! Open cut.xpm and see if the array is really named cut_xpm. I saw that once with some editor who append something to it (like cut_xpm_???).
"How can i include the png file? Is the png file compiled into the executable, if i load it with wxImage?" You can only load the PNG file. Technically it's possible to include the file as a windows resource in the rc file. It is possible to load this custom resource from wxWidgets using ::wxLoadUserResource() (only on Windows, thus breaking protability), but the problem is how to construct an image from the data you get. I tried some ways, but none worked...
For portability use the XPM solution. It's available on all platforms, so this is the way to go...upCASE ----------------------------------- If it was hard to write, it should be hard to read!- Do. Or do not. There is no try! | 6. Re: png files and toolbar #4766 Posted by: 2004-07-08 18:28:42 | Thanks again...
Thats it...now the XPM solution works fine....
Greetings..
| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
|
|