fusion400 Posted September 18, 2010 Share Posted September 18, 2010 Is it possible to make a crossfade effect between different images in autoit and show it in fullscreen mode? My idea is to be able to display a playlist of jpg images for about 5 seconds each that has a smooth cross fade effect. Link to comment Share on other sites More sharing options...
wakillon Posted September 18, 2010 Share Posted September 18, 2010 Try this expandcollapse popup#include <Memory.au3> #Include <WindowsConstants.au3> #include <String.au3> #include <GDIPlus.au3> #NoTrayIcon Dim $socket For $_Load = 1 To 5 _GDIPlus_Startup ( ) Switch $_Load Case 1 $hImage = _GDIPlus_ImageLoadFromInet ( "http://www.autoit.de", "/wcf/images/future/autoit_logo_gtaspider.png" ) Case 2 $hImage = _GDIPlus_ImageLoadFromInet ( "http://upload.wikimedia.org", "/wikipedia/fr/3/38/Guitar_Hero_Logo.png" ) Case 3 $hImage = _GDIPlus_ImageLoadFromInet ( "http://www.sosdevoirs.org", "/blogue/wp-content/uploads/2010/02/vikidia-logo.png" ) Case 4 $hImage = _GDIPlus_ImageLoadFromInet ( "http://arkanfashion.com", "/images/071112_Disney_logo%20copy.png" ) Case 5 $hImage = _GDIPlus_ImageLoadFromInet ( "http://www.canoe.polymtl.ca", "/web/images/stories/Youtube.png" ) EndSwitch $_Width = _GDIPlus_ImageGetWidth ( $hImage ) $_Height = _GDIPlus_ImageGetHeight ( $hImage ) $hwnd = GUICreate ( "Display image from memory", $_Width, $_Height, -1, -1, -1, BitOr ( $WS_EX_LAYERED, $WS_EX_TOOLWINDOW ) ) GUISetState ( ) WinSetOnTop ( $hwnd,"",1 ) For $i = 70 to 255 step 2 _SetBitmap ( $hwnd, $hImage, $i ) Sleep ( 20 ) Next Sleep ( 1000 ) For $i = 255 to 0 step -2 _SetBitmap ( $hwnd, $hImage, $i ) Sleep ( 20 ) Next _GDIPlus_ImageDispose ( $hImage ) _GDIPlus_Shutdown ( ) Next Exit Func _GDIPlus_ImageLoadFromInet ( $sHost, $sSeite ) ; http://www.autoit.de/index.php?page=Thread&threadID=19707 If StringInStr ( $sHost, "http://" ) Then $sHost = StringReplace ( $sHost, "http://", "" ) If StringRegExp ( $sHost, "\.../" ) Then $sHost = Stringreplace ( $sHost, "/", "" ) TCPStartup ( ) $sIp = TCPNameToIP ( $sHost ) $sData = "GET " & $sSeite & " HTTP/1.1" & @Crlf & _ "Host: " & $sHost & @Crlf & _ "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)" & @Crlf & _ "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & @Crlf & _ "Accept-Language:de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" & @Crlf & _ "Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7" & @Crlf & _ "Connection: close" & @Crlf & @Crlf $sSocket = TCPConnect ( $sIp, 80 ) TCPSend ( $sSocket, $sData ) If @error Then Return Seterror ( 1 ) Local $sRecv_header = "", $sRecv_binary = "0x" Do $sRecv_header = TCPRecv ( $sSocket, 1 ) Until $sRecv_header <> "" Do $sRecv_header &= TCPRecv ( $sSocket, 1 ) Until StringInStr ( $sRecv_header, @Crlf & @Crlf ) $aArray_help = _StringBetween ( $sRecv_header, 'Content-Length: ', @Crlf ) If NOT isarray ( $aArray_help ) Then TCPCloseSocket ( $socket ) TCPShutdown ( ) Return Seterror ( 1 ) EndIf $iBytes = $aArray_help[0] Do $sRecv_binary &= StringTrimLeft ( TCPRecv ( $sSocket, 1024, 1 ), 2 ) Until BinaryLen ( Binary ( $sRecv_binary ) ) >= $iBytes TCPCloseSocket ( $sSocket ) TCPShutdown ( ) $memBitmap = Binary ( $sRecv_binary ) $len = BinaryLen ( $memBitmap ) $hData = _MemGlobalAlloc ( $len, 0x0002 ) $pData = _MemGlobalLock ( $hData ) $tMem = DllStructCreate ( "byte[" & $len & "]", $pData ) DllStructSetData ( $tMem, 1, $memBitmap ) _MemGlobalUnlock ( $hData ) $aResult = DllCall ( "ole32.dll", "int", "CreateStreamOnHGlobal", "hwnd", $pData, "int", True, "ptr*", 0 ) If @error Then Return SetError ( @error, @extended, 0 ) $aResult = DllCall ( $ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $aResult[3], "int*", 0 ) If @error Then Return SetError ( @error, @extended, 0 ) Return $aResult[2] EndFunc ;==> _GDIPlus_ImageLoadFromInet ( ) Func _SetBitmap ( $hGUI, $hImage, $iOpacity ) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC ( 0 ) $hMemDC = _WinAPI_CreateCompatibleDC ( $hScrDC ) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap ( $hImage ) $hOld = _WinAPI_SelectObject ( $hMemDC, $hBitmap ) $tSize = DllStructCreate ( $tagSIZE ) $pSize = DllStructGetPtr ( $tSize ) DllStructSetData ( $tSize, "X", _GDIPlus_ImageGetWidth ( $hImage ) ) DllStructSetData ( $tSize, "Y", _GDIPlus_ImageGetHeight ( $hImage ) ) $tSource = DllStructCreate ( $tagPOINT ) $pSource = DllStructGetPtr ( $tSource ) $tBlend = DllStructCreate ( $tagBLENDFUNCTION ) $pBlend = DllStructGetPtr ( $tBlend ) DllStructSetData ( $tBlend, "Alpha" , $iOpacity ) DllStructSetData ( $tBlend, "Format", 1 ) _WinAPI_UpdateLayeredWindow ( $hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA ) _WinAPI_ReleaseDC ( 0, $hScrDC ) _WinAPI_SelectObject ( $hMemDC, $hOld ) _WinAPI_DeleteObject ( $hBitmap ) _WinAPI_DeleteDC ( $hMemDC ) EndFunc ;==> _SetBitmap ( ) AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
fusion400 Posted September 18, 2010 Author Share Posted September 18, 2010 (edited) Yes this seems to be on the right track the only thing missing is that it doesn't actually cross fade between images it rather fades them in and out one by one. Rather then crossfadeing between images and it seems to not initiate any fullscreen mode. This is the more exact definition for a cross-fade: A lap dissolve (sometimes called a cross-fade, mix or simply a dissolve) is a technical term in film editing, most often used in the United States, applying to the process whereby the fading last shot of a preceding scene is superimposed over the emerging first shot (fade in) of the next scene, so that, for a few moments, both shots are seen simultaneously. Generally, but not always, the use of a dissolve is held to indicate that a period of time has passed between the two scenes. Try this expandcollapse popup#include <Memory.au3> #Include <WindowsConstants.au3> #include <String.au3> #include <GDIPlus.au3> #NoTrayIcon Dim $socket For $_Load = 1 To 5 _GDIPlus_Startup ( ) Switch $_Load Case 1 $hImage = _GDIPlus_ImageLoadFromInet ( "http://www.autoit.de", "/wcf/images/future/autoit_logo_gtaspider.png" ) Case 2 $hImage = _GDIPlus_ImageLoadFromInet ( "http://upload.wikimedia.org", "/wikipedia/fr/3/38/Guitar_Hero_Logo.png" ) Case 3 $hImage = _GDIPlus_ImageLoadFromInet ( "http://www.sosdevoirs.org", "/blogue/wp-content/uploads/2010/02/vikidia-logo.png" ) Case 4 $hImage = _GDIPlus_ImageLoadFromInet ( "http://arkanfashion.com", "/images/071112_Disney_logo%20copy.png" ) Case 5 $hImage = _GDIPlus_ImageLoadFromInet ( "http://www.canoe.polymtl.ca", "/web/images/stories/Youtube.png" ) EndSwitch $_Width = _GDIPlus_ImageGetWidth ( $hImage ) $_Height = _GDIPlus_ImageGetHeight ( $hImage ) $hwnd = GUICreate ( "Display image from memory", $_Width, $_Height, -1, -1, -1, BitOr ( $WS_EX_LAYERED, $WS_EX_TOOLWINDOW ) ) GUISetState ( ) WinSetOnTop ( $hwnd,"",1 ) For $i = 70 to 255 step 2 _SetBitmap ( $hwnd, $hImage, $i ) Sleep ( 20 ) Next Sleep ( 1000 ) For $i = 255 to 0 step -2 _SetBitmap ( $hwnd, $hImage, $i ) Sleep ( 20 ) Next _GDIPlus_ImageDispose ( $hImage ) _GDIPlus_Shutdown ( ) Next Exit Func _GDIPlus_ImageLoadFromInet ( $sHost, $sSeite ) ; http://www.autoit.de/index.php?page=Thread&threadID=19707 If StringInStr ( $sHost, "http://" ) Then $sHost = StringReplace ( $sHost, "http://", "" ) If StringRegExp ( $sHost, "\.../" ) Then $sHost = Stringreplace ( $sHost, "/", "" ) TCPStartup ( ) $sIp = TCPNameToIP ( $sHost ) $sData = "GET " & $sSeite & " HTTP/1.1" & @Crlf & _ "Host: " & $sHost & @Crlf & _ "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)" & @Crlf & _ "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & @Crlf & _ "Accept-Language:de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" & @Crlf & _ "Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7" & @Crlf & _ "Connection: close" & @Crlf & @Crlf $sSocket = TCPConnect ( $sIp, 80 ) TCPSend ( $sSocket, $sData ) If @error Then Return Seterror ( 1 ) Local $sRecv_header = "", $sRecv_binary = "0x" Do $sRecv_header = TCPRecv ( $sSocket, 1 ) Until $sRecv_header <> "" Do $sRecv_header &= TCPRecv ( $sSocket, 1 ) Until StringInStr ( $sRecv_header, @Crlf & @Crlf ) $aArray_help = _StringBetween ( $sRecv_header, 'Content-Length: ', @Crlf ) If NOT isarray ( $aArray_help ) Then TCPCloseSocket ( $socket ) TCPShutdown ( ) Return Seterror ( 1 ) EndIf $iBytes = $aArray_help[0] Do $sRecv_binary &= StringTrimLeft ( TCPRecv ( $sSocket, 1024, 1 ), 2 ) Until BinaryLen ( Binary ( $sRecv_binary ) ) >= $iBytes TCPCloseSocket ( $sSocket ) TCPShutdown ( ) $memBitmap = Binary ( $sRecv_binary ) $len = BinaryLen ( $memBitmap ) $hData = _MemGlobalAlloc ( $len, 0x0002 ) $pData = _MemGlobalLock ( $hData ) $tMem = DllStructCreate ( "byte[" & $len & "]", $pData ) DllStructSetData ( $tMem, 1, $memBitmap ) _MemGlobalUnlock ( $hData ) $aResult = DllCall ( "ole32.dll", "int", "CreateStreamOnHGlobal", "hwnd", $pData, "int", True, "ptr*", 0 ) If @error Then Return SetError ( @error, @extended, 0 ) $aResult = DllCall ( $ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $aResult[3], "int*", 0 ) If @error Then Return SetError ( @error, @extended, 0 ) Return $aResult[2] EndFunc ;==> _GDIPlus_ImageLoadFromInet ( ) Func _SetBitmap ( $hGUI, $hImage, $iOpacity ) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC ( 0 ) $hMemDC = _WinAPI_CreateCompatibleDC ( $hScrDC ) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap ( $hImage ) $hOld = _WinAPI_SelectObject ( $hMemDC, $hBitmap ) $tSize = DllStructCreate ( $tagSIZE ) $pSize = DllStructGetPtr ( $tSize ) DllStructSetData ( $tSize, "X", _GDIPlus_ImageGetWidth ( $hImage ) ) DllStructSetData ( $tSize, "Y", _GDIPlus_ImageGetHeight ( $hImage ) ) $tSource = DllStructCreate ( $tagPOINT ) $pSource = DllStructGetPtr ( $tSource ) $tBlend = DllStructCreate ( $tagBLENDFUNCTION ) $pBlend = DllStructGetPtr ( $tBlend ) DllStructSetData ( $tBlend, "Alpha" , $iOpacity ) DllStructSetData ( $tBlend, "Format", 1 ) _WinAPI_UpdateLayeredWindow ( $hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA ) _WinAPI_ReleaseDC ( 0, $hScrDC ) _WinAPI_SelectObject ( $hMemDC, $hOld ) _WinAPI_DeleteObject ( $hBitmap ) _WinAPI_DeleteDC ( $hMemDC ) EndFunc ;==> _SetBitmap ( ) Edited September 18, 2010 by fusion400 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 18, 2010 Share Posted September 18, 2010 I made an image-viewer using SDL that has some sort of crossfading. ShiftER. Use Effect 2.Feel free to borrow ideas or code if you want .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Authenticity Posted September 18, 2010 Share Posted September 18, 2010 expandcollapse popup#include <File.au3> #include <GDIP.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> Local Const $sImagesFolder = @ScriptDir & "\Images" Local Const $iDeskWidth = @DesktopWidth, $iDeskHeight = @DesktopHeight Local $hCurImage, $hNextImage, $hDisplayImage, $hScreenBmp Local $hGraphics, $hImageGraphics Local $hImageAttributes, $tScaleMatrixIn, $pScaleMatrixIn, $tScaleMatrixOut, $pScaleMatrixOut Local $nInScaleF, $nOutScaleF Local $aSize, $iCurImgWidth, $iCurImgHeight, $iNextImgWidth, $iNextImgHeight Local $aFiles = _FileListToArray($sImagesFolder, "*.jpg", 1) If @error Then Exit _GDIPlus_Startup() Local $hGUI = GUICreate("", $iDeskWidth, $iDeskHeight, 0, 0, $WS_POPUP) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hDisplayImage = _GDIPlus_BitmapCreateFromScan0($iDeskWidth, $iDeskHeight) $hImageGraphics = _GDIPlus_ImageGetGraphicsContext($hDisplayImage) $hScreenBmp = _ScreenCapture_Capture("", 0, 0, -1, -1, False) $hNextImage = _GDIPlus_BitmapCreateFromHBITMAP($hScreenBmp) _WinAPI_DeleteObject($hScreenBmp) $hImageAttributes = _GDIPlus_ImageAttributesCreate() ; Fade in color scaling matrix $tScaleMatrixIn = _GDIPlus_ColorMatrixCreateScale(1.0, 1.0, 1.0) $pScaleMatrixIn = DllStructGetPtr($tScaleMatrixIn) ; Fade out color scaling matrix $tScaleMatrixOut = _GDIPlus_ColorMatrixCreateScale(1.0, 1.0, 1.0) $pScaleMatrixOut = DllStructGetPtr($tScaleMatrixOut) HotKeySet("{ESC}", "_Quit") OnAutoItExitRegister("_CleanUp") GUISetState() For $i = 1 To $aFiles[0] If $hNextImage Then $hCurImage = $hNextImage $hNextImage = _GDIPlus_ImageLoadFromFile($sImagesFolder & "\" & $aFiles[$i]) If @error Then ContinueLoop $aSize = _GDIPlus_ImageGetDimension($hCurImage) $iCurImgWidth = $aSize[0] $iCurImgHeight = $aSize[1] $aSize = _GDIPlus_ImageGetDimension($hNextImage) $iNextImgWidth = $aSize[0] $iNextImgHeight = $aSize[1] For $j = 15 To 255 Step 60 $nInScaleF = $j / 255 $nOutScaleF = (255 - $j) / 255 _UpdateScaleColorMatrix($tScaleMatrixIn, $nInScaleF, $nInScaleF, $nInScaleF, $nInScaleF) _UpdateScaleColorMatrix($tScaleMatrixOut, $nOutScaleF, $nOutScaleF, $nOutScaleF, $nOutScaleF) _GDIPlus_GraphicsClear($hImageGraphics) _GDIPlus_ImageAttributesSetColorMatrix($hImageAttributes, 0, True, $pScaleMatrixOut) _GDIPlus_GraphicsDrawImageRectRectIA($hImageGraphics, $hCurImage, 0, 0, $iCurImgWidth, $iCurImgHeight, 0, 0, $iDeskWidth, $iDeskHeight, $hImageAttributes) _GDIPlus_ImageAttributesSetColorMatrix($hImageAttributes, 0, True, $pScaleMatrixIn) _GDIPlus_GraphicsDrawImageRectRectIA($hImageGraphics, $hNextImage, 0, 0, $iNextImgWidth, $iNextImgHeight, 0, 0, $iDeskWidth, $iDeskHeight, $hImageAttributes) _GDIPlus_GraphicsDrawImage($hGraphics, $hDisplayImage, 0, 0) Next _GDIPlus_ImageDispose($hCurImage) Sleep(2000) Next Func _Quit() Exit EndFunc Func _CleanUp() _GDIPlus_ImageDispose($hNextImage) _GDIPlus_ImageDispose($hCurImage) _GDIPlus_ImageAttributesDispose($hImageAttributes) _GDIPlus_GraphicsDispose($hImageGraphics) _GDIPlus_ImageDispose($hDisplayImage) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc Func _UpdateScaleColorMatrix(ByRef $tCM, $nRed, $nGreen, $nBlue, $nAlpha = 1) DllStructSetData($tCM, "m", $nRed, 1) DllStructSetData($tCM, "m", $nGreen, 7) DllStructSetData($tCM, "m", $nBlue, 13) DllStructSetData($tCM, "m", $nAlpha, 19) EndFunc You can reduce the inner loop stepping value, pictures will blend-over more softened but slower. Change the necessary parts. Search the Examples forum for GDIP.au3. Link to comment Share on other sites More sharing options...
fusion400 Posted September 19, 2010 Author Share Posted September 19, 2010 Ok i have tried this and it works but its horribly slow and the stepping is not smooth for one bit and extremely slow. Maybe there is something wrong. I also tried to use images that perfectly match my desktop resolution but it did not make any difference. I am running windows 7 maybe there is something wrong that makes this not work well on win7. expandcollapse popup#include <File.au3> #include <GDIP.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> Local Const $sImagesFolder = @ScriptDir & "\Images" Local Const $iDeskWidth = @DesktopWidth, $iDeskHeight = @DesktopHeight Local $hCurImage, $hNextImage, $hDisplayImage, $hScreenBmp Local $hGraphics, $hImageGraphics Local $hImageAttributes, $tScaleMatrixIn, $pScaleMatrixIn, $tScaleMatrixOut, $pScaleMatrixOut Local $nInScaleF, $nOutScaleF Local $aSize, $iCurImgWidth, $iCurImgHeight, $iNextImgWidth, $iNextImgHeight Local $aFiles = _FileListToArray($sImagesFolder, "*.jpg", 1) If @error Then Exit _GDIPlus_Startup() Local $hGUI = GUICreate("", $iDeskWidth, $iDeskHeight, 0, 0, $WS_POPUP) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hDisplayImage = _GDIPlus_BitmapCreateFromScan0($iDeskWidth, $iDeskHeight) $hImageGraphics = _GDIPlus_ImageGetGraphicsContext($hDisplayImage) $hScreenBmp = _ScreenCapture_Capture("", 0, 0, -1, -1, False) $hNextImage = _GDIPlus_BitmapCreateFromHBITMAP($hScreenBmp) _WinAPI_DeleteObject($hScreenBmp) $hImageAttributes = _GDIPlus_ImageAttributesCreate() ; Fade in color scaling matrix $tScaleMatrixIn = _GDIPlus_ColorMatrixCreateScale(1.0, 1.0, 1.0) $pScaleMatrixIn = DllStructGetPtr($tScaleMatrixIn) ; Fade out color scaling matrix $tScaleMatrixOut = _GDIPlus_ColorMatrixCreateScale(1.0, 1.0, 1.0) $pScaleMatrixOut = DllStructGetPtr($tScaleMatrixOut) HotKeySet("{ESC}", "_Quit") OnAutoItExitRegister("_CleanUp") GUISetState() For $i = 1 To $aFiles[0] If $hNextImage Then $hCurImage = $hNextImage $hNextImage = _GDIPlus_ImageLoadFromFile($sImagesFolder & "\" & $aFiles[$i]) If @error Then ContinueLoop $aSize = _GDIPlus_ImageGetDimension($hCurImage) $iCurImgWidth = $aSize[0] $iCurImgHeight = $aSize[1] $aSize = _GDIPlus_ImageGetDimension($hNextImage) $iNextImgWidth = $aSize[0] $iNextImgHeight = $aSize[1] For $j = 15 To 255 Step 60 $nInScaleF = $j / 255 $nOutScaleF = (255 - $j) / 255 _UpdateScaleColorMatrix($tScaleMatrixIn, $nInScaleF, $nInScaleF, $nInScaleF, $nInScaleF) _UpdateScaleColorMatrix($tScaleMatrixOut, $nOutScaleF, $nOutScaleF, $nOutScaleF, $nOutScaleF) _GDIPlus_GraphicsClear($hImageGraphics) _GDIPlus_ImageAttributesSetColorMatrix($hImageAttributes, 0, True, $pScaleMatrixOut) _GDIPlus_GraphicsDrawImageRectRectIA($hImageGraphics, $hCurImage, 0, 0, $iCurImgWidth, $iCurImgHeight, 0, 0, $iDeskWidth, $iDeskHeight, $hImageAttributes) _GDIPlus_ImageAttributesSetColorMatrix($hImageAttributes, 0, True, $pScaleMatrixIn) _GDIPlus_GraphicsDrawImageRectRectIA($hImageGraphics, $hNextImage, 0, 0, $iNextImgWidth, $iNextImgHeight, 0, 0, $iDeskWidth, $iDeskHeight, $hImageAttributes) _GDIPlus_GraphicsDrawImage($hGraphics, $hDisplayImage, 0, 0) Next _GDIPlus_ImageDispose($hCurImage) Sleep(2000) Next Func _Quit() Exit EndFunc Func _CleanUp() _GDIPlus_ImageDispose($hNextImage) _GDIPlus_ImageDispose($hCurImage) _GDIPlus_ImageAttributesDispose($hImageAttributes) _GDIPlus_GraphicsDispose($hImageGraphics) _GDIPlus_ImageDispose($hDisplayImage) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc Func _UpdateScaleColorMatrix(ByRef $tCM, $nRed, $nGreen, $nBlue, $nAlpha = 1) DllStructSetData($tCM, "m", $nRed, 1) DllStructSetData($tCM, "m", $nGreen, 7) DllStructSetData($tCM, "m", $nBlue, 13) DllStructSetData($tCM, "m", $nAlpha, 19) EndFunc You can reduce the inner loop stepping value, pictures will blend-over more softened but slower. Change the necessary parts. Search the Examples forum for GDIP.au3. Link to comment Share on other sites More sharing options...
seandisanti Posted September 19, 2010 Share Posted September 19, 2010 Ok i have tried this and it works but its horribly slow and the stepping is not smooth for one bit and extremely slow.well Auth said...You can reduce the inner loop stepping value, pictures will blend-over more softened but slowerperhaps there is a clue somewhere in there about a way you could try to speed it up... Or you could of course take his other advice, or better yet post an attempt at doing it yourself instead of complaining at someone else's attempt. Link to comment Share on other sites More sharing options...
Authenticity Posted September 22, 2010 Share Posted September 22, 2010 (edited) You can try using Direct3D, but D3D requires more code:expandcollapse popup#include "D3D9.au3" #include <File.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) Local Const $sFolder = "Images" Local Const $sFolderPath = @ScriptDir & "\" & $sFolder Local Const $iWidth = 640, $iHeight = 480 Local const $nRatio = $iWidth / $iHeight Local Const $FVF_VERTEX = BitOR($D3DFVF_XYZ, $D3DFVF_TEX1) Local $aFiles = _FileListToArray($sFolderPath, "*.jpg", 1) If @error Then Exit MsgBox(0x10, "Error", 'Could not locate image folder: "' & $sFolder & '"') Local $hGUI = GUICreate("", $iWidth, $iHeight, -1, -1, $WS_POPUP) Local $pDevice, $oDevice, $pTextureOut, $oTextureOut, $pTextureIn, $oTextureIn, $pVB, $oVB Local $tMtrlOut, $pMtrlOut, $tMtrlIn, $pMtrlIn Local $iImgIdx = 2, $iImgMax = $aFiles[0] _D3D_Startup() $pDevice = _D3D_Init($hGUI, $iWidth, $iHeight) $oDevice = _AutoItObject_WrapperCreate($pDevice, $tagID3DDevice9Interface) $pTextureOut = _D3DX_CreateTextureFromFile($pDevice, $sFolderPath & "\" & $aFiles[1]) $oTextureOut = _AutoItObject_WrapperCreate($pTextureOut, $tagIDirect3DTexture9) $pTextureIn = _D3DX_CreateTextureFromFile($pDevice, $sFolderPath & "\" & $aFiles[2]) $oTextureIn = _AutoItObject_WrapperCreate($pTextureIn, $tagIDirect3DTexture9) _Setup() GUISetOnEvent(-3, "_Quit") OnAutoItExitRegister("_Cleanup") GUISetState() Local $nOpacityOut = 1, $nOpacityIn = 0 Local $nTimer = TimerInit() While 1 _Render() _HighPrecisionSleep(4000) $nOpacityOut -= 0.005 $nOpacityIn += 0.005 If $nOpacityOut > 1 Then $nOpacityOut = 1 ElseIf $nOpacityOut < 0 Then $nOpacityOut = 0 EndIf If $nOpacityIn > 1 Then $nOpacityIn = 1 ElseIf $nOpacityIn < 0 Then $nOpacityIn = 0 EndIf If TimerDiff($nTimer) > 3000 Then $nOpacityOut = 1 $nOpacityIn = 0 $iImgIdx += 1 If $iImgIdx > $iImgMax Then $iImgIdx = 1 _UpdateTextures($iImgIdx) $nTimer = TimerInit() EndIf WEnd Func _UpdateTextures($iIndex) $pTextureOut = 0 $oTextureOut = 0 $pTextureOut = $pTextureIn $oTextureOut = $oTextureIn $pTextureIn = _D3DX_CreateTextureFromFile($pDevice, $sFolderPath & "\" & $aFiles[$iIndex]) $oTextureIn = _AutoItObject_WrapperCreate($pTextureIn, $tagIDirect3DTexture9) EndFunc Func _Render() $oDevice.Clear("long", "uint", 0, "ptr", 0, "uint", BitOR($D3DCLEAR_TARGET, $D3DCLEAR_ZBUFFER), "uint", 0, "float", 1, "uint", 0) $oDevice.BeginScene("long") DllStructSetData($tMtrlOut, "Diffuse", $nOpacityOut, 4) DllStructSetData($tMtrlIn, "Diffuse", $nOpacityIn, 4) If IsObj($oTextureOut) And IsObj($oTextureIn) Then ; Set our vertex buffer as the source of the triangles vertices $oDevice.SetStreamSource("long", "uint", 0, "ptr", Number($pVB), "uint", 0, "uint", 20) ; Set the flexible vertex format (xyz and texture coordinates in this example) $oDevice.SetFVF("long", "uint", $FVF_VERTEX) ; Set materials and textures and draw $oDevice.SetMaterial("long", "ptr", Number($pMtrlOut)) $oDevice.SetTexture("long", "uint", 0, "ptr", Number($pTextureOut)) $oDevice.DrawPrimitive("long", "int", $D3DPT_TRIANGLEFAN, "uint", 0, "uint", 2) $oDevice.SetMaterial("long", "ptr", Number($pMtrlIn)) $oDevice.SetTexture("long", "uint", 0, "ptr", Number($pTextureIn)) $oDevice.DrawPrimitive("long", "int", $D3DPT_TRIANGLEFAN, "uint", 0, "uint", 2) EndIf $oDevice.EndScene("long") ; Present our next scene for rendering (swap back and front buffers) $oDevice.Present("long", "ptr", 0, "ptr", 0, "hwnd", 0, "ptr", 0) EndFunc Func _Setup() Local $aResult, $tLight, $tVertex, $pVertex Local $aVertices[4][5] = [ _ [-$nRatio, 1, 1, 0, 0], _ [ $nRatio, 1, 1, 1, 0], _ [ $nRatio, -1, 1, 1, 1], _ [-$nRatio, -1, 1, 0, 1]] $tMtrlOut = _D3D_CreateMaterial() $pMtrlOut = DllStructGetPtr($tMtrlOut) $tMtrlIn = _D3D_CreateMaterial() $pMtrlIn = DllStructGetPtr($tMtrlIn) $aResult = $oDevice.CreateVertexBuffer("long", "uint", 4 * 20, "uint", $D3DUSAGE_WRITEONLY, "uint", $FVF_VERTEX, "int", $D3DPOOL_MANAGED, "ptr*", 0, "ptr", 0) $pVB = $aResult[6] $oVB = _AutoItObject_WrapperCreate($pVB, $tagIDirect3DVertexBuffer9) $aResult = $oVB.Lock("long", "uint", 0, "uint", 0, "ptr*", 0, "uint", 0) $pVertex = $aResult[4] $tVertex = DllStructCreate("float[" & 4 * 5 & "]", $pVertex) For $i = 0 To UBound($aVertices)-1 For $j = 0 To UBound($aVertices, 2)-1 DllStructSetData($tVertex, 1, $aVertices[$i][$j], $i*5+$j+1) Next Next $oVB.Unlock("long") $tLight = DllStructCreate($tagD3DLIGHT9) DllStructSetData($tLight, "Type", $D3DLIGHT_DIRECTIONAL) For $i = 1 To 4 DllStructSetData($tLight, "Diffuse", 1, $i) DllStructSetData($tLight, "Specular", 1, $i) DllStructSetData($tLight, "Ambient", 1, $i) Next $oDevice.SetLight("long", "uint", 0, "ptr", Number(DllStructGetPtr($tLight))) $oDevice.LightEnable("long", "uint", 0, "bool", True) $oDevice.SetSamplerState("long", "uint", 0, "int", $D3DSAMP_MAGFILTER, "uint", $D3DTEXF_LINEAR) $oDevice.SetSamplerState("long", "uint", 0, "int", $D3DSAMP_MINFILTER, "uint", $D3DTEXF_LINEAR) $oDevice.SetSamplerState("long", "uint", 0, "int", $D3DSAMP_MIPFILTER, "uint", $D3DTEXF_POINT) $oDevice.SetTextureStageState("long", "uint", 0, "int", $D3DTSS_ALPHAARG1, "uint", $D3DTA_DIFFUSE) $oDevice.SetTextureStageState("long", "uint", 0, "int", $D3DTSS_ALPHAOP, "uint", $D3DTOP_SELECTARG1) $oDevice.SetRenderState("long", "int", $D3DRS_SRCBLEND, "uint", $D3DBLEND_SRCALPHA) $oDevice.SetRenderState("long", "int", $D3DRS_DESTBLEND, "uint", $D3DBLEND_INVSRCALPHA) Local $tProj = _D3DX_MatrixPerspectiveFovLH(ASin(1), $nRatio, 1, 1000) $oDevice.SetTransform("long", "int", $D3DTS_PROJECTION, "ptr", Number(DllStructGetPtr($tProj))) ; Enable alpha-blend channel processing $oDevice.SetRenderState("long", "int", $D3DRS_ALPHABLENDENABLE, "uint", True) EndFunc Func _Quit() Exit EndFunc Func _Cleanup() If IsObj($oTextureIn) Then $oTextureIn = 0 If IsObj($oTextureOut) Then $oTextureOut = 0 If IsObj($oVB) Then $oVB = 0 $oDevice = 0 GUIDelete() _D3D_Shutdown() EndFunc ; #FUNCTION#;=============================================================================== ; ; Name...........: _HighPrecisionSleep() ; Description ...: Sleeps down to 0.1 microseconds ; Syntax.........: _HighPrecisionSleep( $iMicroSeconds, $hDll=False) ; Parameters ....: $iMicroSeconds - Amount of microseconds to sleep ; $hDll - Can be supplied so the UDF doesn't have to re-open the dll all the time. ; Return values .: None ; Author ........: Andreas Karlsson (monoceres) ; Modified.......: ; Remarks .......: Even though this has high precision you need to take into consideration that it will take some time for autoit to call the function. ; Related .......: ; Link ..........; ; Example .......; No ; ;;========================================================================================== Func _HighPrecisionSleep($iMicroSeconds,$hDll=False) Local $hStruct, $bLoaded If Not $hDll Then $hDll=DllOpen("ntdll.dll") $bLoaded=True EndIf $hStruct=DllStructCreate("int64 time;") DllStructSetData($hStruct,"time",-1*($iMicroSeconds*10)) DllCall($hDll,"dword","ZwDelayExecution","int",0,"ptr",DllStructGetPtr($hStruct)) If $bLoaded Then DllClose($hDll) EndFuncDownload the attachment for includes. Also, you need to download AutoItObject UDF, thanks to the developers by the way.Edit: Fixed _D3D_Init function and the flickering. (hopefully)D3D9.rar Edited September 23, 2010 by Authenticity algiuxas 1 Link to comment Share on other sites More sharing options...
trancexx Posted September 22, 2010 Share Posted September 22, 2010 (edited) Authenticity cool! I just tested that script (after downloading d3dx9_36.dll). Works great. Wrapper object in current version of AutoItObject is rewritten not to use callback, btw. I tested your script in this new situation. Works too, even better. What I can see is that you call Release() for od3d9 before returning from _D3D_Init(). You probably shouldn't. If that call actually worked script should crash on later reference to that object. Now Release() fails because you are calling it wrong (no ret type specified). Again, very cool! Thanks for sharing. Edited September 22, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Authenticity Posted September 22, 2010 Share Posted September 22, 2010 Thanks. You're correct about my mistake. Can you elaborate on the callback thing? I'm using AutoItObject v1.1.0. P.S. Is there like a garbage collector in AutoIt? or something similar? I can't believe that such a simple script can use approximately 200MB of RAM o_O Link to comment Share on other sites More sharing options...
trancexx Posted September 22, 2010 Share Posted September 22, 2010 (edited) Thanks. You're correct about my mistake. Can you elaborate on the callback thing? I'm using AutoItObject v1.1.0.P.S. Is there like a garbage collector in AutoIt? or something similar? I can't believe that such a simple script can use approximately 200MB of RAM o_OCallback function was used in 1.1.0 to execute object method. Things were prepared outside the script code and then the control was returned to AutoIt to actually call wanted method. After that control was retaken again and results of the call processed. This was due to the fact that it was easier not to implement DllCall() inside our dll.This method has different disadvantages. For example besides being damn slow you can't use datatypes other than AutoIt supports. After implementing Invoke that doesn't use AutoIt's script code (no callback) 'everything' is possible; we introduced variant data type for example, since it's often needed with different objects.Will be public if testing turns ok. Looks very promising for now. All is available in development.I don't have that high RAM usage for your script. It's more like 11MB. Windows7 x64. Edited September 22, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted September 22, 2010 Share Posted September 22, 2010 For me it is crashing: Problemsignatur: Problemereignisname: APPCRASH Anwendungsname: autoit3.exe Anwendungsversion: 3.3.6.1 Anwendungszeitstempel: 4bc81615 Fehlermodulname: cmd.exe Fehlermodulversion: 6.0.6001.18000 Fehlermodulzeitstempel: 4bd9d984 Ausnahmecode: c0000005 Ausnahmeoffset: 00001f7a Betriebsystemversion: 6.0.6002.2.2.0.256.4 Gebietsschema-ID: 1031 Zusatzinformation 1: d310 Zusatzinformation 2: e9ec4d83da0029b35ba27415b3b318c8 Zusatzinformation 3: e498 Zusatzinformation 4: 54aaf96a2bc2e2838fc609c3418b4797 Problem is line 25: $pTextureOut = _D3DX_CreateTextureFromFile($pDevice, $sFolderPath & "\" & $aFiles[1]) Used: latest version of AutoItObject and AutoIt on Vista x32. That sounds very very promissing Authenticity! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Authenticity Posted September 22, 2010 Share Posted September 22, 2010 Check that $pDevice is not a null pointer. I can't think of any other reason why the script failed... If $pDevice is null you'll need to see check the _D3D_Init function. Link to comment Share on other sites More sharing options...
UEZ Posted September 22, 2010 Share Posted September 22, 2010 d3dx9_36.dll was missing! Sometimes it flickers when changing the image but great implementation! Can we expect a D3D9 UDF soon? Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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