Click here to Skip to main content
15,895,871 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Toolbar image list color depth Pin
pratapM19-Sep-06 1:31
pratapM19-Sep-06 1:31 
AnswerRe: Toolbar image list color depth Pin
tanvon malik19-Sep-06 1:32
tanvon malik19-Sep-06 1:32 
AnswerRe: Toolbar image list color depth Pin
pratapM19-Sep-06 1:33
pratapM19-Sep-06 1:33 
AnswerRe: Toolbar image list color depth Pin
tanvon malik19-Sep-06 2:01
tanvon malik19-Sep-06 2:01 
GeneralRe: Toolbar image list color depth Pin
Christopher Duncan19-Sep-06 4:26
Christopher Duncan19-Sep-06 4:26 
AnswerRe: Toolbar image list color depth Pin
Jörgen Sigvardsson19-Sep-06 2:07
Jörgen Sigvardsson19-Sep-06 2:07 
GeneralRe: Toolbar image list color depth Pin
Christopher Duncan19-Sep-06 4:29
Christopher Duncan19-Sep-06 4:29 
GeneralRe: Toolbar image list color depth Pin
Jörgen Sigvardsson19-Sep-06 5:11
Jörgen Sigvardsson19-Sep-06 5:11 
Christopher Duncan wrote:
I'm assuming I need to or in the ILC_MASK, but I'm not seeing clear doc on how to subsequently set the mask. Any insights would be appreciated.

There are basically two ways to create image lists. One is to use a mask (in some form), and the other is to specify a transparent color. The mask is either explicit (b&w bitmap), or implicit (embedded mask bitmap inside icon and/or alpha transparency). Either way, you will have to specify ILC_MASK.

The transparency color option is simple to use. AFAIK, you don't have to specify ILC_MASK (with MFC you can't I believe). Pixels with this transparent color will be omitted when you draw the image list, giving the transparency effect. When I use this technique, I use a color which is seldom used in the actual image - RGB(0xFF, 0xFF 0) for instance.

So, this is what I'd do if I were to build an image list out of a set of icons:
CImageList lst;
// Using 32 bit icons
lst.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 2);
// Using < 32 bit icons
lst.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 2);
lst.Add(hIcon1);
lst.Add(hIcon2);
With masking bitmaps:
lst.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 2);
lst.Add(&bmpImage, &bmpMask);
And with a transparent pixel and predefined bitmap I'd do this:
lst.Create(MAKEINTRESOURCE(IDB_MYBITMAP), 16, 2, RGB(0xFF, 0xFF, 0));


Of course, ILC_COLOR8 is perfectly valid should you have bitmaps which share the same palette. If your bitmaps have different palettes, the finished image list may look horrible should the bitmaps which you have added to it, have very different palettes.

My rules of thumb are:

  • ILC_COLOR24 for all image lists to which I intend to add different bitmaps and use a transparency color
  • ILC_COLOR32 for all image lists for which I intend to add 32 bit icons, just to preserve the alpha channel
  • ILC_COLORWhatever for static image lists - i.e., image lists which you feed ONE composite bitmap. Such a bitmap will have only one palette, and is therefore not subject to palette freakization. Smile | :)


Basically it boils down to if you want to build the image list at runtime or not. I increase the bit depth for runtime built image lists to guard against ugliness. I am conservative about the bit depth for compile time build image lists, as 24 bits or more for 8 bit images would just be waste of memory.


--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!

GeneralRe: Toolbar image list color depth Pin
Christopher Duncan19-Sep-06 11:24
Christopher Duncan19-Sep-06 11:24 
AnswerRe: Toolbar image list color depth Pin
KarstenK19-Sep-06 2:34
mveKarstenK19-Sep-06 2:34 
AnswerThanks, everyone! Pin
Christopher Duncan19-Sep-06 11:25
Christopher Duncan19-Sep-06 11:25 
QuestionHow to convert char* to char Pin
vc++_fragrance19-Sep-06 0:28
vc++_fragrance19-Sep-06 0:28 
AnswerRe: How to convert char* to char Pin
prasad_som19-Sep-06 0:37
prasad_som19-Sep-06 0:37 
GeneralRe: How to convert char* to char Pin
vc++_fragrance19-Sep-06 0:47
vc++_fragrance19-Sep-06 0:47 
QuestionRe: How to convert char* to char Pin
prasad_som19-Sep-06 1:05
prasad_som19-Sep-06 1:05 
AnswerRe: How to convert char* to char Pin
vc++_fragrance19-Sep-06 1:23
vc++_fragrance19-Sep-06 1:23 
GeneralRe: How to convert char* to char Pin
prasad_som19-Sep-06 2:14
prasad_som19-Sep-06 2:14 
GeneralRe: How to convert char* to char Pin
vc++_fragrance19-Sep-06 3:10
vc++_fragrance19-Sep-06 3:10 
GeneralRe: How to convert char* to char Pin
David Crow19-Sep-06 3:13
David Crow19-Sep-06 3:13 
GeneralRe: How to convert char* to char Pin
KarstenK19-Sep-06 2:32
mveKarstenK19-Sep-06 2:32 
AnswerRe: How to convert char* to char Pin
_AnsHUMAN_ 19-Sep-06 0:48
_AnsHUMAN_ 19-Sep-06 0:48 
QuestionValidation in property pages Pin
Mohammad A Gdeisat18-Sep-06 23:23
Mohammad A Gdeisat18-Sep-06 23:23 
AnswerRe: Validation in property pages Pin
prasad_som18-Sep-06 23:28
prasad_som18-Sep-06 23:28 
QuestionMFC (database) please help ! [modified] Pin
Bravoone_200618-Sep-06 23:05
Bravoone_200618-Sep-06 23:05 
AnswerRe: MFC (database) please help ! Pin
Christian Graus19-Sep-06 1:19
protectorChristian Graus19-Sep-06 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.