Background colour of a new Bitmap

  • Thread starter Thread starter Samuel
  • Start date Start date
Can anyone advice how to set the background colour of a new Bitmap

Thank you,
Samuel

I can't think of a real easy way to do this, but one way would be to
use a nested loop with the bitmap's SetPixel method:

Dim bmp As New Bitmap(40, 40)

For x As Integer = 0 To bmp.Width - 1
For y As Integer = 0 To bmp.Height - 1
bmp.SetPixel(x, y, Color.Blue)
Next
Next

There may be a better way, but I can't think of it at the moment.

Thanks,

Seth Rowe
 
I can't think of a real easy way to do this, but one way would be to
use a nested loop with the bitmap's SetPixel method:

Dim bmp As New Bitmap(40, 40)

For x As Integer = 0 To bmp.Width - 1
For y As Integer = 0 To bmp.Height - 1
bmp.SetPixel(x, y, Color.Blue)
Next
Next

There may be a better way, but I can't think of it at the moment.

This might be much faster and easier solution:

Dim bmp As New Drawing.Bitmap(40, 40)
Dim grap As Drawing.Graphics = Drawing.Graphics.FromImage(bmp)
grap.Clear(Drawing.Color.Blue)

-Teemu
 
Thank you for you reply,

I simple use the FillRectangle method of the Graphics object specifying the
colour

Samuel
 
Back
Top