Larry Brister
asked on
Change Bitmap background color to white
How can I change the attached code so the bitmap will have a white background?
This draws fine but with a default "grayish" #f5f5f5 background.
This draws fine but with a default "grayish" #f5f5f5 background.
#Region "Variables"
' Variables declaration
Private myImage As Bitmap
Private g As Graphics
Private myBrushes(4) As Brush
#End Region
Private Sub initialiseGraphics()
Try
' Create an in-memory bitmap where you will draw the image.
' The Bitmap is 240 pixels wide and 300 pixels high.
' myImage = New Bitmap(240, 300, PixelFormat.Format32bppRgb)
myImage = New Bitmap(240, 300)
' Get the graphics context for the bitmap.
g = Graphics.FromImage(myImage)
' Create the brushes for drawing
createBrushes()
Catch ex As Exception
Throw ex
End Try
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No problems, split the points any way you see fit.
Dustin
Dustin
Use Graphics.Clear():
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.clear.aspx
"Clears the entire drawing surface and fills it with the specified background color."
So something like:
myImage = New Bitmap(240, 300)
g = Graphics.FromImage(myImage )
g.Clear(Color.White)
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.clear.aspx
"Clears the entire drawing surface and fills it with the specified background color."
So something like:
myImage = New Bitmap(240, 300)
g = Graphics.FromImage(myImage
g.Clear(Color.White)
ASKER
Both Posts were helpful but dusion a little more so.
Any problem with a 300/200 split in dusion's favor?