Jump to content

GETDIBITS and __ScreenCapture_Capture

Recommended Posts

I am trying to get the same result in a string by using

getdibits (using samples found in the forum) of the full desktop



I read the fullscreen.bmp with file_read and remove the first 54 trailing headerbytes.

Whatever is left seems not to be equal.

Any help would be appreciated why thats the case

Code to get the bits

$bBytes = DllStructCreate("byte[" & BitAND((@DesktopWidth + 3), 0xFFFFFFFC) * @DesktopHeight * 3 & "]")
getImage(0, 0, @Desktopwidth-1, @DesktopHeight-1, $bBytes)

Func GetImage($get_x, $get_y, $wid, $ht, ByRef $byteStruct, $hwnd = 0)
    Local Const $DIB_RGB_COLORS = 0
    Local Const $SRCCOPY = 0xCC0020
    Local $BitInfo = DllStructCreate("dword;int;int;ushort;ushort;dword;dword;int;int;dword;dword;byte[4]")
    DllStructSetData($BitInfo, 1, 40)
    DllStructSetData($BitInfo, 2, $wid)
    DllStructSetData($BitInfo, 3, $ht)
    DllStructSetData($BitInfo, 4, 1)
    DllStructSetData($BitInfo, 5, 24)
    Local $dc = DllCall("user32.dll", "int", "GetWindowDC", "hwnd", $hwnd)
    $dc = $dc[0]
    Local $iDC = DllCall("gdi32.dll", "int", "CreateCompatibleDC", "int", $dc)
    $iDC = $iDC[0]
    Local $iBitmap = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "int", $iDC, "ptr", DllStructGetPtr($BitInfo), _
            "int", $DIB_RGB_COLORS, "ptr", 0, "hwnd", 0, "int", 0)
    $iBitmap = $iBitmap[0]
    DllCall("gdi32.dll", "hwnd", "SelectObject", "int", $iDC, "hwnd", $iBitmap)
    DllCall("gdi32.dll", "int", "BitBlt", "int", $iDC, "int", 0, "int", 0, "int", $wid, "int", _
            $ht, "int", $dc, "int", $get_x, "int", $get_y, "int", $SRCCOPY)
    DllCall("gdi32.dll", "int", "GetDIBits", "int", $iDC, "hwnd", $iBitmap, "int", 0, "int", $ht, "ptr", _
            DllStructGetPtr($byteStruct), "ptr", DllStructGetPtr($BitInfo), "int", $DIB_RGB_COLORS)
    $BitInfo = 0
    DllCall("user32.dll", "int", "ReleaseDC", "int", $dc, "hwnd", $hwnd)
    DllCall("gdi32.dll", "int", "DeleteDC", "int", $iDC)
    DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $iBitmap)
EndFunc  ;==>GetImage
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...