Saving images as .jpg, .png, .gif, etc. from within VB is possible with GDI+, but since GDI+ is a technology that came around after VB6, you either have to upgrade to .NET (which I'm avoiding ATM), or get something which will allow you to access the GDI+ library.
You're in luck when it comes to the latter option. At
vbAccelerator there is a project - still in development, unfortunately, but read on - which exposes the GDI+ library to VB6 (and likely VB5). The most important part is the
GDI+ type library (which is fully functional and not in development). This gives you direct access to the GDI+ API. However, since any API is hard to work with in VB, there is also a
GDI+ wrapper DLL (the part which is in development) designed to abstract all of the API stuff with VB classes, objects, methods, and properties. So far, image and bitmap support are complete. For more details, see the links.
As to drawing multiple images in the same PictureBox, here's where you would use the PaintPicture method of the PictureBox. Also, just so you know, Forms also have the PaintPicture method.
Let's say you use your current set-up, and you only want to make everything into a single image during the save process. You could in fact use this same code if you were to allow the user to move the PictureBoxes around on the form into whatever position pleases them most. The code is deliberately designed to work no matter how many PictureBoxes you have on the form - just be sure to set their Tag properties to "Collage" before you run this Sub. The Sub uses a hidden PictureBox control large enough to hold everything you want to save (pbxHiddenCollage), so don't forget to create that, too.
Public Sub CombineCollage()
' This array is needed because of the way the ZOrder works.
Dim colPbx() As PictureBox
ReDim colPbx(0)
' Common Dialog to let the user pick a filename for saving.
cdlImage.DefaultExt = ".bmp"
cdlImage.DialogTitle = "Save Collage to an Image"
cdlImage.Filter = "Bitmap File (*.bmp)|*.bmp"
' CancelError is set to True. I always do this.
On Error GoTo SaveImageCancelled
cdlImage.ShowSave
On Error GoTo 0
' Get the hidden PictureBox set up to create the combined image.
pbxHiddenCollage.AutoRedraw = True
pbxHiddenCollage.Cls
' Find every PictureBox on the form whose Tag is "Collage".
For Each ctlObj In Me.Controls
If ((TypeOf ctlObj Is PictureBox)) And ctlObj.Tag = "Collage" Then
ReDim Preserve colPbx(UBound(colPbx) + 1)
Set colPbx(UBound(colPbx)) = ctlObj
End If
Next
' Draw the combined image on the hidden PictureBox.
For countVar = UBound(colPbx) To 1 Step -1
pbxHiddenCollage.PaintPicture colPbx(countVar).Image, _
colPbx(countVar).Left, colPbx(countVar).Top, _
colPbx(countVar).Width, colPbx(countVar).Height, _
0, 0, colPbx(countVar).Width, colPbx(countVar).Height
Next
' Here's where you save to .bmp
SavePicture pbxHiddenCollage.Image, cdlImage.FileName
' Be careful not to execute the error handler!
Exit Sub
SaveImageCancelled: ' Error handler - the user pressed Cancel
On Error GoTo 0
Exit Sub ' Makes adding new error handlers easier.
End Sub
Hope this helps!
- Sendoshin