Combines the image data of both the class object's bitmap (the destination bitmap) and the specified bitmap (the source bitmap), 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) to be used.
virtual L_INT LBitmapBase::Combine(pLBitmapSrc, nWidth, nHeight, nXDst, nYDst, nXSrc, nYSrc, uMaxedFlags=CB_OP_ADD|CB_DST_0, uFlags = 0)
Pointer to an LBitmapBase object that contains the source bitmap, which is combined with the class object's bitmap.
The width of the rectangle, measured in pixels. The same number is used for both source and destination rectangles.
The height of the rectangle, measured in pixels. The same number is used for both source and destination rectangles.
The X coordinate of the origin of the destination rectangle.
The Y coordinate of the origin of the destination rectangle.
The X coordinate of the origin of the source rectangle.
The Y coordinate of the origin of the source rectangle.
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 planes for the destination, source and resulting images. The flags apply only to the defined rectangles (not necessarily the entire bitmap). Use a bitwise OR ( | ) to specify one flag from each group. Refer to Flags for the LBitmapBase::Combine Function for the list of flags.
Reserved for future use. Must be 0.
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
The class object's bitmap is updated with the result of this operation.
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.
For example, suppose you use the LBitmap::SpatialFilter 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.
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 only in the Document/Medical toolkits.
To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.
If a region is defined for either the source or destination bitmap, or both bitmaps, the combine applies only to the intersection of regions.
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 of the bitmaps will be set to master.
In order to speed up widely used image processing filters in LEADTOOLS, the grayscale value (master channel) of a colored image is calculated using the following formulas:
#define CalcGrayValue(r, g, b) ((L_UCHAR)(((L_UCHAR) (((2 * (L_UINT) (r)) + (5 * (L_UINT) (g)) + (L_UINT) (b) + 4) / 8))))
#define CalcGrayValue16(r, g, b) ((L_UINT16) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8))
#define CalcGrayValue32(r, g, b) ((L_UINT32) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8))
Combine Function - Before
Combine Function - After
View additional platform support for this Combine function.
This example uses the flags for a simple paste when combining
the source bitmap with the destination bitmap.
LBitmapBase LeadBitmap; /* Bitmap handle to hold the loaded image */
LBitmapBase 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 =LeadBitmap.Load (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")));
/* Specify a position in the top left part of the displayed image */
XDst = LeadBitmap.GetWidth();
YDst = LeadBitmap.GetHeight() / 8;
/* Use the full size of the source bitmap */
YSize = TmpBitmap.GetWidth();
XSize = TmpBitmap.GetHeight();
XSrc = 0;
YSrc = 0;
/* Combine TmpBitmap with LeadBitmap, using flags for an ordinary paste */
nRet =LeadBitmap.Combine(&TmpBitmap, XSize, YSize, XDst, YDst, XSrc, YSrc, CB_OP_ADD | CB_DST_0);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries