L_DocDrawPage

#include "ltdoc.h"

L_INT EXT_FUNCTION L_DocDrawPage(hDoc, hDC, nPageIndex, pSrc, pClipSrc, pDst, pClipDst, uROP3, bShowZones)

L_HDOC hDoc;

/* handle to the OCR document */

HDC hDC;

/* handle to the target device context */

L_INT nPageIndex;

/* page index */

LPRECT pSrc;

/* pointer to the display source rectangle */

LPRECT pClipSrc;

/* pointer to the display source clipping rectangle */

LPRECT pDst;

/* pointer to the display destination rectangle */

LPRECT pClipDst;

/* pointer to the display destination clipping rectangle */

L_UINT32 uROP3;

/* windows ROP code for display */

L_BOOL bShowZones;

/* flag to draw page zones or not */

Displays the specified page with(out) its zones, at any size, to any device context (screen, printer, or memory DC). If the display surface has fewer colors than the image, this function dithers the output to that display surface without affecting the actual image data.

Parameter

Description

hDoc

handle to the OCR document.

hDC

Handle to a device context, such as a screen, to use as the display surface. The mapping mode of the device context must be MM_TEXT.

nPageIndex

Specifies the index of the page that will be drawn. This index is zero-based.

pSrc

Pointer to the Windows RECT structure that specifies the part of the bitmap to use as the display source.

 

The coordinates in the RECT structure are relative to the bitmap. You can pass NULL to use the default, which matches the bitmap.

pClipSrc

Pointer to the Windows RECT structure that specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source bitmap has changed.

 

The coordinates in the RECT structure are relative to the bitmap. You can pass NULL to use the default, which matches the bitmap.

pDst

Pointer to the Windows RECT structure that determines how the source rectangle is scaled and how the image is positioned in the device context.

 

The coordinates in the RECT structure are relative to the device context. There is no default for this parameter. You must specify the RECT structure.

pClipDst

Pointer to the Windows RECT structure that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

 

The coordinates in the RECT structure are relative to the device context. You can pass NULL to use the default, which matches the device context. In most cases, however, you should use the rectangle returned by the Windows WM_PAINT message.

uROP3

The Windows ROP code that determines how the destination rectangle is updated. This parameter takes the same codes as the Windows BitBlt function. For ordinary painting, use SRCCOPY.

bShowZones

Specifies if the page zones will be drawn or not. Valid values are:

 

Value

Meaning

 

TRUE

draw the page zones

 

FALSE

don’t draw the page zones.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Before calling this function, you must specify the active page that will be drawn.

If L_DocSetActivePage is not called, then this function will return an error, ERROR_DOC_ACTIVE_PAGE.

This function lets you specify a source rectangle (with coordinates relative to the bitmap) and a destination rectangle (with coordinates relative to the device context). Scaling of the displayed image depends on the relationship between these two rectangles, as shown in the following illustration.

Note:

These illustrations are for a bitmap with a TOP_LEFT view perspective. For an explanation of bitmap coordinates and view perspectives, refer to Accounting for View Perspective, in the Main API help file. If the bitmap is not in TOP_LEFT view perspective, refer to Changing Bitmap Coordinates in the Main API help file.

image\paint1.gif

In addition, you can specify a clipping area within either rectangle to limit the area to be painted. For the destination rectangle, a clipping area is commonly specified to repaint part of the image that was temporarily covered up. For a source rectangle, you can use a clipping area to update the display when only part of the image in the source rectangle has changed.

The following illustration shows how specifying a source clipping area affects the display. Text has been added to the source bitmap (using the bitmap as a display surface), and the source clipping area specifies the area to be repainted.

image\paint2.gif

You can specify the various rectangles in any way that meets your needs. Coordinates can have negative values and they can extend beyond the bounds of the bitmap or the device context. In fact, it is common for the display rectangle to be bigger than the device context, where scroll bars are used to see different parts of the image.

In simple cases, you can use this function as follows:

image\paint3.gif

Required DLLs and Libraries

LTDOC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_DocLockPage, L_DocUnlockPage, L_DocSetActivePage, L_DocSelectZoneByPoint, L_DocSelectZone, L_DocRemoveSelectedZone, L_DocSetZonePen, L_DocSetSelectedZonePen, L_DocGetSelectedZone, L_DocZone

Topics:

OCR Functions: Drawing Zones and Pages

 

Drawing Pages and Zones

Example

void TestDrawing(L_HDOC hDoc, HWND hWnd)
{
   HDC hdc = NULL;
   HPEN hSelectedPen = NULL;
   HPEN hOldSelectedPen = NULL;
   HPEN hPen = NULL;
   HPEN hOldPen = NULL;
   PAGEINFO PageInfo;
   RECT rcDst;

   memset(&PageInfo, 0, sizeof(PAGEINFO));
   hdc = GetDC(hWnd);

   L_DocSetActivePage(hDoc, 0);

   hSelectedPen = CreatePen(PS_SOLID, 2, RGB(255, 255, 0));
   if (hSelectedPen)
      hOldSelectedPen = L_DocSetSelectedZonePen(hDoc, hSelectedPen);

   hPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 255));
   if (hPen)
      hOldPen = L_DocSetZonePen(hDoc, hSelectedPen);

   L_DocGetPageInfo (hDoc, 0, &PageInfo, sizeof(PAGEINFO));
   SetRect(&rcDst, 0, 0, PageInfo.nWidth, PageInfo.nHeight);

   L_DocSelectZone(hDoc, hdc, 0, 0, TRUE);
   L_DocDrawPage(hDoc, hdc, 0, NULL, NULL, &rcDst, NULL, SRCCOPY, TRUE);

   if (hOldSelectedPen)
      L_DocSetSelectedZonePen(hDoc, hOldSelectedPen);

   if (hOldPen)
      L_DocSetZonePen(hDoc, hOldPen);

   ReleaseDC(hWnd, hdc);
}