Re: Transform a bitmap depth
- From: "Severian [MVP]" <severian@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 02 May 2005 05:26:05 GMT
On Mon, 2 May 2005 11:02:46 +0900, "William" <port@xxxxxxxxxxxxxxxxxx>
wrote:
>William
>
>> If the image you obtain is 15-32 bit, you do not need to create a
>> palette unless you have a need to display it on a 256-color system.
>> But if you require an 8-bit indexed-color DIB from a higher-depth
>> image, you will have to create it yourself, using any of many known
>> quantization methods (median cut, popularity, fixed distribution,
>> grayscale, Windows standard etc) and dithering methods
>> (Floyd-Steinberg, Stucki, Burkes, etc.). Google and
>> sci.image.processing will be your friends for these.
>> But if the clipboard image is already 8-bpp DDB, there should also be
>> a palette available that you can use directly. (Availability of an
>> 8-bit CF_BITMAP should imply the simultaneous availability of a
>> CF_PALETTE).
>My application need to load, display, save, and deal with 8bit bitmap only,
>no matter what Windows video settings is. Also, if an user copies a bitmap
>from other applications, for example, MSPaint.exe, my application have to
>transform it into 8bit bitmap format before displaying and/or save it.
>
>I know that transforming DDB(clipboard)->DIB(8bit)->DDB(8bit) is one of the
>methods. However, I want to know the normal method to transform it. You said
>that creating an optimized palette is a way. But I still don't know where to
>start? Could you show me a sample source. That will be helpful.
My own color quantization (picking the colors for the 8-bit indexed
image) and dithering routines are dependent on too much other code to
tweeze out easily.
For a simple conversion to the Windows halftone palette, you could use
CreateHalftonePalette() to obtain 256 generally useful colors, which
you will have to transfer to the bmiColors[] array for your 8-bit DIB
before, then convert the clipboard DIB to your DIB. However, the
quality is going to vary significantly depending on the source bitmap.
Another option would be to always generate grayscale DIBs, simply by
averaging each pixels red, green and blue values.
If you need higher quality results, news://sci.image.processing can
probably recommend some simple and cheap libraries for doing this, and
GDI+ probably also has the ability.
--
Phillip Crews aka Severian
Microsoft MVP, Windows SDK
Posting email address is real, but please post replies on the newsgroup.
.
- Follow-Ups:
- Re: Transform a bitmap depth
- From: Michael K. O'Neill
- Re: Transform a bitmap depth
- References:
- Transform a bitmap depth
- From: William
- Re: Transform a bitmap depth
- From: Severian [MVP]
- Re: Transform a bitmap depth
- From: William
- Re: Transform a bitmap depth
- From: Severian [MVP]
- Re: Transform a bitmap depth
- From: William
- Transform a bitmap depth
- Prev by Date: Re: Transform a bitmap depth
- Next by Date: Re: GDI+ FAQ: Where?
- Previous by thread: Re: Transform a bitmap depth
- Next by thread: Re: Transform a bitmap depth
- Index(es):
Relevant Pages
|