virtual L_INT LBitmapBase::SetAlpha(LBitmapAlpha)
Replaces the class object's existing alpha channel data or creates new alpha channel data in the class object's bitmap using the specified class object's bitmap.
A bitmap object that has an allocated bitmap to be set as the alpha channel for the calling objects bitmap.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Typically, an alpha channel contains a mask that is used for transparency. This function, together with the LEADTOOLS region processing functions, lets you use the alpha channel to implement transparency.
Only 16- and 32-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 LBitmapBase::ColorRes, if necessary, before calling this function.)
The pAlpha bitmap does not have to be grayscale. This function converts the data from the pAlpha bitmap to the necessary grayscale or 1-bit format as it replaces the alpha channel in pBitmap. (The pAlpha bitmap, itself, remains unchanged.)
Note: The LBitmapAlpha parameter is passed by reference, and is a required parameter.
This function does not support signed data images, unless they are DICOM images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image that is not a DICOM image is passed to this function.
Win32, x64.
L_INT LBitmapBase__SetAlphaExample()
{
L_INT nRet;
LBitmapBase MyBitmap,Bitmap2;
MyBitmap.SetFileName(MAKE_IMAGE_PATH(TEXT("image1.cmp")));
nRet =MyBitmap.Load(32);
if(nRet !=SUCCESS)//load at 32 bit per pixel
return nRet;
nRet =Bitmap2.CreateAlphaBitmap(MyBitmap);
if(nRet !=SUCCESS)
return nRet;
nRet =MyBitmap.Load(MAKE_IMAGE_PATH(TEXT("image2.cmp")),32);
if(nRet !=SUCCESS)
return nRet;//load at 32 bit per pixel
nRet =MyBitmap.SetAlpha(Bitmap2);
if(nRet !=SUCCESS)
return nRet;
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