' Get the drawing area size.
wid = PictureBox1.ClientRectangle.Width
hgt = PictureBox1.ClientRectangle.Height
' Allocate the form's drawing buffer.
bm = New Bitmap(wid, hgt)
' Get a new color.
If m_UseRed Then
clr = Color.Blue
Else
clr = Color.Red
End If
m_UseRed = Not m_UseRed
' Draw the picture's pixels.
For Y = 1 To hgt - 1
For X = 1 To wid - 1
If (X \ 20) Mod 2 = (Y \ 20) Mod 2 Then
bm.SetPixel(X, Y, Color.Black)
Else
bm.SetPixel(X, Y, clr)
End If
Next X
Next Y
' Display the image.
PictureBox1.Image = bm
|