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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Remove Excel Background Colours 1
Use of resource images 3
Compressed Bitmap 3
Read Part of a Bitmap 2
Setting Background Colour to a Label 2
Refresh is so slow... 5
Creating icons 1
Overlay bitmap on icon 2

Back
Top