#include "l_bitmap.h"
L_LTKRN_API L_INT L_GetBitmapColors(pBitmap, nIndex, nCount, pPalette)
Loads your palette with selected colors from a bitmap handle's palette.
Pointer to the bitmap handle.
The index to the first color to get.
The number of colors to get.
The array of RGBQUAD values that make up your palette.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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
Win32, x64, Linux.
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;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document