Ticket #1196: _GDIPlus_BitmapUnlockBits.au3

File _GDIPlus_BitmapUnlockBits.au3, 1.3 KB (added by eukalyptus, 15 years ago)
Line 
1#include <ScreenCapture.au3>
2
3Global $hScreen, $hBitmap, $aMem, $tData
4
5_GDIPlus_Startup()
6$hScreen=_ScreenCapture_Capture("", 0, 0, -1, -1, False)
7$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hScreen)
8
9For $i=1 To 50
10    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, _GDIPlus_ImageGetWidth($hBitmap), _GDIPlus_ImageGetHeight($hBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB)
11    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
12    Sleep(50)
13    $aMem = MemGetStats()
14    ConsoleWrite("original function; step " & $i & "; mem usage: " & $aMem[0] & @LF)
15Next
16
17ConsoleWrite(@LF)
18
19For $i=1 To 50
20    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, _GDIPlus_ImageGetWidth($hBitmap), _GDIPlus_ImageGetHeight($hBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB)
21    _GDIPlus_BitmapUnlockBits_($hBitmap, $tData)
22    Sleep(50)
23    $aMem = MemGetStats()
24    ConsoleWrite("test function; step " & $i & "; mem usage: " & $aMem[0] & @LF)
25Next
26
27Func _GDIPlus_BitmapUnlockBits_($hBitmap, $tBitmapData)
28    Local $aResult
29
30    $aResult = DllCall($ghGDIPDll, "int", "GdipBitmapUnlockBits", "hwnd", $hBitmap, "ptr", DllStructGetPtr($tBitmapData)) ;Type ptr instead of int*
31    If @error Then Return SetError(@error, @extended, False)
32    Return SetError($aResult[0], 0, $aResult[0] = 0)
33EndFunc   ;==>_GDIPlus_BitmapUnlockBits