L_AlphaBlendBitmap

Summary

Combines image data from two bitmaps, using the specified opacity value.

Syntax

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_AlphaBlendBitmap(pBitmapDst, nXDst, nYDst, nWidth, nHeight, pBitmapSrc, nXSrc, nYSrc, nOpacity, uFlags)

Parameters

pBITMAPHANDLE pBitmapDst

Pointer to the bitmap handle that references the destination bitmap. The function will update this bitmap.

L_INT nXDst

The X coordinate of the origin of the destination rectangle.

L_INT nYDst

The Y coordinate of the origin of the destination rectangle.

L_INT nWidth

Width of the area to be combined, in pixels. This width applies to both the source and the destination areas.

L_INT nHeight

Height of the area to be combined, in pixels. This height applies to both the source and the destination areas.

pBITMAPHANDLE pBitmapSrc

Pointer to the bitmap handle that references the source bitmap.

L_INT nXSrc

The X coordinate of the origin of the source rectangle.

L_INT nYSrc

The Y coordinate of the origin of the source rectangle.

L_INT nOpacity

Opacity value used when combining the areas from the source and destination bitmaps. The valid range is from 0 - 65535 for 64-bit, 48-bit and 16-bit grayscale images and from 0 - 4095 for 12-bit grayscale images. Otherwise, it is from 0 to 255.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

Value Meaning
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.

The opacity determines how much the destination bitmap will show through the source bitmap. For example, if the opacity is 255 (completely opaque) then the source image will appear and the destination image will not show through the source image at all. If the opacity is 128 (half opacity), then the pixels for that area will consist of 50 percent from the source image and 50 percent from the destination image.

To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

Alpha Blend Function - Before

Alpha Blend Function - Before

Alpha Blend Function - After

Alpha Blend Function - After

View additional platform support for this Alpha Blend function.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

L_INT AlphaBlendBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE BitmapDst;  /* Bitmap handle to hold the loaded image   */ 
   BITMAPHANDLE BitmapSrc;  /* source bitmap                            */ 
   L_INT XDst;              /* Column offset of the destination         */ 
   L_INT XSize;             /* Pixel width of the rectangle to combine  */ 
   L_INT YDst;              /* Row offset of the destination            */ 
   L_INT YSize;             /* Pixel height of the rectangle to combine */ 
   L_INT XSrc;              /* Column offset of the source              */ 
   L_INT YSrc;              /* Column offset of the source              */ 
 
   /* Load both bitmaps, at 24 bits per pixel */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &BitmapDst, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE2.CMP")), &BitmapSrc, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Specify a position in the top left part of the displayed image */ 
   XDst = BITMAPWIDTH(&BitmapDst) / 8; 
   YDst = BITMAPHEIGHT(&BitmapDst) / 8; 
 
   /* Use the full size of the source bitmap */ 
   YSize = BITMAPHEIGHT(&BitmapSrc); 
   XSize = BITMAPWIDTH(&BitmapSrc); 
   XSrc = 0; 
   YSrc = 0; 
 
   /* Combine BitmapSrc with BitmapDst, with half opacity */ 
   nRet = L_AlphaBlendBitmap(&BitmapDst, XDst, YDst, XSize, YSize, &BitmapSrc, XSrc, YSrc, 128, 0); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Free the temporary bitmap */ 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &BitmapDst, FILE_BMP, 24, 0, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   //free bitmap 
   if (BitmapSrc.Flags.Allocated) 
      L_FreeBitmap(&BitmapSrc); 
 
   if (BitmapDst.Flags.Allocated) 
      L_FreeBitmap(&BitmapDst); 
 
   return SUCCESS; 
} 
Help Version 22.0.2023.7.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

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