Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_SetBitmapAlphaValues

Show in webframe

#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

Win32, x64, Linux.

See Also

Functions:

L_GetBitmapAlpha, L_SetBitmapAlpha, L_CreateMaskFromBitmapRgn, L_SetBitmapRgnFromMask, L_BitmapHasMeaningfulAlpha

Topics:

Defining and Using a Bitmap Region

 

Implementing Transparency

 

Saving a Region

Example

This example fills the Alpha Channel with a specified value.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


  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;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.