L_GetBitmapColors

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_GetBitmapColors(pBitmap, nIndex, nCount, pPalette)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT nIndex;

/* index to the first color to get */

L_INT nCount;

/* number of colors to get */

LPRGBQUAD pPalette;

/* array values that make up your palette */

Loads your palette with selected colors from a bitmap handle's palette.

Parameter

Description

pBitmap

Pointer to the bitmap handle.

nIndex

The index to the first color to get.

nCount

The number of colors to get.

pPalette

The array of RGBQUAD values that make up your palette.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Your palette can be smaller than the bitmap's palette, as long as it is big enough to hold the selected colors. For the reverse action, refer to L_PutBitmapColors.

Required DLLs and Libraries

LTKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_GetFixedPalette, L_ColorResBitmap, L_CreatePaintPalette, L_PutBitmapColors, L_DupPalette

Topics:

Raster Image Functions: Displaying Images

 

Handling Palette Changes

 

Color Halftone and Halftone Images

Example

/* This example darkens the first 50 colors in a bitmap’s palette. */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the current image */
void TestFunction(HWND hWnd)
{
   RGBQUAD pPalette[50]; /* Temporary palette */
   int i; /* Loop counter */
   /* Convert the current 24-bit bitmap to 8 bits per pixel with an optimized palette */
   L_ColorResBitmap(&LeadBitmap, &LeadBitmap, sizeof(BITMAPHANDLE), 8,
                 CRF_FLOYDSTEINDITHERING|CRF_OPTIMIZEDPALETTE, 
                 NULL, NULL, 0, NULL, NULL );
   /* Get the first 50 colors from the bitmap's palette */
   L_GetBitmapColors(&LeadBitmap, 0, 50, pPalette);
   /* Reduce the intensity of each color component by half */
   for (i=0; i < 50; i++)
   {
       pPalette[i].rgbBlue = (BYTE) (pPalette[i].rgbBlue / 2);
       pPalette[i].rgbGreen = (BYTE) (pPalette[i].rgbGreen / 2);
       pPalette[i].rgbRed = (BYTE) (pPalette[i].rgbRed / 2);
   }
   /* Update the bitmap's palette with the changed colors */
   L_PutBitmapColors(&LeadBitmap, 0, 50, pPalette);
   /* Update the paint palette */
   SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);
   return;
}