Link to home
Start Free TrialLog in
Avatar of crazyman
crazymanFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Save BitBlt image

Can someone tell me how to save an image from a picture box that i have loaded into it using bitblt,i then need to UDP the data to another application which will then load up the pictuure,providing a screen shot of the clients computer,so i also need to know how so read and write files using the binary method as this never seems to work for me even though i have no problems with input and append.
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You also have to set the AutoRedraw property of the picture box to True.
Avatar of crazyman

ASKER

That works great but how do i then break down the file and send it using UDP?
I can never seem to get the binary method to work.
Please post a snippet of the code you are using to send and receive the file.
This is what i was using but i seem to have solved the binary dillemma now so thanks for your help.



Private Sub CmdScreenShot_Click()
Dim wScreen As Long
Dim hScreen As Long
Dim w As Long
Dim h As Long
Dim a As Long
Dim intFile As Integer
Dim strFileLocation As String
Dim clpData As Clipboard
Dim bData() As Variant
    PicScreen.AutoRedraw = True
    strFileLocation = app.path & "\Pic.bmp"
    PicScreen.Cls
    wScreen = Screen.Width \ Screen.TwipsPerPixelX
    hScreen = Screen.Height \ Screen.TwipsPerPixelY
    Picture1.ScaleMode = vbPixels
    w = Picture1.ScaleWidth
    h = Picture1.ScaleHeight
    hdcScreen = GetDC(0)
     StretchBlt PicScreen.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy
    PicScreen.Picture = PicScreen.Image
    SavePicture PicScreen.Picture, strFileLocation
    PicScreen.AutoRedraw = False
    intFile = FreeFile
    ReDim bData(1 To 2)
    Open strFileLocation For Binary Access Read As #intFile
        Do While Not EOF(intFile)
            ReDim Preserve bData(LBound(bData) To UBound(bData) + 1)
            bData(UBound(bData)) = InputB(LOF(ntFile), intFile)
            DoEvents
            Debug.Print bData(UBound(bData))
        Loop
    Close #intFile
End Sub
Great!
Glad to help.