Creates a Windows device context using this
RasterImage as the display surface.
Syntax
Visual Basic (Declaration) | |
---|
Public Function CreateLeadDC() As IntPtr |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As RasterImage
Dim value As IntPtr
value = instance.CreateLeadDC()
|
C# | |
---|
public IntPtr CreateLeadDC() |
C++/CLI | |
---|
public:
IntPtr CreateLeadDC(); |
Return Value
The Win32 HDC this method creates.
Example
This example draws an ellipse on the image.
Visual Basic | Copy Code |
---|
Public Sub CreateLeadDCExample()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP")
Dim StartGDI As Point = New Point(Convert.ToInt32(image.Width / 8), Convert.ToInt32(image.Height / 8))
Dim EndGDI As Point = New Point(Convert.ToInt32(image.Width \ 2), Convert.ToInt32(image.Height \ 2))
If image.ViewPerspective <> RasterViewPerspective.TopLeft Then
StartGDI = image.PointToImage(RasterViewPerspective.TopLeft, StartGDI)
EndGDI = image.PointToImage(RasterViewPerspective.TopLeft, EndGDI)
End If
Dim hdc As IntPtr = image.CreateLeadDC()
Dim pGraphics As Graphics = Graphics.FromHdc(hdc)
pGraphics.DrawEllipse(New Pen(Color.White), StartGDI.X, StartGDI.Y, EndGDI.X - StartGDI.X, EndGDI.Y - StartGDI.Y)
RasterImage.DeleteLeadDC(hdc)
codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_LEADDC.BMP", RasterImageFormat.Bmp, 0)
image.Dispose()
codecs.Dispose()
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
public void CreateLeadDCExample() { RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP"); Point StartGDI = new Point(Convert.ToInt32(image.Width / 8), Convert.ToInt32(image.Height / 8)); Point EndGDI = new Point(Convert.ToInt32(image.Width / 2), Convert.ToInt32(image.Height / 2)); // Convert the coordinates if necessary. if(image.ViewPerspective != Leadtools.RasterViewPerspective.TopLeft) { StartGDI = image.PointToImage(Leadtools.RasterViewPerspective.TopLeft, StartGDI); EndGDI = image.PointToImage(Leadtools.RasterViewPerspective.TopLeft, EndGDI); } // Create the device context IntPtr hdc = image.CreateLeadDC(); Graphics pGraphics = Graphics.FromHdc(hdc); pGraphics.DrawEllipse(new Pen(Color.White), StartGDI.X, StartGDI.Y, EndGDI.X - StartGDI.X, EndGDI.Y - StartGDI.Y); RasterImage.DeleteLeadDC(hdc); codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1_LEADDC.BMP", RasterImageFormat.Bmp, 0); image.Dispose(); codecs.Dispose(); RasterCodecs.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also