L_Doc2DrawPageExt

#include "ltdoc2.h"

L_LTDOC2_API L_INT L_Doc2DrawPageExt(hDoc, hDC, nDocId, nPageIndex, pSrc, pClipSrc, pDst, pClipDst, uROP3, bShowZones)

Displays the specified page with(out) its zones, at any size, on 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.

Parameters

L_HDOC2 hDoc

Handle to the OCR document

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

L_INT nDocId

Document ID created by calling L_Doc2CreateDocument.

L_INT nPageIndex

Zero-based index of the page that will be drawn.

LPRECT pSrc

Pointer to a Windows RECT structure that specifies the part of the bitmap to be used as the display source.

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

LPRECT pClipSrc

Pointer to a Windows RECT structure that specifies the portion of the display source to be painted. 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. Pass NULL to use the default, which matches the bitmap.

LPRECT pDst

Pointer to a 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.

LPRECT pClipDst

Pointer to a Windows RECT structure that specifies the portion of the display rectangle to be painted. 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. Pass NULL to use the default, which matches the device context. In most cases, use the rectangle returned by the Windows WM_PAINT message.

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

Pointer to a Windows RECT structure that specifies the part of the bitmap to be used as the display source.

L_BOOL bShowZones

Specifies whether the page zones will be drawn.  Possible values are:

Value Meaning
TRUE Draw the page zones
FALSE Do not draw the page zones.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

✎ NOTE

Before calling L_Doc2DrawPageExt, you must specify the active page (pDst) that will be drawn by calling L_Doc2SetActivePage / L_Doc2SetActivePageExt. If the active page is not specified, L_Doc2DrawPageExt returns the ERROR_DOC_ACTIVE_PAGE error.

L_Doc2DrawPageExt 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 illustrations.

The following 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. If the bitmap is not in TOP_LEFT view perspective, refer to Changing Bitmap Coordinates.

image\paint1.gif

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 the part of the image that was temporarily covered up. For a source rectangle, 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, use L_Doc2DrawPageExt as follows:

image\paint3.gif

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_INT Doc2DrawPageExampleExt(L_HDOC2 hDoc, L_INT nDocId, HWND hWnd) 
{ 
   L_INT nRet; 
   HDC hdc = NULL; 
   HPEN hSelectedPen = NULL; 
   HPEN hOldSelectedPen = NULL; 
   HPEN hPen = NULL; 
   HPEN hOldPen = NULL; 
   PAGEINFO2 PageInfo; 
   RECT rcDst; 
 
   memset(&PageInfo, 0, sizeof(PAGEINFO2)); 
   hdc = GetDC(hWnd); 
 
   nRet = L_Doc2SetActivePageExt(hDoc, nDocId, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   hSelectedPen = CreatePen(PS_SOLID, 2, RGB(255, 255, 0)); 
   if (hSelectedPen) 
      hOldSelectedPen = L_Doc2SetSelectedZonePen(hDoc, hSelectedPen); 
 
   hPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 255)); 
   if (hPen) 
      hOldPen = L_Doc2SetZonePen(hDoc, hSelectedPen); 
 
   nRet = L_Doc2GetPageInfoExt (hDoc, nDocId, 0, &PageInfo, sizeof(PAGEINFO2)); 
   if(nRet != SUCCESS) 
      return nRet; 
   SetRect(&rcDst, 0, 0, PageInfo.nWidth, PageInfo.nHeight); 
 
   nRet = L_Doc2SelectZoneExt(hDoc, hdc, nDocId, 0, 0, TRUE); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = L_Doc2DrawPageExt(hDoc, hdc, nDocId, 0, NULL, NULL, &rcDst, NULL, SRCCOPY, TRUE); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   if (hOldSelectedPen) 
      L_Doc2SetSelectedZonePen(hDoc, hOldSelectedPen); 
 
   if (hOldPen) 
       L_Doc2SetZonePen(hDoc, hOldPen); 
 
   ReleaseDC(hWnd, hdc); 
   return SUCCESS; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help