Dim gfx As System.Drawing.Graphics
gfx = System.Drawing.Graphics.FromImage(m_backgrourdBitmap)
gfx.Clear(System.Drawing.Color.White)
'Рисуем текст черным
Dim myBrush As System.Drawing.Brush
myBrush = New System.Drawing.SolidBrush( _
System.Drawing.Color.Black)
Dim у As Integer
For у = 0 To bitmap_dy Step 15
gfx.DrawString("I am the BACKGROUND IMAGE...hello", Me.Font, myBrush, 0, y)
Next
'Очистить
myBrush.Dispose
gfx.Dispose
End Sub
'-------------------------------------------------
'Создает и прорисовывает изображение заднего плана
'-------------------------------------------------
Private m_foregroundBitmap As System.Drawing.Bitmap
Sub CreateForeground
If (m_foregroundBitmap Is Nothing) Then
m_foregroundBitmap = New Bitmap(bitmap_dx, bitmap_dy)
End If
'Делаем всю битовую карту синей
Dim gfx As System.Drawing.Graphics
gfx = System.Drawing.Graphics.FromImage(m_foregroundBitmap)
gfx.Clear(System.Drawing.Color.Blue)
'Рисуем несколько фигур желтым
Dim yellowBrush As System.Drawing.Brush
yellowBrush = New System.Drawing.SolidBrush( _
System.Drawing.Color.Yellow)
gfx.FillEllipse(yellowBrush, 130, 4, 40, 70)
gfx.FillRectangle(yellowBrush, 5, 20, 110, 30)
gfx.FillEllipse(yellowBrush, 60, 75, 130, 20)
'Очистить
yellowBrush.Dispose
gfx.Dispose
End Sub
'-----------------------------------------------------------------
'Устанавливает размеры и местоположение PictureBox с левой стороны
'-----------------------------------------------------------------
Private Sub SetPictureBoxDimensions
PictureBox1.Width = bitmap_dx
PictureBox1.Height = bitmap_dy
PictureBox1.Left = 20
End Sub
'---------------------------------------------------------------------
'ОБРАБОТЧИК СОБЫТИЙ: Отобразить изображение ЗАДНЕГО ПЛАНА в PictureBox
'---------------------------------------------------------------------
Private Sub buttonDrawBackground_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles buttonDrawBackground.Click
SetPictureBoxDimensions
CreateBackground
PictureBox1.Image = m_backgroundBitmap
End Sub
'-----------------------------------------------------------------------
'ОБРАБОТЧИК СОБЫТИЙ: Отобразить изображение ПЕРЕДНЕГО ПЛАНА в PictureBox
'-----------------------------------------------------------------------
Private Sub buttonDrawForeground_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles buttonDrawForeground.Click
SetPictureBoxDimensions
CreateForeground
PictureBox1.Image = m_foregroundBitmap
End Sub
'-----------------------------------------------------------------------