Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Showing bitmaps or Icons
Re: Showing bitmaps or Icons [message #2550 is a reply to message #2502] |
Mon, 17 April 2006 18:52  |
 |
mirek
Messages: 14257 Registered: November 2005
|
Ultimate Member |
|
|
Quote: |
gp1 is the name of a bitmap in an .iml file, just like Smiley() in the reference/iml example. What does img1 = gp1() do - does img1 store a copy of the bitmap?
|
Think about Image as of any other "value" type like "int", "Date" or "String". Copies are full and cheap (internally there is reference counting mechanism, but that is nothing you should bother you).
Now "Smiley()" is the Image you have designed and stored in .iml - it is Image constant. In fact, in ideal world, its definition would be (in header)
extern Image Smiley;
However, there are two problems with this:
- first, certain platforms (namely Win32) do not support global variables in .dll (not that we are using .dlls all that often, but it is better to be ready).
- second, global variables in C++ has unpleasant problem of "initialization" order. In practice, in constructor of global variable you are never sure which other global variables are already constructed (unless they are in the same .cpp file).
Therefore, instead of global variable, we are (quite often) using "functional constants". E.g.
const Image& Smiley();
This solves both problems.
Mirek
|
|
|
Goto Forum:
Current Time: Fri May 09 22:02:29 CEST 2025
Total time taken to generate the page: 0.02925 seconds
|