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
Re: SavePicture PictureBox
Is AutoReDraw set to True?
Re: VB: SavePicture PictureBox
Thanks for your tip, the AutoRedraw was not set to true, now it is working. Thanks again
Kajol
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
Re: VB: SavePicture PictureBox -[RESOLVED]-
Quote:
Originally Posted by
peacemakerxx
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.