Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / How to include ICONS and BITMAPS in your application

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. How to include ICONS and BITMAPS in your application
#2812
Posted by: dejudicibus 2003-10-30 20:16:22
I have few icons and bitmaps that I need to include in my executable so that I have not to package them with program. My understanding is that the portable way is XRC. Is there a simple sample of XRC just for such resourcesw (no dialogs or menus, just icons and bitmaps).

TIA

DdJ
Message2. Re: How to include ICONS and BITMAPS in your application
#2815
Posted by: upCASE 2003-10-31 02:17:18
XRC is a resource system that is designed for things like loading dialogs at runtime and storing layouts, not only saving icons and stuff. An XRC file is a seperate XML file storing the layout that can be loaded at runtime. It doesn't store the images in it, they stay seperate. XRS files can store images and other resources, but they're more like zip files...
XRC should be protable, but I confess I never used it. It's still not a "real" part of wxWindows and stays in the contrib.

You could convert your images to the xpm format, include them in your source and use the correct ctor to get a bitmap or icon.
Like:
#include "myicon.xpm"
...
wxIcon* myIcon = new wxIcon(myicon);
   or
wxIcon* myIcon = new wxIcon(myicon, wxBITMAP_TYPE_XPM );

Since XPM is a plaintext format you can use it on every platform. It's even easier to use when you need masked region. Then you don't have to use wxMask...

BTW: For a simple example of XRC, check the contrib dir...

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: How to include ICONS and BITMAPS in your application
#2828
Posted by: 2003-11-02 04:00:27
Thank you. I think I could use XPM. But how can I convert a bitmap or GIF to XPM? Does XMP support transparency?
Message4. Re: How to include ICONS and BITMAPS in your application
#2836
Posted by: upCASE 2003-11-02 21:03:31
Hi!
Yes, it does. Simply open it up in a text editor and set all color codes you want to be transparent to color "none".
For bitmaps there's a tool called "bmp2xpm". Search the wxWindows site.
I think Gimp and maybe a prog like Corel can handle XPM.

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message5. Re: How to include ICONS and BITMAPS in your application
#2840
Posted by: 2003-11-02 23:14:30
OK, I found a way. I can use PaintShop Pro to export any image I like to a XPM file. Then I have to edit file and change the color I wish as transparent to None (PSP does not support that yet). At last, I have to change structure name, since PSP always use Pixmate.

Thank you, upcase.

DdJ

Message6. Re: How to include ICONS and BITMAPS in your application
#2844
Posted by: upCASE 2003-11-03 04:47:50
Hi!

Your welcome!

Oh yes, I forgot to tell you about the array name.... Glad you found it yourself, because I spend about an hour on that when first trying it :)

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥490.00 ·
 
 
¥1,280.00 ·
 
 
¥470.00 ·
 
 
¥307.00 ·
 
 
¥1,280.00 ·
 
 
¥1,480.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0