LEADTOOLS Raster Imaging C DLL Help > Function References > l_deskewbitmapext |
#include "l_bitmap.h"
L_LTIMGCOR_API L_INT L_DeskewBitmapExt(pBitmap, pnAngle, uAngleRange, uAngleResolution, crBack, uFlags)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
L_INT32* pnAngle; |
/* rotation angle */ |
L_UINT uAngleRange; |
/* angle range */ |
L_UINT uAngleResolution; |
/* angle resolution */ |
COLORREF crBack; |
/* fill color */ |
L_UINT uFlags; |
/* flags */ |
Rotates the specified bitmap to straighten it. This function typically is used to automatically straighten scanned images.
Parameter |
Description |
|
pBitmap |
Pointer to the bitmap handle referencing the bitmap to straighten. |
|
pnAngle |
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. |
|
uAngleRange |
Maximum angle of deskew, in hundredths of degrees. Possible values range from 0 to 4500. This value is divided internally by 100.. |
|
uAngleResolution |
Deskew angle precision. The valid range is from 1 to uAngleRange (maximum deskew angle). The real value is divided by 10. |
|
crBack |
Color used to fill the background following rotation. This value is used only if DSK_FILL is set in uFlags. |
|
uFlags |
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. The following flags indicate whether to deskew the image after the function finds the skew angle: |
|
|
Value |
Meaning |
|
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. |
|
The following flags indicate which background color to use to fill areas exposed after rotation: |
|
|
Value |
Meaning |
|
DSKW_FILL |
[0x00000000] Use the color in crBack to fill areas exposed after rotation. |
|
DSKW_NOFILL |
[0x00000010] Let the function automatically find the suitable background color to fill areas exposed after rotation. Ignore the crBack parameter. |
|
The following flags specify whether to deskew the image if the skew angle is very small: |
|
|
Value |
Meaning |
|
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). |
|
The following flags indicate which type of interpolation to perform: |
|
|
Value |
Meaning |
|
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. |
|
The following flags indicate whether the image contains plain text or text and pictures: |
|
|
Value |
Meaning |
|
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). |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
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.
Like L_DeskewBitmap, you can use this function to automatically straighten scanned documents. With this function, the L_DeskewBitmap function has been extended 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, and adds the capability to specify the type of interpolation to be performed while rotating.
If 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 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.
Required DLLs and Libraries
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
Example
The following example loads a bitmap and straightens it.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName #if !defined (LEADTOOLS_V17_OR_LATER) L_INT DeskewBitmapExtExample(L_VOID) { L_INT nRet; 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) return nRet; /* Deskew the bitmap */ nRet = L_DeskewBitmapExt(&LeadBitmap, NULL, 1000, 2, 0, DSKW_PROCESS | DSKW_NOFILL| DSKW_LINEAR| DSKW_DOCUMENTIMAGE); if(nRet !=SUCCESS) return nRet; //free Bitmap L_FreeBitmap(&LeadBitmap); return SUCCESS; } #endif