Solved

How can I display more than 16 colors in my icons?

Posted on 2001-07-31
8
224 Views
Last Modified: 2013-11-20
I have an MFC ActiveX control, that I display from a web page. I want to use more than the standard 16 colors for some of the icons, but it never renders properly.

Does anyone know how to increase the palette size?
0
Comment
Question by:postrowski
[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
8 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6338376
See the article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_icons.asp ('Icons in Win32') - maybe this is of some help.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6338456
The problem is that by default, VC++ creates 16-color icons.  It is easy to fix:

1) In the Resource Editor, create a new icon.  
2) From the Image menu, Chhose "New Device Image"
3) Choose 32x32 256 colors (or choose Custom... and make the icon any size you want.
4) Paste a 256-color picture into the icon (I just copy a chunk from a Paint bitmap)

5) Delete the 16-color icon so that there is only one icon for the system to choose when you call LoadIcon, etc.

-- Dan



0
 

Author Comment

by:postrowski
ID: 6338578
OK, I did what Dan suggested, and that lets me create 256 color icons fine, but when the control is displayed in the web page, it still shows only the primary 16 colors. I think that somehow I need to realize the new larger palette.
0
Technology Partners: 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 49

Expert Comment

by:DanRollins
ID: 6341083
Show the code that you use to render the icon.  I suggest using LoadImage(...,IMAGE_ICON,...) rather than LoadIcon.

-- Dan
0
 

Author Comment

by:postrowski
ID: 6342378
I was using LoadIcon:

   m_pImageList = new CImageList();
   m_pImageList->Create(16, 16, ILC_MASK, 10, 0);
   m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_DB_ICON1));
   m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_DB_ICON2));
   ...
   m_ctlTree.SetImageList(m_pImageList, TVSIL_NORMAL);

In this case, I'm loading the icons into a CTreeCtrl.

I also tried using LoadImage:
   m_pImageList->Add((HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DB_ICON1), IMAGE_ICON,0,0,LR_DEFAULTSIZE));

but I have the same problem.

I also have the same problem with the colors that render in my toolbar. For the toolbar, I'm using a 256 color bitmap, but it seems to be rendering as a 16 bit bitmap. I think if I can figure out how to get the toolbar to render properly as a 256 color bitmap, then the palette would be large enough to display my icons correctly in the CTreeCtrl.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 6347315
>> ... ::LoadImage( ... LR_DEFAULTSIZE));

Do you really want default-sized icons (32x32) in your tree?

I suggest forgetting about icons.  Use the Bitmap editor to make your bitmaps.  Press Alt+Enter to change the properties and set it to 256 colors.  Then paste the images from somewhere else.

For the toolbar, create it as a Toolbar resource in VC++ (it will create a 16-color bmp named Toolbar1.bmp).  Now use a bitmap editor to modify the images.  Save it as a 256-color bitmap.  Just avoid editting it in the IDE because it may save it back out as a 16-color bmp.

-- Dan
0
 

Assisted Solution

by:bcox24
bcox24 earned 100 total points
ID: 6350180

Currently you create the image list by calling:
   m_pImageList->Create(16, 16, ILC_MASK, 10, 0);

Instead of ILC_MASK, try using ILC_COLOR8 or higher.  

-Bryan

0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9521083
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: bcox24, DanRollins (points to be split)

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best tools for Backup and restore of Wordpress site 6 58
Prevent this page from creating additional dialogs. 3 767
Sed question 2 139
Problem to App source 6 116
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

739 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