|
I have a form that has various pictureboxes that are populated by the user. Once the form has all the pictureboxes full, the user needs to save the whole form and its contents as a jpg. The only problem is that the only thing that is saved is the picturebox.1.
Case 1
form2.PictureBox1.Image.Save(fs, _
System.Drawing.Imaging.ImageFormat.Jpeg)
I can see that in Case 1 section I am telling the program to save the PictureBox1 in form 2 but I want it to merge all the PictureBoxs in form 2 and save as a jpg. Can anyone tell me where I am going wrong
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif"
saveFileDialog1.Title = "Save an Image File"
saveFileDialog1.ShowDialog()
If saveFileDialog1.FileName <> "" Then
Dim fs As System.IO.FileStream = CType _
(saveFileDialog1.OpenFile(), System.IO.FileStream)
Select Case saveFileDialog1.FilterIndex
Case 1
form2.PictureBox1.Image.Save(fs, _
System.Drawing.Imaging.ImageFormat.Jpeg)
Case 2
Me.Button2.Image.Save(fs, _
System.Drawing.Imaging.ImageFormat.Bmp)
Case 3
Me.Button2.Image.Save(fs, _
System.Drawing.Imaging.ImageFormat.Gif)
End Select
fs.Close()
End If
|
|
|
|
|
tuffhamster wrote: I have a form that has various pictureboxes that are populated by the user. Once the form has all the pictureboxes full, the user needs to save the whole form and its contents as a jpg.
Call the DrawToBitmap[^] method of the form.
|
|
|
|
|
I have used the drawtobitmap as suggested but still only copies the form background. There are about 8 picture boxes in the form but none of these are saved within the jpg. Here is the code.
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim savefiledialog1 As New SaveFileDialog
savefiledialog1.Title = "Render"
savefiledialog1.FileName = "Render Image"
savefiledialog1.Filter = "jpg |*.jpg| png |*.png| bmp |*.bmp| gif |*.gif"
If savefiledialog1.ShowDialog() = DialogResult.OK Then
Dim bmp As New Drawing.Bitmap(Form2.Width, Form2.Height)
Form2.DrawToBitmap(bmp, New Rectangle(0, 0, bmp.Width, bmp.Height))
bmp.Save(savefiledialog1.FileName, Imaging.ImageFormat.Icon)
End If
End Sub
|
|
|
|
|
As should be; that's how the stuff works. If you want a "mashup", you'll have to draw the pictureboxes by hand, on the forms' paint event.
|
|
|
|