Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

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.
#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

Open in new window

SOLUTION
Avatar of princeatapi
princeatapi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Dustin Hopkins
Dustin Hopkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

Hey guys,
  Both Posts were helpful but dusion a little more so.

Any problem with a 300/200 split in dusion's favor?
No problems, split the points any way you see fit.

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)