LBitmap::TextureAlphaBlend

Summary

Combines image data from pBitmapMask and pBitmapUnderlay with an underlay effect. The result is used as a fade mask that will be used to combine pBitmapSrc and caller object with variable opacity. The result is combined again with caller object using a constant opacity (using nOpacity).

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmap::TextureAlphaBlend (nXDst, nYDst, nWidth, nHeight, pBitmapSrc, nXSrc, nYSrc, pBitmapMask, nOpacity, pBitmapUnderlay, pOffset, uFlags = 0)

virtual L_INT LBitmap::TextureAlphaBlend (nXDst, nYDst, nWidth, nHeight, plBitmapSrc, nXSrc, nYSrc, plBitmapMask, nOpacity, plBitmapUnderlay, pOffset, uFlags = 0)

Parameters

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. This applies to pBitmapSrc, pBitmapMask.

L_INT nYSrc

The Y coordinate of the origin of the source rectangle. This applies to pBitmapSrc, pBitmapMask.

pBITMAPHANDLE pBitmapMask

Pointer to the bitmap handle that references the fade mask. This parameter can be set to NULL, in which case the combine is performed with a constant opacity (nOpacity).

L_INT nOpacity

Opacity value used when combining the areas from the result of feathering and destination bitmaps. Valid values ranges are:

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. This parameter will be used only if pBitmapUnderlay is not NULL.

LBitmapBase *plBitmapSrc

Pointer to the bitmap object that references the source bitmap.

LBitmapBase *plBitmapMask

Pointer to the bitmap object that references the fade mask. This parameter can be set to NULL, in which case the combine is performed with a constant opacity (nOpacity).

LBitmapBase *plBitmapUnderlay

Pointer to the bitmap object 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.

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

To combine two bitmaps with a fixed opacity, use the LBitmapBase::AlphaBlend function.

To combine two bitmaps with feathering, use the LBitmapBase::FeatherAlphaBlend function.

This function works as follows:

If pBitmapUnderlay is not NULL, pBitmapUnderlay is applied with an underlay operation to pBitmapMask. If present, pOffset is used to shift the starting point for the underlay pattern. If pBitmapMask is NULL, pBitmapUnderlay is not used.

If pBitmapMask is not NULL, it is used to combine pBitmapSrc with caller object using a variable opacity. If pBitmapMask is NULL, this step is skipped. (A local copy of pBitmapSrc will be used the original bitmap passed as pBitmapSrc will not be affected).

pBitmapSrc will be combined with caller object using fixed opacity (nOpacity).

To create a bitmap that contains a fade mask, use LBitmapBase::CreateFadedMask.

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

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 only in the Document/Medical toolkits.

As an example:

The source bitmap is a red image.

The destination bitmap is a white image.

The opacity is set to 255.

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.

LBitmap::TextureAlphaBlend

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.

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.

See Also

Functions

Topics

Example

L_INT LBitmap__TextureAlphaBlendExample(LBitmap *pBitmapSrc, LBitmap *pBitmapDst, LBitmap *pBitmapMask)  
{ 
   L_INT nRet; 
 
   /* Combine BitmapSrc with BitmapDst, with fade mask bitmap and a 100 opacity*/ 
 
   nRet = pBitmapDst->TextureAlphaBlend (0, 0, 100, 100, pBitmapSrc, 100, 100,  
                                         pBitmapMask, 100, NULL, NULL);  
 
   /* Free the temporary bitmaps */ 
   pBitmapSrc->Free (); 
   pBitmapMask->Free (); 
 
   return nRet; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

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