L_CaptureArea

#include "l_bitmap.h"

L_LTSCR_API L_INT L_CaptureArea(pBitmap, uBitmapStructSize, pCaptureAreaOption, uOptionsStructSize, pCaptureInfo, uInfoStructSize, pfnCaptureCallback, pUserData)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_UINT uBitmapStructSize;

/* size in bytes, of the structure pointed to by pBitmap */

pLEADCAPTUREAREAOPTION pCaptureAreaOption;

/* pointer to an area option structure */

L_UINT uOptionsStructSize;

/* size in bytes, of the structure pointed to by pCaptureAreaOption */

pLEADCAPTUREINFO pCaptureInfo;

/* pointer to an info option structure */

L_UINT uInfoStructSize;

/* size in bytes, of the structure pointed to by pCaptureInfo */

CAPTURECALLBACK pfnCaptureCallback;

/* optional callback function */

L_VOID * pUserData;

/* pointer to more parameters for the callback */

Captures an image of the user selected area.

Parameter

Description

pBitmap

Pointer to a bitmap handle that references the captured data.

uBitmapStructSize

Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).

pCaptureAreaOption

Address of a LEADCAPTUREAREAOPTION structure that contains information on what type of area to capture.

uOptionsStructSize

Size in bytes, of the structure pointed to by pCaptureAreaOption, for versioning. Use sizeof(LEADCAPTUREAREAOPTION).

pCaptureInfo

Address of a LEADCAPTUREINFO structure to be filled with information regarding the captured image's source. Pass NULL if you are not interested in more information about the capture.

uInfoStructSize

Size in bytes, of the structure pointed to by pCaptureInfo, for versioning. Use sizeof(LEADCAPTUREINFO).

pfnCaptureCallback

Optional callback function for additional processing.

 

If you do not provide a callback function, use NULL as the value of this parameter.

 

If you do provide a callback function, use the function pointer as the value of this parameter.

 

The callback function must adhere to the function prototype described in CAPTURECALLBACK Function.

pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

 

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID ;*. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

 

If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function allows the user to select an area from the entire screen of the specified type, and then captures that area to a bitmap. The resulting bitmap will contain a region of the specified type, and all image data outside that region will be filled with the specified color in the options structure. The callback can be used to do multiple captures, depending on the options set using L_SetCaptureOption.

If the area is CAPTURE_AREA_POLYGON, a double-click will end the area definition. A right mouse click will delete the last point that was drawn.

If the area is any type other than CAPTURE_AREA_POLYGON, the area definition will be ended and the image captured when the left mouse button is released.

If ALT key is depressed while selecting the area, it will cancel the current capture area selection, but not stop the capture (in other words, the user will be able to start a new capture area draw).

If the cancel or ESC key, defined in LEADCAPTUREOPTION, is pressed during capture area, the entire operation is canceled, and the function will return ERROR_USER_ABORT.

Required DLLs and Libraries

LTSCR

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_SetCaptureOption, L_SetCaptureOptionDlg, CAPTURECALLBACK, L_CaptureAreaOptionDlg, L_StopCapture

Topics:

Screen Capture C DLL Function Groups: Capture Functions

 

Implementing Screen Capture

Example

static L_INT EXT_CALLBACK pfnCaptureCallback (pBITMAPHANDLE    pBitmap,
                                              pLEADCAPTUREINFO pCaptureInfo,
                                              L_VOID         * pUserData)
{
   UNREFERENCED_PARAMETER(pCaptureInfo);
   UNREFERENCED_PARAMETER(pUserData);

   /* save the captured image */
   return(L_SaveBitmap (TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 16\\Images\\Area.bmp"), pBitmap, FILE_BMP, 0, 0, NULL));
}

L_INT CaptureAreaExample(L_VOID)
{
   BITMAPHANDLE          Bitmap;
   LEADCAPTUREAREAOPTION CaptureAreaOption;
   LEADCAPTUREINFO       CaptureInfo;

   memset(&CaptureInfo, 0, sizeof(LEADCAPTUREINFO));
   /* To call the L_CaptureArea, L_GetDefaultAreaOption */
   /* This function gets the default area options.      */
   L_GetDefaultAreaOption(&CaptureAreaOption, sizeof(LEADCAPTUREAREAOPTION));

   /* set the Object Options CaptureType to Free hand.*/
   CaptureAreaOption.uAreaType = CAPTURE_AREA_FREEHAND;
   
   L_INT nRet = L_CaptureArea (&Bitmap,sizeof(BITMAPHANDLE),
                               &CaptureAreaOption, sizeof(LEADCAPTUREAREAOPTION),
                               &CaptureInfo, sizeof(LEADCAPTUREINFO),
                               pfnCaptureCallback, NULL);
   if (Bitmap.Flags.Allocated)
      L_FreeBitmap (&Bitmap);
   return nRet;
}