Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
mirek is currently offline  mirek
Messages: 13980
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Image with Layout (iml) painted red, why?
Next Topic: When I added "Draw" package to my project (605dev1), I get "plugin\z" added...
Goto Forum:
  


Current Time: Fri May 17 17:02:17 CEST 2024

Total time taken to generate the page: 0.02753 seconds