Solved

Converting 65536/256-color bitmap to 16 colors under Win16

Posted on 1997-04-30
2
1,025 Views
Last Modified: 2013-12-04
Under Win16, I have a 65536-color or 256-color bitmap
(of size 32x32 because it's an icon's XOR mask) and I
want to convert it to a 16-color bitmap (I need to write
a 16-color XOR mask into a .ICO file). I am using Visual
C++ 1.52c under Windows 95/3.1.

What is the algorithm in C/C++ to do this?
0
Comment
Question by:sarrazip
[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
2 Comments
 

Accepted Solution

by:
jnewlin earned 100 total points
ID: 1397051
It depends on if you know what colors are available in the
16-bit image.  If you do, it's pretty easy.  If you don't
then you have to figure out how to choose the colors, which
can be pretty complex.

Assuming you know the color table for the 16-bit bitmap,
you can do something pretty simple, since the amount of
data that you are working with is small, you can do a linear
lookup on each pixel.  It's slow on large data, but should
be ok with a 32x32 bitmap.

All you do, is for each pixel in the original bitmap, get
a COLORREF that is the color of that pixel, then call
GetNearestColor(hdcOfDestBitMap, colorRef).
Then use the value that that returns as your the value for
the pixel that you are writing.  Of course you'll have to
have an HDC into the bitmap that you are writing.
0
 

Author Comment

by:sarrazip
ID: 1397052
The original bitmap has 16-bit entries. I try to use
GetSystemPaletteEntries() to obtain a COLORREF
from a 16-bit entry, using the HDC returned by GetDC(),
but it fails.

Anyway, I have found a different method that involves
GetBitmapBits() and CreateBitmap() and no HDCs, assuming
that the goal is to produce a .ICO file.

Thanks.

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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