Results 1 to 5 of 5

Thread: Saving picture with text overlaid

  1. #1

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243

    Question

    Hi,
    Is there a way to save a picture with text overlaid on top of it (perhaps using SavePicture)?
    For Example...If I load a photo in a picture box which has a label in the corner, and in that label I display a bit of text about the photo, can I then save the photo with the text on top of it as a bitmap? (at the moment it just keeps saving the photo and not display the text!)

    Any help would be appreciated

    Cheers, Shaun.

  2. #2
    Guest
    First, you must draw it's Image on to it's picture. Then you can save it.
    Code:
    Private Sub Command1_Click()
    
        Picture1.Picture = Picture1.Image
        SavePicture Picture1.Picture, "C:\Windows\Desktop\Testing.bmp"
        
    End Sub

  3. #3

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi Megatron,
    Sorry, but I still cant get it to work. Are there any properties that I have to set either for the picture box or the label? I currently have the labels background set to transparent to show the picture underneath the text.

    Cheers,
    Shaun

  4. #4
    Guest
    If you use the Print statement instead of a Label, the above example will work, however, if you want to stick with the Label, use the BitBlt API.

    Make a Form and add 2 PictureBoxes, a CommandButtons and a Label. Make sure that there is a Picture loaded into Picture1 and make sure that the Label in/on top of it.

    Code:
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    
    Private Sub Command1_Click()
        'Copy the Image to Form2
        BitBlt Picture2.hDC, 0, 0, Picture1.Width, Picture1.Height, Picture1.hDC, 0, 0, vbSrcCopy
        'Transfer the Image and save the Picture
        Picture2.Picture = Picture2.Image
        SavePicture Picture2.Picture, "C:\Windows\Desktop\Mybitmap.bmp"
    End Sub
    
    Private Sub Form_Load()
        Picture2.AutoRedraw = True
    End Sub

  5. #5

    Thread Starter
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Cheers Megatron it works great now although I nearly posted another reply saying it didn't!! (realised I had to switch off autoredraw on picture1!)

    Thanks

    Shaun

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width