Compiling images statically Topic is solved

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
selles
Earned a small fee
Earned a small fee
Posts: 21
Joined: Thu Dec 29, 2005 3:20 am

Compiling images statically

Post by selles »

Hi all,

I would like to know if there is a method to compile images within a program..
like this, it won't be necessary a .bmp file for example..

Thanks,

Selles
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

use resource files if you are under Windows. Cpp's wxMSWResources on wxCode should help you retrieve that resource.

Joel
selles
Earned a small fee
Earned a small fee
Posts: 21
Joined: Thu Dec 29, 2005 3:20 am

Post by selles »

Thank you for the explanation Joel :D
metalogic
Super wx Problem Solver
Super wx Problem Solver
Posts: 307
Joined: Fri Oct 08, 2004 8:21 am
Location: Area 51
Contact:

Post by metalogic »

For a cross platform solution, you can look at XPM images. Those are compiled right into your C++ program under all platforms.
Vexator
I live to help wx-kind
I live to help wx-kind
Posts: 187
Joined: Sun Jan 30, 2005 2:50 pm
Location: Heidelberg, Germany

Post by Vexator »

is there a cross-platform solution for other file formats like png? (for alpha map support)
Windows 7 Pro
Visual Studio 2010
wxWidgets 2.9.3
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

Otherwise, convert to a char* array (and include it into your header file, there's a utility, bin2c that does it), then use wxMemoryInputStream + wxImage (use the wxInputStream ctor) to get the iamge loaded
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Hi!
I guess lowjoel refers to this solution:
http://forums.wxwidgets.org/viewtopic.php?t=214
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
selles
Earned a small fee
Earned a small fee
Posts: 21
Joined: Thu Dec 29, 2005 3:20 am

Post by selles »

Thank you peoples,

I'm very happy for the help!!! :D :D :D !!!


Selles
User avatar
tierra
Site Admin
Site Admin
Posts: 1355
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Post by tierra »

Vexator wrote:is there a cross-platform solution for other file formats like png? (for alpha map support)
Yes, it works pretty close to the same as XPMs:
http://wxwiki.org/Embedding_PNG_Images
metalogic
Super wx Problem Solver
Super wx Problem Solver
Posts: 307
Joined: Fri Oct 08, 2004 8:21 am
Location: Area 51
Contact:

Post by metalogic »

selles wrote:Thank you peoples,

I'm very happy for the help!!! :D :D :D !!!


Selles
Selles,
You have selected your thank you note as the assisting answer :D
Please assign the accepted answer/assisting answer to one or more of the messages above which you found helpful.
helgihg
Earned a small fee
Earned a small fee
Posts: 20
Joined: Tue Jun 06, 2006 11:49 pm

Re: Compiling images statically

Post by helgihg »

selles wrote:Hi all,

I would like to know if there is a method to compile images within a program..
like this, it won't be necessary a .bmp file for example..

Thanks,

Selles
You can find an example of compiling XPM images directly into the binary itself and use it with wxWidgets in my file manager, Jaffm. It's at http://jaffm.binary.is. I can't remember where I got the code myself, but I probably looked it up in the image sample that comes with wxWidgets although I frankly can't remember. :)

Seems like you already found the answer, but I figured it wouldn't hurt to have an extra source.

Edit: It's GPL, but you hereby have my "written" permission to use the image code with whatever license you choose, in case someone realizes that I'm actually encouraging you to use GPL code without knowing what license you plan on using. I'm planning on switching to LGPL or BSD anyway. Regardless, you hereby have my permission.
"Here, then, is the problem which we present to you, stark and dreadful and inescapable: Shall we put an end to the human race; or shall mankind renounce war?" -The Russell-Einstein Manifesto, 1955
selles
Earned a small fee
Earned a small fee
Posts: 21
Joined: Thu Dec 29, 2005 3:20 am

uau!

Post by selles »

Very well!!!:D

I got a great learning here :!: :!: :!:

Thanks for all :D :D :D
Post Reply