L_GetBitmapColors

Summary

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

Syntax

#include "l_bitmap.h"

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

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle.

L_INT nIndex

The index to the first color to get.

L_INT nCount

The number of colors to get.

L_RGBQUAD* pPalette

The array of RGBQUAD values that make up your palette.

Returns

Value Meaning
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

Platforms

Win32, x64, Linux.

See Also

Functions

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; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.