Saving a picturebox control to jpg with VB 2005
-
Hi all, I have written a program that draws graphics to a picturebox control with GDI+ graphics. I want to be able to save the graphics as a jpg file. What I have done is create a temporary bitmap object and using the pictureboxs DrawToBitmap method copying the picturebox to the bitmap. Then I have used the bitmap objects Save method to write the jpg file. When I view the the jpg all I see is black with none of the graphics that are on the picturebox control.
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim bmpMap As New Bitmap(924, 722)
Dim Rect As Rectangle = imgMap.DisplayRectangle
imgMap.DrawToBitmap(bmpMap, Rect)
bmpMap.Save("C:\STARS!\Map.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)End Sub
This code compiles without errors, but the result is not what I expected. Can anyone help please? Thanks in advance Rob.