L_SetBitmapAlphaValues
#include "l_bitmap.h"
L_LTKRN_API L_INT L_SetBitmapAlphaValues(pBitmap, uAlpha)
|
pBITMAPHANDLE pBitmap; |
/* points to the destination bitmap handle */ |
|
L_UINT16 uAlpha; |
/* value to set */ |
Replaces existing alpha channel data or creates new alpha channel data in the destination bitmap.
|
Parameter |
Description |
|
pBitmap |
Points to the destination bitmap handle, which references the bitmap where the alpha channel data will be updated or added. |
|
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
|
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
|
LTKRN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Windows 95 / 98 / Me, Windows 2000 / XP.
See Also
|
Functions: |
L_GetBitmapAlpha,L_SetBitmapAlpha L_CreateMaskFromBitmapRgn, L_SetBitmapRgnFromMask |
|
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(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\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(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\Result.PNG"), &MainBitmap, FILE_PNG, 16, 0, NULL);
if(nRet != SUCCESS)
return nRet;
/* Free the bitmap */
L_FreeBitmap(&MainBitmap);
return SUCCESS;
}