How to Reference Colors in a DIB Section by IndexLast reviewed: March 8, 1996Article ID: Q138256 |
The information in this article applies to:
SUMMARYWhen using the GDI with DIB sections (HBITMAPs returned by a call to CreateDIBSection()), you may need a way to reference the colors in the color table of the DIB section by index rather than by RGB value. This article shows you how.
MORE INFORMATIONTo reference a color table value by index, use the DIBINDEX macro defined in Mmsystem.h. It allows you to index the colors in the color table of a DIB section in a manner similar to the way PALETTEINDEX indexes a color in a logical palette. In other words, you can create COLORREFs that reference a DIB section's color table rather than the logical palette in the DC that the DIB section is selected into. Because DIBINDEX references values in a color table, it only works on DCs where you have a DIB section selected. The DIBINDEX macro accepts an index to a color table entry and returns a color table specifier consisting of a 32-bit COLORREF value that specifies the color associated with the given index. An application using a display context with a DIB section selected into it can pass this specifier, instead of an explicit red, green, blue (RGB) value, to GDI functions that expect a color. This allows the function to use the color at the specified color table index. LONG DIBINDEX( WORD wColorTableIndex // index to color table entry );Parameters wColorTableIndex - Specifies an index to the palette entry containing the color to be used for a graphics operation.Return Value The return value is a color table index specifier.Remarks DIBINDEX is defined as: #define DIBINDEX(n) MAKELONG((n),0x10FF)NOTE: DIBINDEX also works with 16-bit WinGBitmaps and WinGDCs.
|
Additional reference words: 3.10 3.50 4.00 Windows 95 COLORTABLE HBITMAP
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |