Add the following lines in one of your source code files (for example: IMPORTS.CPP).
// Please note to change the path to the LEADTOOLS toolkit location on your system.
Under (WIN64) add the following line:
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\CDLL\\x64\\Ltimgefx_x.lib")
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\CDLL\\x64\\Ltdis_x.lib")
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\CDLL\\x64\\Ltfil_x.lib")
Under (WIN32) add the following line:
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\CDLL\\Win32\\Ltimgefx_u.lib")
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\CDLL\\Win32\\Ltdis_u.lib")
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\CDLL\\Win32\\Ltfil_u.lib")
Include the following header file:
(Please note to change the path to the LEADTOOLS toolkit location on your system.)
#include "../../../L_Bitmap.h"
Define the following global variables:
HWND hWndClient; /* Handle of the current child window */
RGNXFORM XForm; /* Structure for transforming display coordinates */
RECT rClientArea; /* Client area of the current window */
RECT rRgnRect; /* Rectangle that defines the region */
BITMAPHANDLE BitmapDst; /* Destination bitmap */
BITMAPHANDLE BitmapSrc; /* Source bitmap */
L_INT XDst; /* Column offset of the destination */
L_INT YDst; /* Row offset of the destination */
L_INT XSize;/* Pixel width of the rectangle to combine */
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 two images as follows:
L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("sample1.cmp")), &BitmapDst, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("sample2.cmp")), &BitmapSrc, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
Get the client area of the current child window as follows:
GetClientRect(hWndClient, &rClientArea);
Set RGNXFORM fields, assuming that the display rectangle is the same as the client area of the current child window as follows:
XForm.uViewPerspective = TOP_LEFT;
XForm.nXScalarNum = BITMAPWIDTH(&BitmapDst);
XForm.nXScalarDen = rClientArea.right;
XForm.nYScalarNum = BITMAPHEIGHT(&BitmapDst);
XForm.nYScalarDen = rClientArea.bottom;
XForm.nXOffset = 0;
XForm.nYOffset = 0;
Specify a rectangle to define the region and then create a rectangular region as follows:
SetRect(&rRgnRect, rClientArea.right/8, rClientArea.bottom/8, rClientArea.right/2, rClientArea.bottom/2);
L_SetBitmapRgnRect(&BitmapDst, &XForm, &rRgnRect, L_RGN_SET);
Specify a position in the top left part of the displayed image and use the full size of the source bitmap as follows:
XDst = BITMAPWIDTH(&BitmapDst) / 8;
YDst = BITMAPHEIGHT(&BitmapDst) / 8;
YSize = BITMAPHEIGHT(&BitmapSrc);
XSize = BITMAPWIDTH(&BitmapSrc);
XSrc = 0;
YSrc = 0;
Combine BitmapDst with &BitmapSrc, using flags for an ordinary paste, and save the results:
L_CombineBitmap(&BitmapDst, XSize, YSize, XDst, YDst, &BitmapSrc, XSrc, YSrc, CB_OP_ADD | CB_DST_0);
L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("test_region.bmp")), &BitmapDst, FILE_BMP, 0, 2, NULL);
At the end you should free the rectangle:
L_FreeBitmapRgn(&BitmapDst);
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document