LBitmapBase::SetAlpha

#include "ltwrappr.h"

virtual L_INT LBitmapBase::SetAlpha(LBitmapAlpha)

LBitmapBase& LBitmapAlpha;

/* an LBitmap object */

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.

Parameter

Description

LBitmapAlpha

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

Returns

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

LTDIS
LTFIL

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Elements:

LFile::LoadCMYKArray, LFile::SaveCMYKArray, LPaint::PaintDCCMYKArray, LBitmapBase::CreateAlphaBitmap, Class Members

Topics:

Defining and Using a Bitmap Region

 

Implementing Transparency

 

Saving a Region

Example

LBitmapBase MyBitmap, Bitmap2;

MyBitmap.SetFileName(TEXT("image1.cmp"));
MyBitmap.Load(32); //load at 32 bit per pixel

Bitmap2.CreateAlphaBitmap(MyBitmap);
MyBitmap.Load(TEXT("image2.cmp"),32); //load at 32 bit per pixel
MyBitmap.SetAlpha(Bitmap2);