Sets the palette handle associated with the specified vector.
#include "ltvkrn.h"
L_LVKRN_API L_INT L_VecSetPalette(pVector, hPalette)
Pointer to the vector handle.
Handle to the new palette to set.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function makes a copy of hPalette, so you can delete the object if you don't need it anymore.
L_LTVKRNTEX_API 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;
}