L_ScreenCaptureBitmap

#include "l_bitmap.h"

L_LTDIS_API L_INT L_ScreenCaptureBitmap(hDC, pBitmap, uStructSize, pRect)

Loads a bitmap from the specified rectangle within a device context.

Parameters

L_HDC hDC

Handle to the source device. The mapping mode of the device context must be MM_TEXT.

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the target bitmap.

L_UINT uStructSize

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

L_RECT* pRect

The windows RECT structure that specifies the portion of the device context to capture.

Returns

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

Comments

Normally, this function is used for capturing images displayed on the screen. The resulting bitmap will have the same bits per pixel as the display device.

Before calling this function, you must declare a bitmap handle, but do not allocate the bitmap. This function allocates the bitmap.

LEAD provides several other screen capture functions for increased versatility in capturing images from the screen. For more information, refer to the LEADTOOLS Screen Capture C API help.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Topics

Example

For complete sample code, refer to the FRAME.C module of the DEMO example. This example captures the whole screen.

L_INT ScreenCaptureBitmapExample(L_HWND  hWnd,pBITMAPHANDLE   pBitmap) 
{ 
   L_INT nRet; 
   RECT ScreenRect; /* Rectangle for the whole screen */ 
   HDC   ScreenDC;  /* Device context for the whole screen */ 
 
   /* Get the device context for the whole screen */ 
   ScreenDC = GetDC (NULL); 
 
   /* Get the rectangle for the whole screen */ 
   SetRect (&ScreenRect, 0, 0, GetDeviceCaps (ScreenDC, HORZRES),  
      GetDeviceCaps (ScreenDC, VERTRES)); 
 
   /* Capture the whole screen */ 
   if(pBitmap->Flags.Allocated) 
      L_FreeBitmap(pBitmap); 
   nRet = L_ScreenCaptureBitmap (ScreenDC, pBitmap, sizeof(BITMAPHANDLE), &ScreenRect); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* The palette might have changed */ 
   SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L); 
 
   /* Release the device context */ 
   ReleaseDC (NULL, ScreenDC); 
 
   return SUCCESS; 
} 

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help