L_CreateLeadDC

#include "l_bitmap.h"

L_LTKRN_API L_HDC L_CreateLeadDC(pBitmap)

Provides a powerful set of graphics features by creating a Microsoft Windows device context, using the specified bitmap as the display surface.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the LEAD bitmap handle referencing the image data.

Returns

Value Meaning
>0 Function was successful. The return value is the HDC.
NULL An error occurred.

Comments

This allows you to create an infinite number of drawing capabilities such as paint, erase, color erase and brush, pen, spray gun, flood fill, color tube, text overlay, curve, line, rectangle, polygon, ellipse, freehand shapes, cut and paste, and more.

All Windows GDI functions can be used to draw to the bitmap using the returned HDC. The HDC must be freed with the L_DeleteLeadDC function.

Note: For WIN32 applications, this function ensures that the bitmap's view perspective is BOTTOM_LEFT, flipping the bitmap if necessary. This can affect functions that use bitmap coordinates. For more information, refer to Accounting for View Perspective.

If a region is defined for the bitmap, GDI functions act only on the region, not on the entire bitmap.

The DIB driver supports only 1, 4, 8, 16, 24 and 32 bit images. If you are using an image that has some other number of bits per pixel, you must use L_ColorResBitmap to change the image to a bits per pixel value supported by the DIB driver.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

For complete sample code, refer to the DRAW example. This example uses GDI functions to draw an ellipse on the bitmap.

L_INT CreateLeadDCExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the image */ 
   HDC          LeadDC; /* Device context for the LEAD bitmap */ 
   L_INT        StartGDIX, StartGDIY, EndGDIX, EndGDIY; /* Drawing coordinates */ 
 
   /* Load a bitmap at its own bits per pixel */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Create the device context */ 
   LeadDC = L_CreateLeadDC(&LeadBitmap); 
   /* Set the drawing coordinates in the top left quadrant of the bitmap */ 
   StartGDIX = BITMAPWIDTH(&LeadBitmap) / 8; 
   EndGDIX = BITMAPWIDTH(&LeadBitmap) / 2; 
   StartGDIY = BITMAPHEIGHT(&LeadBitmap) / 8; 
   EndGDIY = BITMAPHEIGHT(&LeadBitmap) / 2; 
   /* Convert the coordinates if necessary */ 
   if (LeadBitmap.ViewPerspective != TOP_LEFT) 
   { 
      L_PointToBitmap ( &LeadBitmap, TOP_LEFT, & StartGDIX, & StartGDIY ); 
      L_PointToBitmap ( &LeadBitmap, TOP_LEFT, & EndGDIX, & EndGDIY ); 
   } 
   /* Draw the ellipse */ 
   SelectObject(LeadDC, GetStockObject(WHITE_PEN)); 
   SelectObject(LeadDC, GetStockObject(NULL_BRUSH)); 
   SetROP2(LeadDC, R2_NOT); 
   Ellipse(LeadDC, StartGDIX, StartGDIY, EndGDIX, EndGDIY); 
   /* Delete the device context */ 
   L_DeleteLeadDC(LeadDC); 
   L_FreeBitmap(&LeadBitmap); 
   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