Results 1 to 5 of 5

Thread: VB: SavePicture PictureBox -[RESOLVED]-

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    23

    Resolved VB: SavePicture PictureBox -[RESOLVED]-

    Hi

    I am trying to save a picturebox into a ".bmp" file afterdrawing something on the picturebox, but it is not working for me. what I am getting is, a blank bitmap file with the same color as the background color of the picturebox, I am giving the code what I am doing to save the drawing

    '***********************************************
    Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
    Private Declare Function StretchBlt Lib "gdi32" (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 Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Picture1.PSet (X, Y)
    End Sub

    Private Sub Command1_Click()
    StretchBlt Picture2.hdc, 0, 0, 100, 100, Picture1.hdc, 0, 0, 100, 100, SRCCOPY
    End Sub

    Private Sub Command2_Click()
    SavePicture Picture2.Image, "c:\tp.bmp"
    MsgBox ("Done")
    End Sub
    '***********************************************

    can anyone help me to solve my problem.

    kajol
    Last edited by Electroman; Dec 9th, 2004 at 03:55 AM. Reason: Added Language to title & Added Resolved to title.

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Re: SavePicture PictureBox

    Is AutoReDraw set to True?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    23

    Thumbs up Re: VB: SavePicture PictureBox

    Thanks for your tip, the AutoRedraw was not set to true, now it is working. Thanks again

    Kajol

  4. #4
    New Member
    Join Date
    May 2012
    Posts
    1

    Re: VB: SavePicture PictureBox -[RESOLVED]-

    Dear kajol,

    what you mean by "Const SRCCOPY = &HCC0020 ' (DWORD) dest = source"?

    I try to do the same thing as you but I don't understand the coding. Please help me

  5. #5
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VB: SavePicture PictureBox -[RESOLVED]-

    Quote Originally Posted by peacemakerxx View Post
    Dear kajol,

    what you mean by "Const SRCCOPY = &HCC0020 ' (DWORD) dest = source"?

    I try to do the same thing as you but I don't understand the coding. Please help me
    Not sure if you realize it but you opened a post from 8 years ago.

    Bitblt, Stretchblt, and Transparentblt are APIs which are graphical functions used from the gdi32 dll file found in your windows folder. These use hexadecimal tags for souce and destination of where to blit the image. In this case its stretchblt and is using SRCCOPY, which means its getting the image info from its source handle (pointer, or hDC) such as a picturebox, and copies it. Then savepicture saves it to file.

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