' Add references to:
' System.Drawing.dll
' Microsoft.VisualBasic.Compatibility.dll
'
' Register for COM Interop:
' Select Project\Properties.
' Open the Configuration Properties folder.
' Click the Build tab.
' Check "Register for COM Interop"
Imports System.Runtime.InteropServices
Imports System.Drawing
<ClassInterface(ClassInterfaceType.AutoDual)> _
Public Class PictureMaker
' Draw a picture.
Public Function MakePicture() As Object
Dim bm As New Bitmap(100, 100)
Dim gr As Graphics = Graphics.FromImage(bm)
gr.FillEllipse(Brushes.LightYellow, 1, 1, 98, 98)
Dim face_pen As New Pen(Color.Black, 2)
gr.DrawEllipse(face_pen, 1, 1, 98, 98)
face_pen.Dispose()
Dim smile_pen As New Pen(Color.Red, 3)
gr.DrawArc(smile_pen, 20, 20, 60, 60, 0, 180)
smile_pen.Dispose()
gr.FillEllipse(Brushes.White, 25, 25, 10, 20)
gr.DrawEllipse(Pens.Black, 25, 25, 10, 20)
gr.FillEllipse(Brushes.Black, 28, 28, 7, 14)
gr.FillEllipse(Brushes.White, 65, 25, 10, 20)
gr.DrawEllipse(Pens.Black, 65, 25, 10, 20)
gr.FillEllipse(Brushes.Black, 68, 28, 7, 14)
gr.FillEllipse(Brushes.Orange, 40, 40, 20, 30)
Dim nose_pen As New Pen(Color.DarkGreen, 2)
gr.DrawEllipse(nose_pen, 40, 40, 20, 30)
nose_pen.Dispose()
gr.Dispose()
Return Compatibility.VB6.ImageToIPictureDisp(bm)
End Function
End Class
|