#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.
Points to the destination bitmap handle, which references the bitmap where the alpha channel data will be updated or added.
Value which will be used to create or replace the alpha channel data. The entire alpha channel will be filled with this value.
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.
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
Win32, x64, Linux.
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 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