LBitmapBase::SetAlpha

Summary

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.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmapBase::SetAlpha(LBitmapAlpha)

Parameters

LBitmapBase& LBitmapAlpha

A bitmap object that has an allocated bitmap to be set as the alpha channel for the calling objects bitmap.

Returns

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

Comments

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.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

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 Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.