L_SetBitmapAlphaValues

#include "l_bitmap.h"

L_LTKRN_API L_INT L_SetBitmapAlphaValues(pBitmap, uAlpha)

Replaces existing alpha channel data or creates new alpha channel data in the destination bitmap.

Parameters

pBITMAPHANDLE pBitmap

Points to the destination bitmap handle, which references the bitmap where the alpha channel data will be updated or added.

L_UINT16 uAlpha

Value which will be used to create or replace the alpha channel data. The entire alpha channel will be filled with this value.

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.

Typically, an alpha channel contains a mask that is used for transparency. This function, together with L_GetBitmapAlpha and the LEADTOOLS region processing functions, lets you use the alpha channel to implement transparency.

Only 16-, 32- and 64-bit images can have an alpha channel. If pBitmap references a bitmap of any other color resolution, this function converts the pBitmap bitmap to 32-bit before it replaces the alpha channel. (If you want 16-bit, you should change it using L_ColorResBitmap, if necessary, before calling this function.)

If pBitmap is 48-bit, it will be converted to 64-bit and then have the alpha information added to it.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example fills the Alpha Channel with a specified value.

L_INT SetBitmapAlphaValuesExample() 
{ 
   L_INT nRet; 
   BITMAPHANDLE   MainBitmap;           /* Main bitmap */ 
   L_UINT16       uAlpha=0xFFFF;        /* Alpha channel value */ 
 
   /* Load a bitmap at 32 bits per pixel */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("Image1.cmp")), &MainBitmap, sizeof(BITMAPHANDLE), 32, ORDER_BGR, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Update the alpha channel in the bitmap */ 
   nRet = L_SetBitmapAlphaValues(&MainBitmap, uAlpha); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Save the bitmap at 32 bits per pixel to keep the alpha channel */ 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.PNG")), &MainBitmap, FILE_PNG, 24, 0, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Free the bitmap */ 
   L_FreeBitmap(&MainBitmap); 
 
   return SUCCESS; 
} 

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

LEADTOOLS Raster Imaging C API Help