L_TextureAlphaBlendBitmap

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_TextureAlphaBlendBitmap(pBitmapDst, nXDst, nYDst, nWidth, nHeight, pBitmapSrc, nXSrc, nYSrc, pBitmapMask, nOpacity, pBitmapUnderlay, pOffset, uFlags)

Combines image data from two bitmaps with feathering and constant opacity; by combining the two bitmaps with a variable opacity that depends on a fade mask then combine the result with the destination bitmap with a constant opacity.

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.

pBITMAPHANDLE pBitmapMask

Pointer to the bitmap handle that references the fade mask, if you want to combine the two bitmaps just with opacity set this parameter to NULL.

L_INT nOpacity

Opacity value used when combining the areas from the result of feathering and destination bitmaps. Valid values range 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.

pBITMAPHANDLE pBitmapUnderlay

Pointer to the bitmap handle that references the bitmap to be used as the underlying image. The function will use this bitmap to underlay the mask bitmap. You could ignore this parameter effect by passing NULL.

LPPOINT pOffset

Pointer to an underlay bitmap offset with respect to the destination bitmap. The function will use this point to calculate the parts of the underlay bitmap that will be applied to the mask bitmap. Using this point will give the user the ability to give the feel of continuous texture when applying this function to neighboring parts inside the destination bitmap using the same or different mask, if the pBitmapUnderlay parameter is set to NULL also set this parameter to NULL.

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.

To combine two bitmaps with a fixed opacity, use the L_AlphaBlendBitmap function.

To combine two bitmaps with a feather, use the L_FeatherAlphaBlendBitmap function.

The L_TextureAlphaBlendBitmap function does the two operations; at first combine the two images with feather using the fade mask bitmap then combine the result with the destination bitmap with a fixed opacity.

To create a bitmap that contains a fade mask, use L_CreateFadedMask.

This function can also underlay the fade mask bitmap with the underlay bitmap before using it in the feather combine operation.

This function also combines the fade mask bitmap with the underlay bitmap so that it appears to be an underlying texture for the fade mask bitmap.

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.

The following is an example for the resulted image using this functions with the following characteristics:

The right image is the result of applying the function without texture bitmap.

The left image is the result of applying the function with texture bitmap.

result of applying the L_TextureAlphaBlendBitmap

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.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

L_INT TextureAlphaBlendBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE BitmapDst; /* Bitmap handle to hold the loaded image */ 
   BITMAPHANDLE BitmapSrc; /* source bitmap */ 
   BITMAPHANDLE BitmapMask; /* Bitmap handle to the fade mask bitmap */ 
   L_INT XDst, YDst, XSize, YSize, XSrc, YSrc; 
 
   /* Load both bitmaps, at 24 bits per pixel */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Fruits.jpg")), &BitmapDst, sizeof(BITMAPHANDLE), 24, ORDER_BGRORGRAY, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image1.jpg")), &BitmapSrc, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* Load the fade mask bitmaps */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\FadeMask.bmp")), &BitmapMask, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL);  
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* Combine BitmapSrc with BitmapDst, with fade mask bitmap and a 100 opacity*/ 
   XSrc= XDst=0; 
   YSrc=YDst=0; 
   XSize=min(BitmapDst.Width,BitmapSrc.Width)-1; 
   YSize=min(BitmapDst.Height,BitmapSrc.Height)-1; 
   nRet = L_TextureAlphaBlendBitmap (&BitmapDst, XDst, YDst, BitmapMask.Width, BitmapMask.Height, &BitmapSrc, XSrc, YSrc, &BitmapMask, 100, NULL, NULL, 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &BitmapDst, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap  
   if(BitmapDst.Flags.Allocated)   
      L_FreeBitmap(&BitmapDst);   
   if(BitmapSrc.Flags.Allocated)    
      L_FreeBitmap(&BitmapSrc); 
   if (BitmapMask.Flags.Allocated) 
      L_FreeBitmap(&BitmapMask); 
   return SUCCESS; 
} 
Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

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