help needed pls
-
I am opening an image on a picturebox using: pictureBox1.Image = new Bitmap(openFileDialog1.FileName); then i am drawing some lines and curves on the picturebox using the event: private void pictureBox1_Paint(object sender, PaintEventArgs e) such that the painted lines and curves are drawn over the image opened on the picturebox. Now, I want to save the image containing the original image and the lines or curves drawn on the picturebox as one image. Please tell how do i do that........ Thank You Umang Jain
-
I am opening an image on a picturebox using: pictureBox1.Image = new Bitmap(openFileDialog1.FileName); then i am drawing some lines and curves on the picturebox using the event: private void pictureBox1_Paint(object sender, PaintEventArgs e) such that the painted lines and curves are drawn over the image opened on the picturebox. Now, I want to save the image containing the original image and the lines or curves drawn on the picturebox as one image. Please tell how do i do that........ Thank You Umang Jain
Well, the first problem you have is that you're not drawing the lines on the image. You're drawing on the surface of the picturebox control. So, everything you see appears as though you're drawing on the image when you're not. You have to draw the lines on the bitmap you created, then you can save the changes back to the original files. Speaking of that, you have a second problem. When you created a Bitmap object using the overload that you did, the file gets locked for the life of that Bitmap object. This means you can't save any changes back to the original file. To get around this, you have to create a FileStream object, opening that image file, then create the Bitmap from that Stream, then closing the file. This will prevent the file from being locked so you can save the changes back to it.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Well, the first problem you have is that you're not drawing the lines on the image. You're drawing on the surface of the picturebox control. So, everything you see appears as though you're drawing on the image when you're not. You have to draw the lines on the bitmap you created, then you can save the changes back to the original files. Speaking of that, you have a second problem. When you created a Bitmap object using the overload that you did, the file gets locked for the life of that Bitmap object. This means you can't save any changes back to the original file. To get around this, you have to create a FileStream object, opening that image file, then create the Bitmap from that Stream, then closing the file. This will prevent the file from being locked so you can save the changes back to it.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Hi, Graphics.FromImage() is what you want. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Fixturized forever. :confused:
-
Well, the first problem you have is that you're not drawing the lines on the image. You're drawing on the surface of the picturebox control. So, everything you see appears as though you're drawing on the image when you're not. You have to draw the lines on the bitmap you created, then you can save the changes back to the original files. Speaking of that, you have a second problem. When you created a Bitmap object using the overload that you did, the file gets locked for the life of that Bitmap object. This means you can't save any changes back to the original file. To get around this, you have to create a FileStream object, opening that image file, then create the Bitmap from that Stream, then closing the file. This will prevent the file from being locked so you can save the changes back to it.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008