Vert Posted May 28, 2009 Share Posted May 28, 2009 Hello, I have created a script that downloads a PNG image, converts it to JPG, and then uses a splash screen to show it to the user. It is then supposed to get rid of these images, and loop through the entire process again. However, the PNG file does not get deleted properly because it is already in use. Below is part of my code: _GDIPlus_Startup() $image=_GDIPlus_ImageLoadFromFile("testpic.png") _GDIPlus_ImageSaveToFile($image,"testpic.jpg") _GDIPLus_ImageDispose("testpic.png") _WinAPI_DeleteObject($image) SplashImageOn("", "testpic.jpg", 80, 30, 0, 0) SplashOff() _GDIPlus_Shutdown() FileDelete("testpic.png") FileDelete("testpic.jpg") The JPG file gets deleted with no problems, but the PNG file still persists, and therefore my script cannot continue to re-download a new image with the same name because it is already in use. Any ideas? Link to comment Share on other sites More sharing options...
Malkey Posted May 28, 2009 Share Posted May 28, 2009 (edited) Hello, I have created a script that downloads a PNG image, converts it to JPG, and then uses a splash screen to show it to the user. It is then supposed to get rid of these images, and loop through the entire process again. However, the PNG file does not get deleted properly because it is already in use. Below is part of my code: _GDIPlus_Startup() $image=_GDIPlus_ImageLoadFromFile("testpic.png") _GDIPlus_ImageSaveToFile($image,"testpic.jpg") _GDIPLus_ImageDispose("testpic.png") _WinAPI_DeleteObject($image) SplashImageOn("", "testpic.jpg", 80, 30, 0, 0) SplashOff() _GDIPlus_Shutdown() FileDelete("testpic.png") FileDelete("testpic.jpg") The JPG file gets deleted with no problems, but the PNG file still persists, and therefore my script cannot continue to re-download a new image with the same name because it is already in use. Any ideas?One thing I can see wrong is _GDIPLus_ImageDispose("testpic.png") should be _GDIPLus_ImageDispose($image) and _WinAPI_DeleteObject($image) is not needed. Try this. ; #include <GDIPlus.au3> _SpshJPG("File Name.png", 2000);in Script directory _SpshJPG("C:\Full Path\File name.png", 3000) Func _SpshJPG($FileName, $Time) Local $iX, $iY _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile($FileName) _GDIPlus_ImageSaveToFile($image, "testpic.jpg") $iX = _GDIPlus_ImageGetWidth($image) $iY = _GDIPlus_ImageGetHeight($image) SplashImageOn("", "testpic.jpg", $iX, $iY, (@DesktopWidth - $iX) / 2, (@DesktopHeight - $iX) / 2) Sleep($Time) SplashOff() _GDIPlus_ImageDispose($image) _GDIPlus_Shutdown() ;FileDelete("testpic.png") FileDelete("testpic.jpg") Return EndFunc ;==>_SpshJPG ; Edited May 28, 2009 by Malkey Link to comment Share on other sites More sharing options...
Vert Posted May 28, 2009 Author Share Posted May 28, 2009 Works great now, thanks for the help! 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