The AnnPicture Class is available in LEADTOOLS Document and Medical Imaging toolkits.
Defines an annotation picture along with its transparency information.Visual Basic (Declaration) | |
---|---|
<SerializableAttribute()> Public Class AnnPicture Implements ICloneable, IDisposable, ISerializable |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As AnnPicture |
C# | |
---|---|
[SerializableAttribute()] public class AnnPicture : ICloneable, IDisposable, ISerializable |
C++/CLI | |
---|---|
[SerializableAttribute()] public ref class AnnPicture : public ICloneable, IDisposable, ISerializable |
This example creates an image that has a blue ellipse inside a red rectangle.
Visual Basic | Copy Code |
---|---|
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 |
C# | Copy Code |
---|---|
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); } } } |
System.Object
Leadtools.Annotations.AnnPicture
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7