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_CombineBitmap

Show in webframe

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_CombineBitmap(pBitmapDst, nXDst, nYDst, nWidth, nHeight, pBitmapSrc, nXSrc, nYSrc, uMaxedFlags, uFlags)

pBITMAPHANDLE pBitmapDst;

/* pointer to the destination bitmap handle */

L_INT nXDst;

/* x coordinate of the origin of the destination rectangle */

L_INT nYDst;

/* y coordinate of the origin of the destination rectangle */

L_INT nWidth;

/* width of the rectangle, measured in pixels */

L_INT nHeight;

/* height of the rectangle, measured in pixels */

pBITMAPHANDLE pBitmapSrc;

/* pointer to the source bitmap handle */

L_INT nXSrc;

/* x coordinate of the origin of the source rectangle */

L_INT nYSrc;

/* y coordinate of the origin of the source rectangle */

L_UINT uMaxedFlags;

/* operation flags */

L_UINT32 uFlags;

/* flags */

Combines image data from two bitmaps (source and destination), letting you specify the areas to be combined, the operations to be performed when combining the data, and which color planes (R or G or B or R, G, and B) are used.

Parameter

Description

pBitmapDst

Pointer to the bitmap handle referencing the destination bitmap. This is the bitmap that the function updates.

nXDst

The X coordinate of the origin of the destination rectangle.

nYDst

The Y coordinate of the origin of the destination rectangle.

nWidth

The width of the rectangle, measured in pixels. The same number is used for both source and destination rectangles.

nHeight

The height of the rectangle, measured in pixels. The same number is used for both source and destination rectangles.

pBitmapSrc

Pointer to the bitmap handle referencing the source bitmap, which is combined with the destination bitmap.

nXSrc

The X coordinate of the origin of the source rectangle.

nYSrc

The Y coordinate of the origin of the source rectangle.

uMaxedFlags

The flags are combined into seven groups that define treatment of the source, treatment of the destination, the operation to use when combining the data, treatment of the resulting image, and the color plan for the destination, source and resulting images. The flags apply only to the defined rectangles (not necessarily the whole bitmap). You can use a bitwise OR ( | ) to specify one flag from each group. Refer to Flags for the L_CombineBitmap Function for the list of flags.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

For example, suppose you use the L_SpatialFilterBitmap function to apply an edge detection filter. You can then use this function to combine the resulting bitmap with the original one to produce an image with hard edges.

This function combines the data byte-by-byte. The two images can be any color resolution. Images that are 24-bits per pixel are the easiest and fastest to combine. This function uses Windows-style coordinates (with a top-left origin) to specify the areas to be combined.

If the channel setting for one of the bitmaps is the master channel (CB_SRC_MASTER, CB_DST_MASTER, CB_RES_MASTER) the settings for all the bitmaps will be set to master.

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

If a region is defined for either the source or destination bitmap, or both bitmaps, the combine applies only to the intersection of regions.

For example, assume CB_SRC_RED is passed for the source bitmap, CB_DST_BLUE is passed for the destination bitmap and CB_RES_GREEN is passed for the resulting bitmap. In this case, the green channel of the resulting bitmap is calculated as the result of the operations applied to the red channel of the source bitmap and the blue channel of the destination bitmap. The other channels of the resulting bitmap are unchanged.

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.

The sign flag in the BITMAPHANDLE structure must be the same for all images listed. That is, all images must be either signed or unsigned.

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_BricksTextureBitmap, L_CanvasBitmap, L_DisplaceMapBitmap, L_FragmentBitmap, L_VignetteBitmap

Topics:

Raster Image Functions: Combining Images

 

Processing an Image

 

Raster Image Functions: Processing an Image

Example

For complete sample code, refer to the CHILD.C module of the DEMO example. This example uses the flags for a simple paste when combining the source bitmap with the destination bitmap.

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


 L_INT CombineBitmapExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE   LeadBitmap;  /* Bitmap handle to hold the loaded image */
   BITMAPHANDLE   TmpBitmap;   /* Temporary 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("ImageProcessingDemo\\Image3.cmp")), &LeadBitmap, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL);
   if(nRet != SUCCESS)
      return nRet;
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ULAY1.BMP")), &TmpBitmap, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL);
   if(nRet != SUCCESS)
   {
      L_FreeBitmap (&LeadBitmap);
      return nRet;
   }
   /* Specify a position in the top left part of the displayed image */
   XDst = BITMAPWIDTH(&LeadBitmap) / 8;
   YDst = BITMAPHEIGHT(&LeadBitmap) / 8;
   /* Use the full size of the source bitmap */
   YSize = BITMAPHEIGHT(&TmpBitmap);
   XSize = BITMAPWIDTH(&TmpBitmap);
   XSrc = 0;
   YSrc = 0;
   /* Combine TmpBitmap with LeadBitmap, using flags for an ordinary paste */
#if defined (LEADTOOLS_V16_OR_LATER)
   nRet = L_CombineBitmap(&LeadBitmap, XDst, YDst, XSize, YSize,
                   &TmpBitmap, XSrc, YSrc, CB_OP_ADD | CB_DST_0, 0);
#else
   nRet = L_CombineBitmap(&LeadBitmap, XDst, YDst, XSize, YSize,
                   &TmpBitmap, XSrc, YSrc, CB_OP_ADD | CB_DST_0);
#endif
   if(nRet != SUCCESS)
   {
      L_FreeBitmap (&LeadBitmap);
      L_FreeBitmap (&TmpBitmap);
      return nRet;
   }

   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &TmpBitmap, FILE_BMP, 24, 0, NULL);
   if(nRet != SUCCESS)
   {
      L_FreeBitmap (&LeadBitmap);
      L_FreeBitmap (&TmpBitmap);
      return nRet;
   }

   L_FreeBitmap (&LeadBitmap);
   L_FreeBitmap (&TmpBitmap);

   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.