MvGulik Posted April 30, 2010 Share Posted April 30, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Malkey Posted April 30, 2010 Share Posted April 30, 2010 It appears your function can be replaced with :-_GDIPlus_ImageSaveToFile($Bitmap, 'E:\Media\Pictures\Raster_Proj' & '\Out_A_' & $sTrail & '.png')Here are two methods of creating a bitmap that is saved to disk.expandcollapse popup#include <WinAPI.au3> #include <GDIPlus.au3> Local $filename, $begin, $aArr, $time, $iColor Local $hBMP, $hImage1, $hImage2, $hGraphic, $iW, $iH $sFilename = @ScriptDir & "\TestRed.gif" $sFilename1 = @ScriptDir & "\TestBrown.png" $iW = 32 $iH = 32 $iColor = "0xFFFF0000" $iColor1 = "0x654321" $begin = TimerInit() _FileCreateImageColor($sFilename, $iW, $iH, $iColor) _FileCreateImageColor1($sFilename1, $iW, $iH, $iColor1) ConsoleWrite("Time taken = " & Round(TimerDiff($begin) / 1000, 3) & " secs" & @CRLF) ShellExecute($sFilename) ShellExecute($sFilename1) Func _FileCreateImageColor($filename, $iW = 32, $iH = 32, $iColor = "0xFFFFFFFF") $hBMP = _WinAPI_CreateBitmap($iW, $iH, 1, 32) _GDIPlus_Startup() $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) _GDIPlus_GraphicsClear($hGraphic, $iColor) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage1, 0, 0, $iW, $iH) _GDIPlus_ImageSaveToFile($hImage1, $filename) ;__BitmapToImageFile($hImage1, $filename) _GDIPlus_ImageDispose($hImage1) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() Return EndFunc ;==>_FileCreateImageColor Func _FileCreateImageColor1($filename, $iW = 32, $iH = 32, $iColor = "0xFFFFFF") $hBMP = _WinAPI_CreateSolidBitmap(WinGetHandle(""), $iColor, $iW, $iH) _GDIPlus_Startup() $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_ImageSaveToFile($hImage1, $filename) ;__BitmapToImageFile($hImage1, $filename) ;__BitmapToImageFile1($hImage1, $filename) _GDIPlus_ImageDispose($hImage1) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() Return EndFunc ;==>_FileCreateImageColor1 ; ============ Testing MvGulik's function ============== Func __BitmapToImageFile(ByRef $Bitmap, $filename) _GDIPlus_ImageSaveToFile($Bitmap, $filename) Return EndFunc ;==>__BitmapToImageFile Func __BitmapToImageFile1(ByRef $Bitmap, $sTrail = '') ;Local $sFileName = 'E:\Media\Pictures\Raster_Proj' & '\Out_A_' & $sTrail & '.png' Local $tmp1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Bitmap) Local $tmp2 = _GDIPlus_BitmapCreateFromHBITMAP($tmp1) Local $sCLSID = _GDIPlus_EncodersGetCLSID('png') Local $res $res = _GDIPlus_ImageSaveToFileEx($tmp2, $sTrail, $sCLSID, 0) $res = _GDIPlus_ImageDispose($tmp2) $res = _WinAPI_DeleteObject($tmp1) Return EndFunc ;==>__BitmapToImageFile1 ; ===================================================== Link to comment Share on other sites More sharing options...
MvGulik Posted April 30, 2010 Author Share Posted April 30, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... 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