Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleCompose four pictures into a single picture and save the result into a file
DescriptionThis example shows how to compose four pictures into a single picture and save the result into a file in Visual Basic 6.
Keywordscompose, composition, picture, PictureBox, PaintPicture
CategoriesGraphics, Controls
 
When it starts, the program performs some setup including setting the picResult control's AutoRedraw property to True. This doesn't work if AutoRedraw is False.

Then program loads a pictures into the hidden PictureBox named picHidden. It then uses PaintPicture to copy the hidden picture into part of the result PictureBox picResult. It repeats those steps three more times to load each picture and draw it on a new part of picResult.

The program finishes by using SavePicture to save the result into a file.

 
Private Sub Form_Load()
Dim file_path As String

    file_path = App.Path
    If Right$(file_path, 1) <> "\" Then file_path = _
        file_path & "\"

    picResult.Width = ScaleX(2 * 72, vbPixels, vbTwips) + _
        picResult.Width - picResult.ScaleWidth
    picResult.Height = ScaleY(2 * 90, vbPixels, vbTwips) + _
        picResult.Height - picResult.ScaleHeight
    Width = picResult.Width + 2 * picResult.Left + Width - _
        ScaleWidth
    Height = picResult.Height + 2 * picResult.Top + Height _
        - ScaleHeight
    picResult.AutoRedraw = True
    picResult.ScaleMode = vbPixels

    ' Get the pictures.
    picHidden.Picture = LoadPicture(file_path & "ccls.jpg")
    picResult.PaintPicture picHidden.Picture, 0, 0

    picHidden.Picture = LoadPicture(file_path & _
        "offices.jpg")
    picResult.PaintPicture picHidden.Picture, 72, 0

    picHidden.Picture = LoadPicture(file_path & _
        "vb_prog_refs.jpg")
    picResult.PaintPicture picHidden.Picture, 0, 90

    picHidden.Picture = LoadPicture(file_path & "vbgps.jpg")
    picResult.PaintPicture picHidden.Picture, 72, 90

    ' Save the result.
    picResult.Picture = picResult.Image
    SavePicture picResult.Picture, file_path & "4pics.bmp"
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated