#include "ltdoc2.h"
L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2GetZoneNodes(hDoc, nPageIndex, nZoneIndex, ppPoints, pnNodesCount)
Gets the polygon of the user zone.
Handle to the OCR document. This handle is obtained by calling the L_Doc2StartUp function.
Index of the page. This is a zero-based index.
Index of the zone. This is a zero-based index.
Address of an array of POINT structures to be updated with polygon points
Address of a variable to be updated with the number of polygon points.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function retrieves a polygon, which consists of the vertices of a user zone. This can be useful for an application with a GUI when drawing irregular zones.
✎ NOTE
This function will not work for OMR zones, because OMR zones should have a regular shape.
To use the function properly:
To add a user zone, call the L_Doc2AddZone / L_Doc2AddZoneExt function. To add rectangle(s) to a user zone to make its shape irregular, call the L_Doc2AddZoneRect / L_Doc2AddZoneRectExt function.
To get zone rectangles, call the L_Doc2GetZoneLayout / L_Doc2GetZoneLayoutExt function. To set zone rectangles call the L_Doc2SetZoneLayout / L_Doc2SetZoneLayoutExt function.
Required DLLs and Libraries
L_INT Doc2ZoneNodesExample(L_HDOC2 hDoc, L_INT nPageIndex, L_INT nZoneIndex)
{
L_INT nRet;
L_INT nNodesCount;
POINT * pNodes = NULL;
nRet = L_Doc2GetZoneNodes(hDoc, nPageIndex, nZoneIndex, NULL, &nNodesCount);
if (nRet != SUCCESS)
return nRet;
pNodes = (POINT *)GlobalAllocPtr(GHND, sizeof(POINT) * nNodesCount);
nRet = L_Doc2GetZoneNodes(hDoc, nPageIndex, nZoneIndex, &pNodes, &nNodesCount);
if (nRet != SUCCESS)
{
GlobalFreePtr(pNodes);
return nRet;
}
L_TCHAR szBuffer[100];
for(int i=0; i<nNodesCount; i++)
{
memset(szBuffer, 0, sizeof(szBuffer));
wsprintf(szBuffer, TEXT("Zone Nodes # %d\nx = %d\ny = %d\n"),
i,
pNodes[i].x,
pNodes[i].y);
MessageBox(NULL, szBuffer, TEXT("Notice"), MB_OK);
}
GlobalFreePtr(pNodes);
return SUCCESS;
}