Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.5.2
|
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
[SerializableAttribute()] public ref class AnnPicture : public System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
This example creates an image that has a blue ellipse inside a red rectangle.
Imports Leadtools Imports Leadtools.Annotations Imports Leadtools.Codecs Imports Leadtools.WinForms 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
using Leadtools; using Leadtools.Annotations; using Leadtools.Codecs; using Leadtools.WinForms; 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); } } }