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_TextureAlphaBlendBitmap

Show in webframe

#include "l_bitmap.h"

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

pBITMAPHANDLE pBitmapDst;

/* pointer to the destination bitmap handle */

L_INT nXDst;

/* x coordinate */

L_INT nYDst;

/* y coordinate */

L_INT nWidth;

/* width */

L_INT nHeight;

/* height */

pBITMAPHANDLE pBitmapSrc;

/* pointer to the source bitmap handle */

L_INT nXSrc;

/* x coordinate */

L_INT nYSrc;

/* y coordinate */

pBITMAPHANDLE pBitmapMask;

/* pointer to a mask bitmap handle */

L_INT nOpacity;

/* opacity value */

pBITMAPHANDLE pBitmapUnderlay;

/* pointer to the underlay bitmap handle */

LPPOINT pOffset;

/* pointer to an underlay bitmap offset */

L_UINT32 uFlags;

/* flags */

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.

Parameter

Description

pBitmapDst

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

nXDst

The X coordinate of the origin of the destination rectangle.

nYDst

The Y coordinate of the origin of the destination rectangle.

nWidth

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

nHeight

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

pBitmapSrc

Pointer to the bitmap handle that references the source bitmap.

nXSrc

The X coordinate of the origin of the source rectangle.

nYSrc

The Y coordinate of the origin of the source rectangle.

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.

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.

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.

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.

uFlags

Reserved for future use. Must be 0.

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.

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

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

LTIMGEFX

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_UnderlayBitmap, L_CombineBitmap, L_AlphaBlendBitmap, L_FeatherAlphaBlendBitmap, L_CreateFadedMask, L_BricksTextureBitmap, L_CanvasBitmap, L_DisplaceMapBitmap, L_FragmentBitmap, L_VignetteBitmap, L_CanvasBitmap, L_CloudsBitmap, L_ColoredBallsBitmap, L_DiffuseGlowBitmap, L_DisplaceMapBitmap, L_FragmentBitmap, L_HalfTonePatternBitmap, L_MaskConvolutionBitmap, L_MosaicTilesBitmap, L_OffsetBitmap, L_PerspectiveBitmap, L_PlasmaFilterBitmap, L_PointillistBitmap, L_RomanMosaicBitmap, L_VignetteBitmap, L_ZigZagBitmap

Topics:

Raster Image Functions: Combining Images

 

Processing an Image

 

Raster Image Functions: Processing an Image

Example

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


#if defined (LEADTOOLS_V16_OR_LATER)
 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("IMAGE1.CMP")), &BitmapDst, sizeof(BITMAPHANDLE), 24, ORDER_BGRORGRAY, 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;

   /* 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, XSize, YSize, &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);
   return SUCCESS;
}
#else
 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("IMAGE1.CMP")), &BitmapDst, sizeof(BITMAPHANDLE), 24, ORDER_BGRORGRAY, 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;

   /* 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, XSize, YSize, &BitmapSrc, XSrc, YSrc, &BitmapMask, 100, NULL, NULL);
   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);
   return SUCCESS;
}
#endif // LEADTOOLS_V16_OR_LATER
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.