Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_CreateLeadDC

Show in webframe

#include "l_bitmap.h"

L_LTKRN_API L_HDC L_CreateLeadDC(pBitmap)

pBITMAPHANDLE pBitmap;

/* pointer to the LEAD bitmap handle */

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

Parameter

Description

pBitmap

Pointer to the LEAD bitmap handle referencing the image data.

Returns

>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 and 24 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

LTKRN

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

Platforms

Win32, x64.

See Also

Functions:

L_DeleteLeadDC

Topics:

Processing an Image

 

Raster Image Functions: Processing an Image

Example

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

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


 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; 
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.