#include "l_bitmap.h"
L_LTKRN_API L_INT L_CopyBitmapRect(pBitmapDst, pBitmapSrc, uStructSize, nCol, nRow, uWidth, uHeight)
Copies a portion of a bitmap to create another bitmap that is the size of the rectangle that you specify.
Pointer to the bitmap handle referencing the destination bitmap.
You do not have to initialize the bitmap handle; the L_CopyBitmapRect function initializes it for you.
Pointer to the bitmap handle referencing the source bitmap.
Size in bytes, of the structure pointed to by pBitmapDst
, for versioning. Use sizeof(BITMAPHANDLE).
The X coordinate of the pixel within the source bitmap that is the origin of the rectangle to copy.
The Y coordinate of the pixel within the source bitmap that is the origin of the rectangle to copy.
Width of the rectangle to copy (in pixels).
Height of the rectangle to copy (in pixels).
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function duplicates the original bitmap's palette, if one is required in the new bitmap.
This function uses bitmap coordinates to specify the area to be copied. Therefore, you must account for the view perspective of the bitmap. For information about bitmap coordinates, refer to Accounting for View Perspective.
If a region is defined for the source bitmap, the region is also copied, and the region is clipped if necessary.
Required DLLs and Libraries
Win32, x64, Linux.
This example uses L_CopyBitmapRect to copy a rectangle that would
appear in the upper left part of the displayed image.
L_INT CopyBitmapRectExample(L_TCHAR* szFilename, BITMAPHANDLE* pBitmap)
{
BITMAPHANDLE TmpBitmap; /* Temporary bitmap */
L_INT XOffset; /* Column offset of the rectangle to process */
L_UINT XSize; /* Pixel width of the rectangle to process */
L_INT YOffset; /* Row offset of the rectangle to process */
L_UINT YSize; /* Pixel height of the rectangle to process */
RECT rc; /* rect for converting coordinates */
L_INT nRet = 1;
/* Load the bitmap, at its own bits per pixel */
nRet = L_LoadBitmap (szFilename, &TmpBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet != SUCCESS)
return nRet;
/* Specify a rectangle in the top left part of the displayed image */
XOffset = BITMAPWIDTH (&TmpBitmap) / 8;
XSize = BITMAPWIDTH (&TmpBitmap) / 3;
YOffset = BITMAPHEIGHT (&TmpBitmap) / 8;
YSize = BITMAPHEIGHT (&TmpBitmap) / 3;
rc.left = XOffset;
rc.top = YOffset;
rc.right = XSize + rc.left;
rc.bottom = YSize + rc.top;
/* Make sure the coordinates are in the ViewPerspective of the Bitmap */
nRet = L_RectToBitmap ( &TmpBitmap, TOP_LEFT, &rc );
if(nRet != SUCCESS)
{
L_FreeBitmap(&TmpBitmap);
return nRet;
}
XOffset = rc.left;
YOffset = rc.top;
XSize = rc.right - rc.left;
YSize = rc.bottom - rc.top;
/* Copy the rectangle */
if(pBitmap->Flags.Allocated)
L_FreeBitmap(pBitmap);
nRet = L_CopyBitmapRect(pBitmap, &TmpBitmap, sizeof(BITMAPHANDLE), XOffset, YOffset, XSize, YSize);
/* Free the temporary bitmap */
L_FreeBitmap(&TmpBitmap);
return nRet;
}
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