LEADTOOLS Raster Imaging C++ Class Library Help > Classes and Member Functions > LBitmap > LBitmap Member Functions > LBitmap::InvertedText |
#include "ltwrappr.h"
virtual L_INT LBitmap::InvertedText(pInvertedText, uFlags = 0)
pINVERTEDTEXT pInvertedText; |
/* pointer to a structure */ |
L_UINT32 uFlags; |
/* flags */ |
Finds and inverts areas of inverted text in a 1-bit black and white image.
Parameter |
Description |
pInvertedText |
Pointer to the INVERTEDTEXT structure that LEADTOOLS uses to find and correct inverted text. |
uFlags |
Reserved for future use. Must be 0. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function finds and inverts areas of inverted text that are common in scanned text documents.
Below is an example of inverted text often found in scanned images:
Modifying the area of inverted text yields:
This function works only on 1-bit black and white images.
If a region is selected, only the selected region will be changed by this function. If no region is selected, the whole image will be processed.
The behavior of this function can be modified by overriding LBitmap::InvertedTextCallback.
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
Win32, x64.
See Also
Example
//This example finds all inverted text regions greater than 5 inches in width and 1/2 inch in height
// and inverts it so that it appears normal
//The derived class LMyBitmap is used to override the InvertedTextCallBack function
//The callback member function is used to display additional information about the inverted text regions
//The callback member function does NOT receive a Windows region
//A LEAD region is updated by the function to show all of the changes.
class LInvertedTextBitmap : public LBitmap { public: LInvertedTextBitmap(); ~LInvertedTextBitmap(); virtual L_INT LInvertedTextBitmap::InvertedTextCallBack(HRGN hRgn, PRECT pBoundingRect, L_INT32 iWhiteCount, L_INT32 iBlackCount ); }; LInvertedTextBitmap::LInvertedTextBitmap() { } LInvertedTextBitmap::~LInvertedTextBitmap() { } L_INT LInvertedTextBitmap::InvertedTextCallBack(HRGN hRgn, PRECT pBoundingRect, L_INT32 iWhiteCount, L_INT32 iBlackCount ) { UNREFERENCED_PARAMETER(hRgn); CString strMsg; //Note: no hRgn to delete because it was not requested strMsg.Format( TEXT("Size[%dx%d]\tBounds[%d,%d][%d,%d]\tWhiteCount[%d]\tBlackCount[%d]\n"), pBoundingRect->right - pBoundingRect->left, pBoundingRect->bottom - pBoundingRect->top, pBoundingRect->left, pBoundingRect->top, pBoundingRect->right, pBoundingRect->bottom, iWhiteCount, iBlackCount); OutputDebugString(strMsg); return SUCCESS_REMOVE; } L_INT LBitmap__InvertedTextExample(LBitmapWindow *pBitmapWindow) { L_INT32 nRet; BITMAPHANDLE BitmapRegion; INVERTEDTEXT it; it.uStructSize = sizeof(INVERTEDTEXT); memset(&BitmapRegion, 0, sizeof(BITMAPHANDLE)); it.uStructSize = sizeof(INVERTEDTEXT); //Units are in thousands of inches it.iMinInvertWidth = 5000; it.iMinInvertHeight = 500; it.iMinBlackPercent = 70; it.iMaxBlackPercent = 95; it.pBitmapRegion = &BitmapRegion; it.uBitmapStructSize = sizeof(BitmapRegion); it.uFlags = INVERTEDTEXT_SINGLE_REGION | INVERTEDTEXT_LEAD_REGION | INVERTEDTEXT_USE_DPI; nRet = pBitmapWindow->InvertedText(&it); if (nRet == SUCCESS) { //Delete the existing region LBitmapRgn Region(pBitmapWindow); if(Region.BitmapHasRgn()) { Region.Free(); } pBitmapWindow->SetHandle(it.pBitmapRegion, FALSE); } return SUCCESS; }