Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_GetBitmapColors
#include "l_bitmap.h"
L_LTKRN_API L_INT 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 */ |
L_RGBQUAD* 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
This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.
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 2000 / XP/Vista, Windows CE.
See Also
Functions: |
L_GetFixedPalette, L_ColorResBitmap, L_CreatePaintPalette, L_PutBitmapColors, L_DupPalette |
Topics: |
|
|
|
|
Example
This example darkens the first 50 colors in a bitmap's palette.
L_INT GetBitmapColorsExample(HWND hWnd,pBITMAPHANDLE pBitmap) { L_INT nRet; RGBQUAD pPalette[50]; /* Temporary palette */ L_INT i; /* Loop counter */ /* Convert the current 24-bit bitmap to 8 bits per pixel with an optimized palette */ nRet = L_ColorResBitmap(pBitmap, pBitmap, sizeof(BITMAPHANDLE), 8, CRF_FLOYDSTEINDITHERING|CRF_OPTIMIZEDPALETTE, NULL, NULL, 0, NULL, NULL ); if(nRet != SUCCESS) return nRet; /* Get the first 50 colors from the bitmap's palette */ nRet = L_GetBitmapColors(pBitmap, 0, 50, pPalette); if(nRet != SUCCESS) return nRet; /* 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 */ nRet = L_PutBitmapColors(pBitmap, 0, 50, pPalette); if(nRet != SUCCESS) return nRet; /* Update the paint palette */ SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L); return SUCCESS; }