Solved

Icon pixels

Posted on 1997-02-28
11
495 Views
Last Modified: 2013-11-19
When drawing icons with the graphic icon editor, you can designate some pixels as "transparent" or "opaque" by selecting one of the two monitors at the middle top portion of the color palette.  The pixels are then drawn red (opaque) or dark cyan (transparent).  But when the icons are displayed (in list view or explorer window), the meaning of "transparent" and "opaque" are not intuitive.  Example: in a list view, transparent pixels are black and opaque pixels are white (opposite of what I expected).

Can you clarify this topic?
0
Comment
Question by:lgrove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 

Expert Comment

by:rsantossio
ID: 1300190
I'm not sure of what you're asking... the "transparent-ness" of a displayed icon is always that; transparent.  To set transparency, in a ListCtrl/TreeCtrl, use the mask to designate the color you want to be transparent.  You can pass it a COLORREF or a CBitmap.  If you send a CBitmap, it will take whatever color is at pixel 0,0, and make that the transparent.

I'm still not sure what you were originally asking, but that's what I know about them... I was just working on them this morning.

Randy

0
 

Author Comment

by:lgrove
ID: 1300191
Edited text of question
0
 

Author Comment

by:lgrove
ID: 1300192

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:mrosen
ID: 1300193
Actually, there is transparent, and then inverse. The greenish blue is transparent and will show up white on a while background (such as in a list view with the default win95 colors). The pinkish-red one will invert the background color. Therefore, on the while list view background, the color looks black.
0
 

Author Comment

by:lgrove
ID: 1300194
The answer from mrosen is what I stated as intuitive.  My question is why is it acting the opposite in the list view?
0
 
LVL 1

Expert Comment

by:MFCGuy
ID: 1300195
I don't understand the actions you are seeing.

Please explain further.

My listview works as expected.  Perhaps you are setting the
colormask wrong?

Regards,
MFCGuy
0
 

Author Comment

by:lgrove
ID: 1300196
Colormask? Please explain.  I'm just editing the icon with the icon editor.  Where do I manipulate the colormask?
0
 

Author Comment

by:lgrove
ID: 1300197
Colormask? Please explain.  I'm just editing the icon with the icon editor.  Where do I manipulate the colormask?
0
 

Expert Comment

by:JohnWeidner
ID: 1300198
I believe the transparent/opaque commands in the icon editor only effect how cut and paste operations will occur while you are editing the bitmap.  I didn't think they would control how the bitmap was displayed.
0
 

Author Comment

by:lgrove
ID: 1300199
No. It does not work this way
0
 
LVL 1

Accepted Solution

by:
MFCGuy earned 150 total points
ID: 1300200
When you say "list view", are you referring to a CListView control you have in a program or just the "list view" in Explorer?

I created an icon as you described and the transparent pixels ("special" dark cyan in icon editor) were white on a white background.  The opaque pixels ("special" light red in icon editor) were black on my white background.  This was in Windows NT 4.0 Explorer.

If you are using a CListCtrl, I recommend using the following code for icon usage where I have a single bitmap that has all the images I need for a given CListCtrl.  Everything I want to make transparent is painted red (like the background):
.h
--
CImageList m_TheImageList;

.cpp
----
in c'tor
--------
//Initialize image list
m_TheImageList.Create(IDB_MY_BITMAP, 16, 12, RGB(255,0,0));
//The RGB(255,0,0) is what I referred to in my earlier
//comment as the "mask".

In OnInitDialog() or OnInitialUpdate of MDI/SDI child
-----------------------------------------------------
m_ListCtrl.SetImageList(&m_TheImageList,LVSIL_SMALL);

I then just insert the CListCtrl items normally, specifying the index into the image list that I want for each row, usually with a switch statement to do the image index logic for the insert.

Of course, you can individually add icons to the image list using CImageList::Add() but it's a pain compared to having one single image list as a bitmap in your resources.

If you want more information on how the system uses the transparent and opaque icon pixels, search on CreateIcon in VC++.

Here's an excerpt:
To create the icon, CreateIcon applies the following truth table to the AND and XOR bitmasks.
AND bitmask      XOR bitmask      Display
0      0      Black
0      1      White
1      0      Screen             (Transparent)
1      1      Reverse screen     (Opaque)

Regards,
MFCGuy
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question