L_VecSetPalette

Summary

Sets the palette handle associated with the specified vector.

Syntax

#include "ltvkrn.h"

L_LVKRN_API L_INT L_VecSetPalette(pVector, hPalette)

Parameters

pVECTORHANDLE pVector

Pointer to the vector handle.

L_HPALETTE hPalette

Handle to the new palette to set.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function makes a copy of hPalette, so you can delete the object if you don't need it anymore.

Required DLLs and Libraries

See Also

Functions

Example

L_INT VecSetPaletteExample( 
   pVECTORHANDLE pVector, 
   COLORREF* pColors, 
   L_UINT16 uClrCount) 
{ 
   L_INT          nRet; 
   L_UINT16       i; 
   HPALETTE       hPalette; 
   LPLOGPALETTE   pLogPalette; 
 
   if( uClrCount > 0 ) 
   { 
      pLogPalette = (LPLOGPALETTE) malloc( sizeof( LOGPALETTE ) + sizeof( PALETTEENTRY ) * ( uClrCount - 1 ) ); 
      if( NULL == pLogPalette  ) 
         return ERROR_NO_MEMORY; 
 
      pLogPalette->palVersion    = 0x300; 
      pLogPalette->palNumEntries = uClrCount; 
      for( i = 0 ; i < pLogPalette->palNumEntries ; i++ ) 
      { 
         pLogPalette->palPalEntry[ i ].peRed   = GetRValue( pColors[ i ] ); 
         pLogPalette->palPalEntry[ i ].peGreen = GetGValue( pColors[ i ] ); 
         pLogPalette->palPalEntry[ i ].peBlue  = GetBValue( pColors[ i ] );  
         pLogPalette->palPalEntry[ i ].peFlags = 0; 
      } 
 
      hPalette = CreatePalette( pLogPalette ); 
      free( pLogPalette ); 
      if( NULL != hPalette ) 
      { 
         nRet = L_VecSetPalette( pVector, hPalette ); 
         DeleteObject( hPalette ); 
      } 
      else 
         nRet = FAILURE; 
   } 
   else 
      nRet = L_VecSetPalette( pVector, NULL ); 
 
   return nRet; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

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