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
Dim pic As AnnPicture = New AnnPicture(btmp)
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
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
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 |