Rotates the specified bitmap to straighten it. This function typically is used to automatically straighten scanned images.
L_LTIMGCOR_API L_INT L_DeskewBitmapExt(pBitmap, pnAngle, uAngleRange, uAngleResolution, crBack, uFlags)
Pointer to the bitmap handle referencing the bitmap to straighten.
NULL or the address of the variable to be updated with the amount that the function rotates the image. The amount of rotation is expressed in hundredths of degrees. For example, 500 means 5 degrees clockwise. You can pass NULL if you do not need to check the amount of rotation.
Maximum angle of deskew, in hundredths of degrees. Possible values range from 0 to 4500. This value is divided internally by 100.
Deskew angle precision. The valid range is from 1 to
uAngleRange (maximum deskew angle). The real value is divided by 10.
Color used to fill the background following rotation. This value is used only if DSK_FILL is set in
Flags that indicate whether or not to deskew the image, which background color to use, whether to deskew the image if the skew angle is very small, which type of interpolation is to be used, and whether the image is mostly text or text and pictures. You can use a bitwise OR ( | ) to specify one flag from each group.
|Deskewing the image after finding the skew angle:|
|DSKW_PROCESS||[0x00000000] Deskew (rotate) the image.|
|DSKW_NOPROCESS||[0x00000001] Do not deskew (rotate) the image. Use this flag to find the angle of rotation.|
|Background color to fill areas exposed after rotation:|
|DSKW_FILL||[0x00000000] Use the color in
|DSKW_NOFILL||[0x00000010] Let the function automatically find the suitable background color to fill areas exposed after rotation. Ignore the crBack parameter.|
|Deskew the image if the skew angle is very small:|
|DSKW_NOTHRESHOLD||[0x00000000] Deskew (rotate) the image for any deskew angle value.|
|DSKW_THRESHOLD||[0x00000100] Do not deskew the image if the deskew angle is very small (less than 0.5 degrees).|
|Type of interpolation to perform:|
|DSKW_LINEAR||[0x00000000] Do not perform interpolation when rotating.|
|DSKW_RESAMPLE||[0x00001000] Perform bilinear interpolation when rotating.|
|DSKW_BICUBIC||[0x00002000] Perform bicubic interpolation when rotating.|
|Image containing plain text or text and pictures:|
|DSKW_DOCUMENTIMAGE||[0x00000000] The image contains only text.|
|DSKW_DOCUMENTANDPICTURE||[0x00010000] The image contains text and pictures.|
|DSKW_NORMALSPEEDROTATE||[0x00000000] Rotate the image normally with a high rotation quality.|
|DSKW_HIGHSPEEDROTATE||[0x00100000] Speed up the image rotation with a moderate rotation quality (only for 1-bit images).|
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
Like L_DeskewBitmap, you can use this function to automatically straighten scanned documents. The L_DeskewBitmapeExt function extends the L_DeskewBitmap function to increase the possible deskew angle (from 10 degrees to 45 degrees in either direction). In addition, it adds the capability to forgo deskewing if the deskew angle is very small and to specify the resolution of the rotation step. It slso adds the capability to specify the type of interpolation to be performed while rotating.
uFlags contains DSKW_NOPROCESS, the function will update
pnAngle with the deskew angle without rotating the image.
The calculated rotation is limited to 45 degrees in either direction. This function is intended for images, such as scanned documents, that are mainly horizontal lines of text. The results are less predictable with other types of images.
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
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.
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.
Win32, x64, Linux.
The following example loads a bitmap and straightens it.
BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if (nRet != SUCCESS)
/* Deskew the bitmap */
nRet = L_DeskewBitmapExt(&LeadBitmap, NULL, 1000, 2, 0, DSKW_PROCESS | DSKW_NOFILL | DSKW_LINEAR | DSKW_DOCUMENTIMAGE);
if (nRet != SUCCESS)
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries