Results 1 to 2 of 2

Thread: Images in VB

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    45

    Question

    Has anyone any idea of a way to take an image that can be displayed in a standard image control and resize and save it? I'm basically trying to write something that will auto-generate thumbnails of screenshots taking by our testers.

    Can I do this with the built in VB controls, are the any API calls or does anyone know of a custom control that will do this?

    Thanks,

    K

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    You can use SavePicture(Image1.Picture) to do this, I'm not sure it'll work though, I think it will save the picture in it's origional size.

    The Bstway is to use the StreachBlit API
    have 2 picture boxes, one with autosize set to true,
    the other autoredraw set to true.

    Code:
    Public Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
    
    
    
    private Sub MakeThumnail(FromFile as String, ToFile as String)
    
    
    Picture1.Picture = LoadPicture(FromFile")
    
    StretchBlt Picture2.HDC, _
               0,0, _
               Picture2.ScaleX(Picture2.ScaleWidth, Picture2.ScaleMode,vbPixels),Picture2.ScaleY(Picture2.ScaleHeight, Picture2.ScaleMode,vbPixels), _
               Picture1.HDC, _
               0,0, _
               Picture1.ScaleX(Picture1.ScaleWidth, Picture1.ScaleMode,vbPixels),Picture1.ScaleY(Picture1.ScaleHeight, Picture1.ScaleMode,vbPixels), _
               vbSrcCopy
    
    SavePicture Picture1.Image, ToFile
    
    End Sub
    Hope this helps

    [Edited by Sam Finch on 05-04-2000 at 12:16 PM]

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