Solved

Icon pixels

Posted on 1997-02-28
11
476 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dog bark java program 15 94
Execute multiple curl cmds with sleep and send output to file 10 97
noX challenge 17 112
Problem to App source 6 33
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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