0

I have a picturebox that upon request, I save the current display to a bitmap.

My question is, how do I then load that same bitmap to the picturebox?

Thanks.

EDIT:

The only relevant code is: pictureBox1.DrawToBitmap(test1,pictureBox1.ClientRectangle);

The picture box contains graphics that I have written 'freehand' using the mouse. So you can use the mouse to write directly onto the screen when the left mouse is pressed.

4
  • Wait, your picturebox displays a bitmap, upon request saves it to disk, and you want to display to bitmap that was saved to disk? Are you clearing the picturebox when you save it? Commented Nov 11, 2010 at 14:17
  • Where do you store this bitmap? What are you doing with it? Some relevant code might help us understand better.. Commented Nov 11, 2010 at 14:20
  • No...at first it is a standard piturebox, and I then save it's contents to a bitmap. Commented Nov 11, 2010 at 14:21
  • code added..thanks. The bitmap for this purpose is just stored in memory...called test1 in my code above. Commented Nov 11, 2010 at 14:25

2 Answers 2

2

You can assign any image to the picture box that you want during run-time. Just set the Image property of the picture box to the picture you want to be displayed.

For example, to display an image in a picture box from a file on your hard drive, you could use something like:

myPicBox.Image = Image.FromFile("C:\savedimage.bmp");

Or, your edit suggests that you have a bitmap object in memory that you want to display in the picture box. In that case, it's a simple matter of assigning that bitmap object to the Image property:

myPicBox.Image = test1;  //(where test1 is your bitmap object in memory)


Edit: Just in case you want to save the bitmap object that you created in memory to disk so that you can reload and use it later, check out the Save method of the Bitmap object:

test1.Save("C:\savedimage.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
Sign up to request clarification or add additional context in comments.

Comments

0

If I'm not mistaken, the picturebox should have an Image property that you can simply use to assign the Bitmap to.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.