Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class DrawImageIndirectly
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Private Sub Form1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Me.Paint
Dim x As Single
Dim y As Single
Dim xCenter As Single
Dim yCenter As Single
Dim angle As Single
Dim radians As Single
Dim workImage As Bitmap
Dim canvas As Graphics
workImage = New Bitmap(Me.Size.Width, Me.Size.Height,e.Graphics)
canvas = Graphics.FromImage(workImage)
For angle = 0 To 360 Step 2
radians = angle * Math.PI / 180
x = 500 * Math.Cos(radians)
y = 500 * Math.Sin(radians)
yCenter = Me.ClientSize.Height / 2
xCenter = Me.ClientSize.Width * 10 / 21
canvas.DrawLine(Pens.Black, xCenter, yCenter, xCenter + x, yCenter + y)
xCenter = Me.ClientSize.Width * 11 / 21
canvas.DrawLine(Pens.Black, xCenter, yCenter, xCenter + x, yCenter + y)
Next angle
e.Graphics.DrawImage(workImage, 0, 0)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Me.Invalidate()
End Sub
End Class
_
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
_
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
_
Private Sub InitializeComponent()
Me.SuspendLayout()
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(430, 419)
Me.DoubleBuffered = True
Me.Name = "Form1"
Me.Text = "Creating a Bitmap"
Me.ResumeLayout(False)
End Sub
End Class