Solved

Icon pixels

Posted on 1997-02-28
11
456 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
Comment Utility
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
Comment Utility
Edited text of question
0
 

Author Comment

by:lgrove
Comment Utility

0
 
LVL 1

Expert Comment

by:mrosen
Comment Utility
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
Comment Utility
The answer from mrosen is what I stated as intuitive.  My question is why is it acting the opposite in the list view?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Expert Comment

by:MFCGuy
Comment Utility
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
Comment Utility
Colormask? Please explain.  I'm just editing the icon with the icon editor.  Where do I manipulate the colormask?
0
 

Author Comment

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

Expert Comment

by:JohnWeidner
Comment Utility
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
Comment Utility
No. It does not work this way
0
 
LVL 1

Accepted Solution

by:
MFCGuy earned 150 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now