Makaule Posted March 28, 2010 Share Posted March 28, 2010 Hello, all, i have a problem and hope you may have solution. My problem is that i cant delete image after using GDIPlus function. Here is my code: Problem.au3 Thanks, as always, for any answers. Link to comment Share on other sites More sharing options...
Malkey Posted March 28, 2010 Share Posted March 28, 2010 Hello, all, i have a problem and hope you may have solution. My problem is that i cant delete image after using GDIPlus function. Here is my code: Problem.au3 #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #Include <Color.au3> $sBMP_Path1 = @ScriptDir & "\Test.bmp" $GuiSizeX = 74 $GuiSizeY = 130 Compare() Func Compare() Local $v_Values[$GuiSizeX + 1][$GuiSizeY + 1], $count = 0, $Var = 0 _GDIPlus_Startup() If not FileExists($sBMP_Path1) Then _GDIPlus_Shutdown() MsgBox(32,"Error","Why you didnt put image?") Exit EndIf $hBMPBuff1 = _GDIPlus_BitmapCreateFromFile($sBMP_Path1) $Reslt = _GDIPlus_BitmapLockBits($hBMPBuff1, 0, 0, $GuiSizeX, $GuiSizeY, $GDIP_ILMREAD, $GDIP_PXF32RGB) $stride = DllStructGetData($Reslt, "stride") $Scan0 = DllStructGetData($Reslt, "Scan0") For $i = 0 To $GuiSizeX - 1 For $j = 0 To $GuiSizeY - 1 $count = $count + 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $v_Values[$i][$j] = DllStructGetData($v_Buffer, 1) Next Next _GDIPlus_BitmapUnlockBits($hBMPBuff1, $Reslt) _GDIPlus_BitmapDispose($hBMPBuff1) _GDIPlus_Shutdown() ConsoleWrite("Pixels number: " & $count & @CRLF) FileDelete($hBMPBuff1) Return EndFunc Thanks, as always, for any answers. FileDelete($hBMPBuff1) This line in your script should not work. $hBMPBuff1 is a handle to a bitmap object created from a file using _GDIPlus_BitmapCreateFromFile function. In the help file under _GDIPlus_BitmapCreateFromFile there is mentioned a related file _WinAPI_DeleteObject which is used to delete a bitmap. So to clean up the bitmap object, _WinAPI_DeleteObject ($hBMPBuff1) should be used. If you wish to delete the bmp image file from your hard drive, then FileDelete(@ScriptDir & "\Test.bmp") should be used. Link to comment Share on other sites More sharing options...
Makaule Posted March 28, 2010 Author Share Posted March 28, 2010 (edited) Heh, nice one, the easyest sollution, didn't notice, that i am copying wrong name. Fixed to FileDelete($sBMP_Path1), thanks. Edited March 28, 2010 by Makaule Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now