Creates a Windows GDI device context using this Leadtools.RasterImage as the display surface.
public static IntPtr CreateLeadDC(
RasterImage image
)
Public Shared Function CreateLeadDC( _
ByVal image As Leadtools.RasterImage _
) As IntPtr
public:
static IntPtr CreateLeadDC(
Leadtools.RasterImage^ image
)
image
The source image.
The Windows HDC object this method creates.
This method 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 image using the returned HDC. The HDC must be freed with the DeleteLeadDC method.
If a region is defined for the image, GDI functions act only on the region, not on the entire image.
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 Leadtools.ImageProcessing.ColorResolutionCommand to change the image to a bits per pixel value supported by the DIB driver.
For more information refer to RasterImage and GDI/GDI+.
For more information, refer to Introduction to Image Processing With LEADTOOLS.
This example draws an ellipse on a raster image.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Drawing;
using Leadtools.ImageProcessing;
public void CreateLeadDCExample()
{
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"));
LeadPoint point1 = new LeadPoint(image.Width / 8, image.Height / 8);
LeadPoint point2 = new LeadPoint(image.Width / 2, image.Height / 2);
// Convert the coordinates if necessary.
if (image.ViewPerspective != RasterViewPerspective.TopLeft)
{
point1 = image.PointToImage(RasterViewPerspective.TopLeft, point1);
point2 = image.PointToImage(RasterViewPerspective.TopLeft, point2);
}
// Create the device context
IntPtr hdc = RasterImagePainter.CreateLeadDC(image);
using (Graphics g = Graphics.FromHdc(hdc))
{
g.DrawEllipse(new Pen(Color.White), point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y);
}
RasterImagePainter.DeleteLeadDC(hdc);
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Imahe1_CreateLeadDC.bmp"), RasterImageFormat.Bmp, 0);
image.Dispose();
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Drawing
Imports Leadtools.ImageProcessing
Public Sub CreateLeadDCExample()
Dim codecs As New RasterCodecs()
Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"))
Dim point1 As New LeadPoint(image.Width \ 8, image.Height \ 8)
Dim point2 As New LeadPoint(image.Width \ 2, image.Height \ 2)
' Convert the coordinates if necessary.
If image.ViewPerspective <> RasterViewPerspective.TopLeft Then
point1 = image.PointToImage(RasterViewPerspective.TopLeft, point1)
point2 = image.PointToImage(RasterViewPerspective.TopLeft, point2)
End If
' Create the device context
Dim hdc As IntPtr = RasterImagePainter.CreateLeadDC(image)
Using g As Graphics = Graphics.FromHdc(hdc)
g.DrawEllipse(New Pen(Color.White), point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y)
End Using
RasterImagePainter.DeleteLeadDC(hdc)
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Imahe1_CreateLeadDC.bmp"), RasterImageFormat.Bmp, 0)
image.Dispose()
codecs.Dispose()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.