)Bitmap bitmap = (Bitmap)pictureBox.Image;
for (int x = 0; x < bitmap.Width; x += 1) // horizontal lines
{
bitmap.SetPixel(x, 0, Color.Red); // top line
bitmap.SetPixel(x, bitmap.Height - 1, Color.Red); // bottom line
}
for (int y = 0; y < bitmap.Height; y += 1) // vertical lines
{
bitmap.SetPixel(0, y, Color.Red); // left line
bitmap.SetPixel(bitmap.Width - 1, y, Color.Red); // right line
}
pictureBox.Image = (Image)bitmap;
Dim bitmap As Bitmap = DirectCast(pictureBox.Image, Bitmap)
For x As Integer = 0 To bitmap.Width - 1
' horizontal lines
bitmap.SetPixel(x, 0, Color.Red)
' top line
' bottom line
bitmap.SetPixel(x, bitmap.Height - 1, Color.Red)
Next
For y As Integer = 0 To bitmap.Height - 1
' vertical lines
bitmap.SetPixel(0, y, Color.Red)
' left line
' right line
bitmap.SetPixel(bitmap.Width - 1, y, Color.Red)
Next
pictureBox.Image = DirectCast(bitmap, Image)