By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,652 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

Save/Open Drawn Image

P: n/a
Hi,

I have a picturebox on a form that I am able to draw on (similar to ms
paint). My declarations are as follows:

--------------------------------------------------------------------------------
'Globals
Dim b As Drawing.Bitmap ' Eventually initialzed to b = New
Drawing.Bitmap(Me.Width, Me.Height)
Dim g As Drawing.Graphics
Dim pen As New Drawing.Pen(System.Drawing.Color.DarkBlue, 2)
Dim aBgColor As Drawing.Color = Drawing.Color.White

--------------------------------------------------------------------------------

I can sucessfully save the Image using the following code:

--------------------------------------------------------------------------------
Public Sub SaveSigAsImage(ByVal Path As String)
b.Save(Path)
End Sub

--------------------------------------------------------------------------------

I can sucessfully open the image right when the program starts with
the following code:

--------------------------------------------------------------------------------
Public Sub OpenSigImage(ByVal Path As String)
picSig.Image = Image.FromFile(Path)
b = picSig.Image
End Sub

--------------------------------------------------------------------------------

The problem is, when I open an image, modify it and save it, an
exception is thrown: An unhandled exception of type
'System.NullReferenceException' occurred in WindowsApplication3.exe

Additional information: Object reference not set to an instance of an
object.

The exception is thrown on the line b = picSig.Image in OpenSigImage.

How do I initialize b when opening the picture?

Thank you.
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.