L_DeskewCheckBitmap

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT EXT_FUNCTION L_DeskewCheckBitmap(pBitmap, pnAngle, crBack, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT32 * pnAngle;

/* address of the variable to be updated */

COLORREF crBack;

/* fill color */

L_UINT uFlags;

/* flags */

Rotates the specified bank check bitmap to straighten it. This function is available in Document/Medical toolkits only.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bank check bitmap to straighten

pnAngle

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. Valid values range from -2000 to 2000

crBack

Color used to fill the background following rotation. This is used only if DSKW_FILL is set in uFlags.

uFlags

Flags that indicate whether or not to deskew the image and what background color to use. 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. This is the default value.

 

DSKW_NOPROCESS

[0x00000001] Don�t deskew (rotate) the image. Generally this flag is used to find the angle of rotation.

 

The following flags indicate what background color to use:

 

Value

Meaning

 

DSKW_FILL

[0x00000000] Use the color in crBack to fill areas exposed after rotation. This is the default value.

 

DSKW_NOFILL

[0x00000010] Let the function automatically find the suitable background color used to fill areas exposed after rotation. crBack is ignored in this case.

 

The following flags indicate the image type:

 

Value

Meaning

 

DSKW_DOCUMENTIMAGE

[0x00000000] The image contains text only. This is the default value.

 

DSKW_DOCUMENTANDPICTURE

[0x00010000] The image contains text and pictures or light text.

 

The following flags indicate the rotation type:

 

Value

Meaning

 

DSKW_NORMALSPEEDROTATE

[0x00000000] Rotate at normal speed (high quality). This is the default value.

 

DSKW_HIGHSPEEDROTATE

[0x00100000] Rotate at high speed (moderate quality, only for 1-bit images)

 

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 which deskew algorithm to use:

 

Value

Meaning

 

CHECK_DESKEW_NOT_USED

[0x00000000] Do not perform any of the bank check algorithms. Perform the ordinary deskew. This is the default value.

 

CHECK_DESKEW_NORMAL

[0x01000000] Use the bank check algorithm to deskew the bitmap. This algorithm considers many features common to standard bank checks in order to determine orientation.

 

CHECK_DESKEW_DETECT_LINES

[0x02000000] Use the line detection algorithm to deskew the bitmap.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Like L_DeskewBitmap, you can use this function to automatically straighten scanned documents. L_DeskewCheckBitmap is designed to work especially on bank check images. The following algorithms can be used:

the normal deskew algorithm

a special bank check algorithm

a special line detection algorithm.

If uFlags contains DSKW_NOPROCESS, the function will update pnAngle with the deskew angle, without rotating the image.

Bitmaps can be rotated by as much as 20 degrees in either direction. This function is intended for bank check images 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 12 and 16-bit grayscale and 48 and 64-bit color images. If the image is 12 and 16-bit grayscale and 48 and 64-bit color, the function will not return an error.

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 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

LTIMGCOR

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

Windows 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_DeskewBitmap, L_DespeckleBitmap, L_WindowLevel, L_ApplyTransformationParameters, L_GetMarksCenterMassBitmap, L_GetTransformationParameters, L_IsRegMarkBitmap, L_SearchRegMarksBitmap

Topics:

Raster Image Functions: Doing Geometric Transformations

 

Raster Image Functions: Filtering Images

 

Processing an Image

 

Raster Image Functions: Document Imaging

 

Raster Image Functions: Processing an Image

 

Using Color Values in LEADTOOLS

 

Detecting Registration Marks

 

Deskewing

Example

This example loads a money check bitmap and straightens it.

L_INT DeskewCheckBitmapExample(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 (TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\Clean.tif"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   /* Deskew the bitmap */
   nRet = L_DeskewCheckBitmap(&LeadBitmap, NULL, 0, CHECK_DESKEW_DETECT_LINES | DSKW_PROCESS | DSKW_NOFILL | DSKW_DOCUMENTIMAGE | DSKW_HIGHSPEEDROTATE);
   if(nRet !=SUCCESS)
      return nRet;
   nRet = L_SaveBitmap(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\Result.BMP"), &LeadBitmap, FILE_BMP, 24, 0, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);  
   return SUCCESS;
}