Image of a picturebox painted manualy

  • Thread starter Thread starter Crirus
  • Start date Start date
C

Crirus

hello
I have apicturebox painted in it's paint event.
I need a way to save the image created. Image obj of my picturebox is
Nothing. How to output to a jpg my image?

Crirus
 
Crirus said:
hello
I have apicturebox painted in it's paint event.
I need a way to save the image created. Image obj of my picturebox
is Nothing. How to output to a jpg my image?

Paint on a Bitmap instead of directly painting on the picturebox. In the
picbox' paint event draw the bitmap on the picturebox. The Bitmap can be
save to a JPG:

bmp.Save("myfile.jpg", Imaging.ImageFormat.Jpeg)
 
Crirus said:
I have apicturebox painted in it's paint event.
I need a way to save the image created. Image obj of my picturebox is
Nothing. How to output to a jpg my image?

Draw the image onto a bitmap instead. Create a new 'Bitmap' object with
the preferred size ('Dim b As New Bitmap(...)'), then obtain a
'Graphics' handle ('Graphics.FromImage') and draw onto the bitmap. Then
you can draw the bitmap to the picturebox in its 'Paint' event handler.
You can save the image by calling 'b''s 'Save' method. Don't forget to
call the 'Graphics'' object's 'Dispose' method after you finish using it.
 
Back
Top