Gets the zero-based index of the zone under a certain point.
#include "ltocr.h"
L_LTOCR_API L_INT EXT_FUNCTION L_OcrPage_HitTestZone(page, point, zoneIndex)
Handle to the OCR page.
The test point
Address of an L_INT variable to be updated with the zone index at the specified point.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Gets the zero-based index of the zone under a certain point. If no zone is under the test point, 'zoneIndex' parameter will have he value -1.
You can use this method to check whether a zone (either added manually or automatically) is under a given test point. For example, if you have a bitmap in your viewer you had the page zones drawn over the bitmap as rectangles and you wish to allow the user to click with the mouse on the viewer to select and de-select drawn zones, you can use L_OcrPage_HitTestZone.
// This example assumes you already have a page created and you have WM_LBUTTONDOWN or WM_LBUTTONUP messages taken care of
// so you can send the test point you wish to check again page zones and then the example will delete the zone under that point.
L_INT L_OcrPage_HitTestZoneExample(L_OcrPage ocrPage, L_POINT point)
{
L_INT zoneIndex = -1;
L_INT retCode = L_OcrPage_HitTestZone(ocrPage, point, &zoneIndex);
if(retCode != SUCCESS)
return FAILURE;
if(zoneIndex >= 0)
{
// we were able to successfully find the zone that includes the user passed point, so delete it.
retCode = L_OcrPage_RemoveZoneAt(ocrPage, zoneIndex);
if(retCode != SUCCESS)
return FAILURE;
}
return SUCCESS;
}