Leadtools.Annotations Namespace : AnnPicture Class |
[SerializableAttribute()] public class AnnPicture : System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
'Declaration <SerializableAttribute()> Public Class AnnPicture Implements System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
'Usage Dim instance As AnnPicture
public sealed class AnnPicture : System.ICloneable, IClosable //In WinRT the IDisposable interface is replaced by IClosable, ~Remove~
function Leadtools.Annotations.AnnPicture()
[SerializableAttribute()] public ref class AnnPicture : public System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
Private Sub AnnPicture_AnnPicture(ByVal g As Graphics) Dim btmp As Bitmap = New Bitmap(100, 100, PixelFormat.Format32bppArgb) Try Dim graphicsImage As Graphics = Graphics.FromImage(btmp) Try graphicsImage.FillRectangle(Brushes.Red, New Rectangle(0, 0, 100, 100)) graphicsImage.FillEllipse(Brushes.Blue, New Rectangle(0, 0, 100, 100)) graphicsImage.Dispose() Finally CType(graphicsImage, IDisposable).Dispose() End Try ' initialize a new AnnPicture class for this image Dim pic As AnnPicture = New AnnPicture(btmp) ' draw the picture with no transparency Dim rc As Rectangle = New Rectangle(10, 10, pic.Image.Width, pic.Image.Height) Dim ia As ImageAttributes = pic.ImageAttributes If Not ia Is Nothing Then g.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia) ia.Dispose() Else If rc.Width > 1 AndAlso rc.Height > 1 Then g.DrawImage(pic.Image, rc) End If End If ' draw the picture without the ellipse (make transparent color = blue) rc.Offset(0, pic.Image.Height + 10) pic.TransparentMode = AnnPictureTransparentMode.UseColor pic.TransparentColor = Color.Blue ia = pic.ImageAttributes If Not ia Is Nothing Then g.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia) ia.Dispose() Else If rc.Width > 1 AndAlso rc.Height > 1 Then g.DrawImage(pic.Image, rc) End If End If ' draw the picture without the rectangle (use the top left pixel as the transparent color) rc.Offset(0, pic.Image.Height + 10) pic.TransparentMode = AnnPictureTransparentMode.TopLeftPixel ia = pic.ImageAttributes If Not ia Is Nothing Then g.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia) ia.Dispose() Else If rc.Width > 1 AndAlso rc.Height > 1 Then g.DrawImage(pic.Image, rc) End If End If Finally CType(btmp, IDisposable).Dispose() End Try End Sub
private void AnnPicture_AnnPicture(Graphics graphics) { using(Bitmap btmp = new Bitmap(100, 100, PixelFormat.Format32bppArgb)) { using(Graphics graphicsImage = Graphics.FromImage(btmp)) { graphicsImage.FillRectangle(Brushes.Red, new Rectangle(0, 0, 100, 100)); graphicsImage.FillEllipse(Brushes.Blue, new Rectangle(0, 0, 100, 100)); graphicsImage.Dispose(); } // initialize a new AnnPicture class for this image AnnPicture pic = new AnnPicture(btmp); // draw the picture with no transparency Rectangle rc = new Rectangle(10, 10, pic.Image.Width, pic.Image.Height); ImageAttributes ia = pic.ImageAttributes; if(ia != null) { graphics.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia); ia.Dispose(); } else { if(rc.Width > 1 && rc.Height > 1) graphics.DrawImage(pic.Image, rc); } // draw the picture without the ellipse (make transparent color = blue) rc.Offset(0, pic.Image.Height + 10); pic.TransparentMode = AnnPictureTransparentMode.UseColor; pic.TransparentColor = Color.Blue; ia = pic.ImageAttributes; if(ia != null) { graphics.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia); ia.Dispose(); } else { if(rc.Width > 1 && rc.Height > 1) graphics.DrawImage(pic.Image, rc); } // draw the picture without the rectangle (use the top left pixel as the transparent color) rc.Offset(0, pic.Image.Height + 10); pic.TransparentMode = AnnPictureTransparentMode.TopLeftPixel; ia = pic.ImageAttributes; if(ia != null) { graphics.DrawImage(pic.Image, rc, 0, 0, pic.Image.Width, pic.Image.Height, GraphicsUnit.Pixel, ia); ia.Dispose(); } else { if(rc.Width > 1 && rc.Height > 1) graphics.DrawImage(pic.Image, rc); } } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2