Jump to content

Looking for Slide Transition Effect


qwert
 Share

Recommended Posts

I've been experimenting with having a GUI that fades an image into view ... then fades it out, changes the image, and fades the new image into view. It's a nice effect, but I'd like to take it to the next level, where the current image fades out, as the next one fades in -- a slide transition effect.

But before I get too involved in further experiments, I thought I would ask: Has anyone worked with this effect? Should I maintain two GUIs and alternate between? Or should I create a new GUI for each image and delete the previous after it has faded out? Or is there an even better approach? Ideally, I would like to avoid any screen flashes or visual glitches to achieve a "pro" result.

Any suggestions will be appreciated.

Link to comment
Share on other sites

Thanks for the reply. I'll have a look at it. My first impression is that it may be more complicated than what I need, given that it involves textures and 3D libraries. I'd certainly forgo "cross fade" for the simpler effect that I had in mind. Then again, even a simpler method may take more than I thought to do it right.

Link to comment
Share on other sites

Here a very simple version:

#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=Simple Image Slideshow Program
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=UEZ 2010
#AutoIt3Wrapper_Res_Language=1033
://////=__=
://////=__=--
://////=__=
://////=__=
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UPX_Parameters=--ultra-brute
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <Array.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Global $c, $i, $k, $l, $chk, $end, $fn
Global $hGUI[3], $graphic0, $graphic1, $graphic2, $hGraphic[2], $hImage, $hBrush1, $hBrush2, $hFamily, $hFont, $hFormat, $tLayout, $aInfo
Global Const $SC_DRAGMOVE = 0xF012, $fsize = 8, $fh = 15
Global Const $ratio = 16 / 10
Global Const $height = Floor(@DesktopHeight * 0.9 / 8) * 8, $width = Floor($height * $ratio / 8) * 8
Global Const $bg_color = "F0F0F0"
Global Const $title = "Simple Image Slideshow by UEZ"
Global $imagedir = FileSelectFolder("Select folder with images", "", 4, @ScriptDir)
If $imagedir = "" Then Exit MsgBox(16, "Error", "No folder selected!", 5)

Global $aFiles = _FileListToArray($imagedir, "*.*", 1)
If Not UBound($aFiles) Then Exit MsgBox(16, "Error", "No files found!", 5)

$l = 1
Do
    $chk = StringRegExp($aFiles[$l], "(?i:.*\.jpg|.*\.png|.*\.bmp|.*\.gif)", 3)
    If @error Then
        _ArrayDelete($aFiles, $l)
        $l -= 1
    EndIf
    $l += 1
Until $l = UBound($aFiles)

If UBound($aFiles) = 1 Then Exit MsgBox(16, "Error", "No images found!", 5)

Global $audio = _FileListToArray(@ScriptDir, "*.mp3", 1)
Global $play = False, $rand, $a
$a = UBound($audio) - 1
If Not @error Then
    If $a Then
        $rand = 1
    Else
        $rand = Random(1, $a, 1)
    EndIf
    $play = True
    SoundPlay($audio[$rand])
EndIf

Fader_Init($width, $height)

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hGUI[2])
WinActivate($hGUI[2])

GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

For $k = 1 To UBound($aFiles) - 1
    Fader($imagedir & "\" & $aFiles[$k])
Next

Sleep(3000)
_Exit(True)

Func WM_ERASEBKGND($hWnd, $msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hGUI[2], 0, 0, 0)
    Return 1
EndFunc

Func Fader($image, $delay = 12, $speed = 3, $sleep = 1500, $display_fn = True)
    Local $a, $d = Mod($c, 2), $iW, $iH, $f, $w, $h
    $hImage = _GDIPlus_ImageLoadFromFile($image)
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)

    If $iW < $width + 1 And $iH < $height + 1 Then
        _GDIPlus_GraphicsDrawImageRect($hGraphic[$d], $hImage, $width / 2 - $iW / 2, $height / 2 - $iH / 2, $iW, $iH)
    Else
        If $iW > $iH Then
            $f = $iW / $width
        Else
            $f = $iH / $height
        EndIf
        $w = Int($iW / $f)
        $h = Int($iH / $f)
        _GDIPlus_GraphicsDrawImageRect($hGraphic[$d], $hImage, $width / 2 - $w / 2, $height / 2 - $h / 2, $w, $h)
    EndIf
    If $display_fn Then
        _GDIPlus_GraphicsFillRect($hGraphic[$d], 0, $height - $fh, $width, $fh, $hBrush2)
        $fn = $k & "/" & UBound($aFiles) - 1 & ": " & $image & " (" & $iW & "x" & $iH & ")"
        If StringLen($fn) > Floor($width / 5.5) Then $fn = StringLeft($fn, 30) & "..." & StringRight($fn, StringLen($fn) - StringInStr($fn, "\", 0, -1) + 30)
        _GDIPlus_GraphicsDrawStringEx($hGraphic[$d], $fn, $hFont, $tLayout, $hFormat, $hBrush1)
    EndIf
    For $a = 0 To 0xFF - $speed Step $speed
        WinSetTrans($hGUI[$d], "", $a)
        WinSetTrans($hGUI[Not $d], "", 0xFF - $speed - $a)
        Sleep($delay)
    Next
    _GDIPlus_GraphicsClear($hGraphic[Not $d], "0xFF" & $bg_color)
    $c += 1
    Sleep($sleep)
EndFunc   ;==>Fader

Func Fader_Init($width, $height)
    $hGUI[2] = GUICreate($title, $width, $height, -1, -1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_DLGMODALFRAME)
    $hGUI[0] = GUICreate($title, $width, $height, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_MDICHILD, $hGUI[2])
    $hGUI[1] = GUICreate($title, $width, $height, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_MDICHILD, $hGUI[2])
    GUISetBkColor("0x" & $bg_color, $hGUI[2])
    GUISetState(@SW_SHOW, $hGUI[2])
    GUISetState(@SW_SHOW, $hGUI[0])
    GUISetState(@SW_SHOW, $hGUI[1])
    WinSetTrans($hGUI[0], "", 0x00)
    WinSetTrans($hGUI[1], "", 0x00)
    _GDIPlus_Startup()
    $hGraphic[0] = _GDIPlus_GraphicsCreateFromHWND($hGUI[0])
    $hGraphic[1] = _GDIPlus_GraphicsCreateFromHWND($hGUI[1])
    _GDIPlus_GraphicsClear($hGraphic[0], "0xFF" & $bg_color)
    _GDIPlus_GraphicsClear($hGraphic[1], "0xFF" & $bg_color)
    $hBrush1 = _GDIPlus_BrushCreateSolid(0xFFF0F080)
    $hBrush2 = _GDIPlus_LineBrushCreate(0, 0, $width, $fh, 0xD0101020, 0x08D0D080, 0x03)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, $fsize)
    $tLayout = _GDIPlus_RectFCreate(0, $height - $fh, 0, 0)
EndFunc   ;==>Fader_Init

Func _Exit($end = False)
    GUIRegisterMsg($WM_LBUTTONDOWN, "")
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphic[0])
    _GDIPlus_GraphicsDispose($hGraphic[1])
    GUIDelete($hGUI[0])
    GUIDelete($hGUI[1])
    GUIDelete($hGUI[2])
    _GDIPlus_Shutdown()
    If $play Then SoundPlay("")
    If $end Then Exit MsgBox(0, "Information", "End reached! Closing in 10 seconds!", 10)
    Exit
EndFunc   ;==>_Exit

Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0)
    Local $tPointF1, $pPointF1
    Local $tPointF2, $pPointF2
    Local $aResult
    $tPointF1 = DllStructCreate("float;float")
    $pPointF1 = DllStructGetPtr($tPointF1)
    $tPointF2 = DllStructCreate("float;float")
    $pPointF2 = DllStructGetPtr($tPointF2)
    DllStructSetData($tPointF1, 1, $nX1)
    DllStructSetData($tPointF1, 2, $nY1)
    DllStructSetData($tPointF2, 1, $nX2)
    DllStructSetData($tPointF2, 2, $nY2)
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", $pPointF1, "ptr", $pPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[6]
EndFunc   ;==>_GDIPlus_LineBrushCreate

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI[2], $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

Have fun.

Works properly only on Vista+ os!

Br,

UEZ

Edited by 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

This is not compared with UEZ's, but you should try it:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;sample pictures (replace them)
_FadeGUIs("C:\Users\nevermind\Pictures\mosaic.JPG","C:\Users\nevermind\Pictures\3dBarGraph.JPG")

While 1
    Sleep(10)
WEnd

Func _FadeGUIs($sPic1, $sPic2)
    Local $switch=1
    Local $hWnd1 = GUICreate("Picture #1", 600, 400,-1,-1,$WS_POPUP,0)
    GUICtrlCreatePic($sPic1, 1, 1, 598, 398)
    Local $hWnd2 = GUICreate("Picture #2", 600, 400,-1,-1,$WS_POPUP,0)
    GUICtrlCreatePic($sPic2, 1, 1, 598, 398)
    WinSetTrans($hWnd1,"",0)
    WinSetTrans($hWnd2,"",250)
    GUISetState(@SW_SHOW,$hWnd1)
    GUISetState(@SW_SHOW,$hWnd2)
    Sleep(1000)
    Switch $switch
        Case 1
            For $i=0 To 250
                Sleep(10)
                WinSetTrans($hWnd1,"",$i)
                WinSetTrans($hWnd2,"",250-$i)
            Next
            $switch = 0
            Sleep(500)
            ContinueCase
        Case 0
            For $i=0 To 250
                Sleep(10)
                WinSetTrans($hWnd2,"",$i)
                WinSetTrans($hWnd1,"",250-$i)
            Next
            Sleep(1000)
            MsgBox(64,"End show","That's it!"&@CRLF&"Press OK to exit.")
            Exit
    EndSwitch
EndFunc

M.I.

[EDIT]  qwert, I read only the first part before I post this, and the second part after!   :graduated:

Edited by taietel
Link to comment
Share on other sites

UEZ,

That's a really nice packaging of the whole idea. I was able to tune to get a nice fade in, but I couldn't make it fade out the previous slide. That slide just disappears the instant the next one starts fading in. Have I missed some setting? I probably won't have time to look at the script in more detail until next week, but there's probably a easy way to add fade out.

taietel,

Your script is much closer to what I can easily follow. One thing I did learn is that I will have to have a third GUI as a "back drop" for the slide show ... otherwise, the desktop shows through. But I see how that will be easy to add.

Thanks to you both.

Link to comment
Share on other sites

That one just does simple transitions. The OP is looking for something to Cross-fade where during part of the cycle you are seeing both images. I know that can be done in JQuery and it can be done in Javascript but I still haven't worked at doing it in AutoIt. Theoretically it can be done using WinSetTrans() using two overlapping windows and one day I'll get around to trying it.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

That one just does simple transitions. The OP is looking for something to Cross-fade where during part of the cycle you are seeing both images. I know that can be done in JQuery and it can be done in Javascript but I still haven't worked at doing it in AutoIt. Theoretically it can be done using WinSetTrans() using two overlapping windows and one day I'll get around to trying it.

Look at post#4 Posted Image.

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

Here's something I use in the latest SMF release, play with the timings to make it smoother :(...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $gui_FadeIn_hwnd, $gui_FadeIn_iTrans_Current, $gui_FadeIn_iTrans_Max = 254, $gui_FadeIn_iTrans_Step = 10
Global $gui_FadeIn_hwnd2, $gui_FadeIn_iTrans_Current2, $gui_FadeIn_iTrans_Max2 = 254, $gui_FadeIn_iTrans_Step2 = 10

$hGui1 = GUICreate("My GUI #1")
GUICtrlCreateLabel("GUI #1",10,10,200)
GUICtrlSetFont(-1,14,800)
WinSetTrans($hGui1, "", 0)
GUISetState(@SW_SHOW)
$gui_FadeIn_hwnd = $hGui1
AdlibRegister("GUI_FadeInOut", 10)

Sleep(2000)

$hGui2 = GUICreate("My GUI #2")
GUICtrlCreateLabel("GUI #2",10,10,200)
GUICtrlSetFont(-1,14,800)
WinSetTrans($hGui2, "", 0)
GUISetState(@SW_SHOW)
$gui_FadeIn_iTrans_Current = 0
$gui_FadeIn_iTrans_Max = 254
$gui_FadeIn_iTrans_Step = 10
$gui_FadeIn_hwnd = $hGui2
AdlibRegister("GUI_FadeInOut", 40)

$gui_FadeIn_iTrans_Current2 = 90
$gui_FadeIn_iTrans_Max2 = 0
$gui_FadeIn_iTrans_Step2 = -10
$gui_FadeIn_hwnd2 = $hGui1
AdlibRegister("GUI_FadeInOut2", 40)


While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

#region Splash Intro
Func GUI_FadeInOut()
    Select
        Case $gui_FadeIn_iTrans_Step > 0
            If $gui_FadeIn_iTrans_Current + $gui_FadeIn_iTrans_Step >= $gui_FadeIn_iTrans_Max Then
                $gui_FadeIn_iTrans_Current += $gui_FadeIn_iTrans_Step
                WinSetTrans($gui_FadeIn_hwnd, "", $gui_FadeIn_iTrans_Max)
                AdlibUnRegister("GUI_FadeInOut")
                Return
            EndIf
        Case $gui_FadeIn_iTrans_Step < 0
            If $gui_FadeIn_iTrans_Current + $gui_FadeIn_iTrans_Step <= $gui_FadeIn_iTrans_Max Then
                $gui_FadeIn_iTrans_Current += $gui_FadeIn_iTrans_Step
                WinSetTrans($gui_FadeIn_hwnd, "", $gui_FadeIn_iTrans_Max)
                AdlibUnRegister("GUI_FadeInOut")
                Return
            EndIf
    EndSelect
    $gui_FadeIn_iTrans_Current += $gui_FadeIn_iTrans_Step
    WinSetTrans($gui_FadeIn_hwnd, "", $gui_FadeIn_iTrans_Current)
EndFunc   ;==>GUI_FadeInOut

Func GUI_FadeInOut2()
    Select
        Case $gui_FadeIn_iTrans_Step2 > 0
            If $gui_FadeIn_iTrans_Current2 + $gui_FadeIn_iTrans_Step2 >= $gui_FadeIn_iTrans_Max2 Then
                $gui_FadeIn_iTrans_Current2 += $gui_FadeIn_iTrans_Step2
                WinSetTrans($gui_FadeIn_hwnd2, "", $gui_FadeIn_iTrans_Max2)
                AdlibUnRegister("GUI_FadeInOut2")
                Return
            EndIf
        Case $gui_FadeIn_iTrans_Step2 < 0
            If $gui_FadeIn_iTrans_Current2 + $gui_FadeIn_iTrans_Step2 <= $gui_FadeIn_iTrans_Max2 Then
                $gui_FadeIn_iTrans_Current2 += $gui_FadeIn_iTrans_Step2
                WinSetTrans($gui_FadeIn_hwnd2, "", $gui_FadeIn_iTrans_Max2)
                AdlibUnRegister("GUI_FadeInOut2")
                Return
            EndIf
    EndSelect
    $gui_FadeIn_iTrans_Current2 += $gui_FadeIn_iTrans_Step2
    WinSetTrans($gui_FadeIn_hwnd2, "", $gui_FadeIn_iTrans_Current2)
EndFunc   ;==>GUI_FadeInOut2
#endregion Splash Intro

Edit: Looking at it now, it would be more convenient to pack the vars into arrays :graduated: , something like $aFadeIn and $aFadeIn2...

Edited by KaFu
Link to comment
Share on other sites

Look at post#4 Posted Image.

Br,

UEZ

I saw it, I just haven't had time to play with it yet.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 3 weeks later...

Mmmmm Nice, nice, nice,...

I just fixed the program from UEZ... I had some flashing thing happened... it is when you put the WinSetTrans to 255. You should put 254 and... no more flashing.

#include <Array.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)


Global $c=0, $i, $k, $l, $chk, $end, $fn
Global $hGUI[3], $hGraphic[2], $hImage, $hBrush1, $hBrush2, $hFamily, $hFont, $hFormat, $tLayout, $aInfo
Global Const $SC_DRAGMOVE = 0xF012, $fsize = 8, $fh = 15
Global Const $width = 800, $height = 600
Global Const $bg_color = "000000"
Global $imagedir =  FileSelectFolder("Select folder with images", "", 4, @ScriptDir)
If $imagedir = "" Then Exit MsgBox(16, "Error", "No folder selected!", 5)


Global $aFiles = _FileListToArray($imagedir, "*.*", 1)
If Not UBound($aFiles) Then Exit MsgBox(16, "Error", "No files found!", 5)


$l = 1
Do
    $chk = StringRegExp($aFiles[$l], "(.*\.jpg|.*\.png|.*\.bmp|.*\.gif|.*\.JPG|.*\.PNG|.*\.BMP|.*\.GIF)", 3)
    If @error Then
        _ArrayDelete($aFiles, $l)
        $l -= 1
    EndIf
    $l += 1
Until $l = UBound($aFiles)


If UBound($aFiles) = 1 Then Exit MsgBox(16, "Error", "No images found!", 5)



Fader_Init($width, $height)


GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hGUI[2])
WinActivate($hGUI[2])


GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")


For $k = 1 To UBound($aFiles) - 1
    Fader($imagedir & "\" & $aFiles[$k])
Next


Sleep(3000)
_Exit(True)


Func WM_ERASEBKGND($hWnd, $msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hGUI[2], 0, 0, 0)
    Return 1
EndFunc


Func Fader($image, $delay = 0, $speed = 5, $sleep = 500, $display_fn = True)
    Local $a, $d = $c, $iX, $iY, $f, $w, $h
    ;ConsoleWrite($d&"-"&$m & @CRLF)
    $hImage = _GDIPlus_ImageLoadFromFile($image)
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)

    If $iX < $width + 1 And $iY < $height + 1 Then
        _GDIPlus_GraphicsDrawImageRect($hGraphic[$d], $hImage, $width / 2 - $iX / 2, $height / 2 - $iY / 2, $iX, $iY)
    Else
        If $iX > $iY Then
            $f = $iX / $width
            $w = $iX / $f
            $h = $iY / $f
        Else
            $f = $iY / $height
            $w = $iX / $f
            $h = $iY / $f
        EndIf
        _GDIPlus_GraphicsDrawImageRect($hGraphic[$d], $hImage, $width / 2 - $w / 2, $height / 2 - $h / 2, $w, $h)
    EndIf
    If $display_fn Then
        _GDIPlus_GraphicsFillRect($hGraphic[$d], 0, $height - $fh, $width, $fh, $hBrush2)
        $fn = $k & "/" & UBound($aFiles) - 1 & ": " & $image & " (" & $iX & "x" & $iY & ")"
        If StringLen($fn) > Floor($width / 5.5) Then $fn = StringLeft($fn, 30) & "..." & StringRight($fn, StringLen($fn) - StringInStr($fn, "\", 0, -1) + 30)
        _GDIPlus_GraphicsDrawStringEx($hGraphic[$d], $fn, $hFont, $tLayout, $hFormat, $hBrush1)
    EndIf
    For $a = 0 To 254 Step $speed
        WinSetTrans($hGUI[$d], "", $a)
        WinSetTrans($hGUI[Not ($d)], "", 254 - $a)
        Sleep($delay)
    Next
    ;WinSetTrans($hGUI[Not $d], "", 0)
        _GDIPlus_GraphicsClear($hGraphic[Not($d)], "0xFF" & $bg_color)
    ;WinSetTrans($hGUI[$d], "", 255)
    $c = 1 - $d
    Sleep($sleep)
EndFunc   ;==>Fader


Func Fader_Init($width, $height)
    $hGUI[2] = GUICreate("", $width, $height, -1, -1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_DLGMODALFRAME)
    $hGUI[0] = GUICreate("", $width, $height, -1, -1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_MDICHILD , $hGUI[2])
    $hGUI[1] = GUICreate("", $width, $height, -1, -1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_MDICHILD , $hGUI[2])
    GUISetBkColor("0x" & $bg_color, $hGUI[2])
    GUISetState(@SW_SHOW, $hGUI[2])
    GUISetState(@SW_SHOW, $hGUI[0])
    GUISetState(@SW_SHOW, $hGUI[1])
    WinSetTrans($hGUI[0], "", 0)
    WinSetTrans($hGUI[1], "", 0)
    _GDIPlus_Startup()
    $hGraphic[0] = _GDIPlus_GraphicsCreateFromHWND($hGUI[0])
    $hGraphic[1] = _GDIPlus_GraphicsCreateFromHWND($hGUI[1])
    _GDIPlus_GraphicsClear($hGraphic[0], "0xFF" & $bg_color)
    _GDIPlus_GraphicsClear($hGraphic[1], "0xFF" & $bg_color)
    $hBrush1 = _GDIPlus_BrushCreateSolid(0xFFF0F080)
    $hBrush2 = _GDIPlus_LineBrushCreate(0, 0, $width, $fh, 0xD0101020, 0x08D0D080, 0x03)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, $fsize)
    $tLayout = _GDIPlus_RectFCreate(0, $height - $fh, 0, 0)
EndFunc   ;==>Fader_Init


Func _Exit($end = False)
    GUIRegisterMsg($WM_LBUTTONDOWN, "")
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphic[0])
    _GDIPlus_GraphicsDispose($hGraphic[1])
    GUIDelete($hGUI[0])
    GUIDelete($hGUI[1])
    GUIDelete($hGUI[2])
    _GDIPlus_Shutdown()
    ;If $play Then SoundPlay("")
    ;If $end Then Exit MsgBox(0, "Information", "End reached! Closing in 10 seconds!", 10)
    Exit
EndFunc   ;==>_Exit


Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0)
    Local $tPointF1, $pPointF1
    Local $tPointF2, $pPointF2
    Local $aResult
    $tPointF1 = DllStructCreate("float;float")
    $pPointF1 = DllStructGetPtr($tPointF1)
    $tPointF2 = DllStructCreate("float;float")
    $pPointF2 = DllStructGetPtr($tPointF2)
    DllStructSetData($tPointF1, 1, $nX1)
    DllStructSetData($tPointF1, 2, $nY1)
    DllStructSetData($tPointF2, 1, $nX2)
    DllStructSetData($tPointF2, 2, $nY2)
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", $pPointF1, "ptr", $pPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[6]
EndFunc   ;==>_GDIPlus_LineBrushCreate


Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI[2], $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

I modified as well taietel's prg to have an another exemple...

#include <Array.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Local $hWnd1 = GUICreate("Picture", 1024, 768,-1,-1,$WS_POPUP)
GUISetBkColor( "0xFFFFFF", $hWnd1)
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

;sample pictures (replace them)
_FadeGUIs("D:\Mes documents\Mes images\123.jpg","D:\Mes documents\Mes images\456.JPG")
_FadeGUIs("D:\Mes documents\Mes images\456.JPG", "D:\Mes documents\Mes images\789.bmp")

Exit

While 1
    Sleep(10)
WEnd

Func _FadeGUIs($sPic1, $sPic2)
    Local $switch=1
    Local $hWnd3 = GUICreate("", 1024, 768,-1,-1,$WS_POPUP,-1,$hWnd1)
    $hPic1=GUICtrlCreatePic($sPic1, 1, 1, 1024, 768)
    Local $hWnd2 = GUICreate("", 1024, 768,-1,-1,$WS_POPUP,-1,$hWnd1)
    $hPic2=GUICtrlCreatePic($sPic2, 1, 1, 1024, 768)
    WinSetTrans($hWnd3,"",255)
    WinSetTrans($hWnd2,"",0)
    GUISetState(@SW_SHOW,$hWnd1)
    GUISetState(@SW_SHOW,$hWnd3)
    GUISetState(@SW_SHOW,$hWnd2)
    Sleep(1000)
            For $i=0 To 255 Step 5
                ;Sleep(10)
                WinSetTrans($hWnd2,"",$i)
                WinSetTrans($hWnd3,"",255-$i)
            Next
            GUICtrlDelete ( $hPic1 )
            GUIDelete($hWnd3)
            Sleep(1000)
            ;MsgBox(64,"End show","That's it!"&@CRLF&"Press OK to exit.")

EndFunc

Func WM_ERASEBKGND($hWnd, $msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hWnd1, 0, 0, 0)
    Return 1
EndFunc

Enjoy it and modify it !!!!!

Cramaboule

EDIT: Typo

Edited by cramaboule
Link to comment
Share on other sites

Hum,... My brain doesn't stop.... :(:lol::shifty::x

what can we do with this?

Func _TrayBoxAnimate($TBGui, $Xstyle = 1, $Xspeed = 2000)
    ; $Xstyle - 1=Fade, 3=Explode, 5=L-Slide, 7=R-Slide, 9=T-Slide, 11=B-Slide,
    ;13=TL-Diag-Slide, 15=TR-Diag-Slide, 17=BL-Diag-Slide, 19=BR-Diag-Slide,21=Roll-Left
    ;23=Roll-Right
    Local $Xpick = StringSplit('80000,90000,40010,50010,40001,50002,40002,50001,40004,50008,40008,50004,40005,5000a,40006,50009,40009,50006,4000a,50005,20001,30002,20002,30001,20004,30008,20008,30004', ",")
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $TBGui, "int", $Xspeed, "long", "0x000" & $Xpick[$Xstyle])
EndFunc   ;==>_TrayBoxAnimate

:P:nuke::D

I'll try to work on something...

Cram

Ah!!!! I really love AutoIt... :)

Link to comment
Share on other sites

Something like that for example:

#AutoIt3Wrapper_UseX64=n
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "On_Exit")

If @OSArch = "X64" Then
    $sPic = RegRead("HKLM64\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt", "InstallDir")
Else
    $sPic = RegRead("HKLM\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
EndIf

$sPic &= "\Examples\GUI\logo4.gif"

$sFile = StringRight($sPic, StringLen($sPic) - StringInStr($sPic, "\", 0, -1))
$sPath = StringLeft($sPic, StringInStr($sPic, "\", 0, -1) - 1)

$sDimensions = ""
$oShellApp = ObjCreate("shell.application")
If IsObj($oShellApp) Then
    Local $oDir = $oShellApp.NameSpace($sPath)
    If IsObj($oDir) Then
        Local $oFile = $oDir.Parsename($sFile)
        If IsObj($oFile) Then
            If @OSBuild > 6000 Then
                $sDimensions = $oDir.GetDetailsOf($oFile, 31)
            ElseIf @OSVersion = "WIN_XP" Then
                $sDimensions = $oDir.GetDetailsOf($oFile, 26)
            EndIf
        EndIf
    EndIf
EndIf
If $sDimensions = "" Then Exit MsgBox(0, "Error", "Object creation failed")

$aDimensions = StringRegExp($sDimensions, "(?i)[\d]*x*[\d]", 3)
If Not IsArray($aDimensions) Then Exit MsgBox(0, "Error", "Cannot get image resolution!")

$hGUI = GUICreate("Splash", $aDimensions[0], $aDimensions[1], -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic($sPic, 0, 0, $aDimensions[0], $aDimensions[1])

Dim $Gui_Effects_in[10] = [0x00090000, 0x00040001, 0x00040002, 0x00040005, 0x00040004, 0x00040006, 0x00040008, 0x00040009, 0x0004000a, 0x00040010]
Dim $Gui_Effects_out[9] =   [0x00050001, 0x00050002, 0x00050004, 0x00050006, 0x00050005, 0x00050008, 0x00050009, 0x0005000a, 0x00050010]

$effect = Random(0, 1, 1)

If $effect = 1 Then
    WinSetTrans($hGUI, "", 0)
Else
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", 500, "short", $Gui_Effects_in[Random(1, 9, 1)])
EndIf
GUISetState()

If $effect = 1 Then
    For $i = 1 To 255 Step 2
        WinSetTrans($hGUI, "", $i)
        Sleep(10)
    Next
EndIf

Sleep(3500)

On_Exit()

Func On_Exit()
    $effect = Random(0, 1, 1)
    Switch $effect
        Case 0
            For $i = 255 To 0 Step -2
                WinSetTrans($hGUI, "", $i)
                Sleep(5)
            Next
        Case 1
            GUISetState(@SW_DISABLE, $hGUI)
            $hGUI = GUICreate("Test", $aDimensions[0], $aDimensions[1], -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
            DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", 500, "short", $Gui_Effects_out[Random(0, 8, 1)])
            GUISetState(@SW_DISABLE, $hGUI)
    EndSwitch
    Exit
EndFunc

Br,

UEZ

Edited by 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

I am sure a skilled person can find a nicer way to get these into arrays rather than flashing them onscreen, but a decent transition effect on the way out. and _drawpicfromarray allows for offsets if you want to layer them.

Example uses the default wallpapers in XP

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $image1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\merlin.gif"
Local $image2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\msoobe.jpg"
Local $image3 = "C:\Windows\Web\Wallpaper\Ascent.jpg"
Local $image4 = "C:\Windows\Web\Wallpaper\Autumn.jpg"
Local $image5 = "C:\Windows\Web\Wallpaper\Azul.jpg"
Local $image6 = "C:\Windows\Web\Wallpaper\Bliss.bmp"
Local $image7 = "C:\Windows\Web\Wallpaper\Crystal.jpg"
Local $image8 = "C:\Windows\Web\Wallpaper\Follow.jpg"
Local $image9 = "C:\Windows\Web\Wallpaper\Friend.jpg"
Local $image10 = "C:\Windows\Web\Wallpaper\Home.jpg"
Local $image11 = "C:\Windows\Web\Wallpaper\Peace.jpg"
Local $image12 = "C:\Windows\Web\Wallpaper\Power.jpg"


$yGui = 90
$rows = 3
$NumOfImgs = 4

$gui = GUICreate("", $NumOfImgs * 90, $ygui * $rows, 0 , 0, $WS_POPUPWINDOW)

;row 1

        GUICtrlCreatePic($image1, 0, 0, $yGui, $yGui)
        GUICtrlCreatePic($image2, 90, 0, $yGui, $yGui)
        GUICtrlCreatePic($image3, 180, 0, $yGui, $yGui)
        GUICtrlCreatePic($image4, 270, 0, $yGui, $yGui)

;row 2

        GUICtrlCreatePic($image5, 0, 90, $yGui, $yGui)
        GUICtrlCreatePic($image6, 90, 90, $yGui, $yGui)
        GUICtrlCreatePic($image7, 180, 90, $yGui, $yGui)
        GUICtrlCreatePic($image8, 270, 90, $yGui, $yGui)

;row 3
        GUICtrlCreatePic($image9, 0, 180, $yGui, $yGui)
        GUICtrlCreatePic($image10, 90, 180, $yGui, $yGui)
        GUICtrlCreatePic($image11, 180, 180, $yGui, $yGui)
        GUICtrlCreatePic($image12, 270, 180, $yGui, $yGui)

GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW, $gui)

$merlin = _PicToArray(0, 0)
$oobe = _PicToArray(90, 0)
$Ascent = _PicToArray(180, 0)
$Autumn = _PicToArray(270, 0)
$Azul = _PicToArray(0, 90)
$Bliss = _PicToArray(90, 90)
$Crystal = _PicToArray(180, 90)
$Follow = _PicToArray(270, 90)
$Friend = _PicToArray(0, 180)
$Home = _PicToArray(90, 180)
$Peace = _PicToArray(180, 180)
$Power = _PicToArray(270, 180)

GUIDelete()

_DrawPicfromArray ($merlin, '1' , 0 , 0)
_DrawPicfromArray ($oobe, '1' , 0 , 0)
_DrawPicfromArray ($Ascent, '1' , 0 , 0)
_DrawPicfromArray ($Autumn, '1' , 0 , 0)
_DrawPicfromArray ($Azul, '1' , 0 , 0)
_DrawPicfromArray ($Bliss, '1' , 0 , 0)
_DrawPicfromArray ($Crystal, '1' , 0 , 0)
_DrawPicfromArray ($Follow, '1' , 0 , 0)
_DrawPicfromArray ($Friend, '1' , 0 , 0)
_DrawPicfromArray ($Home, '1' , 0 , 0)
_DrawPicfromArray ($Peace, '1' , 0 , 0)
_DrawPicfromArray ($Power, '1' , 0 , 0)




Func _PicToArray($x, $y)

    Dim $BArray[90][90]

    $firstD = UBound($BArray, 1) - 1
    $secondD = UBound($BArray, 2) - 1

    For $B = $x To $firstD + $x
    For $C = $y To $secondD + $y
        $BArray[$B - $x][$C - $y] = "0x" & Hex(PixelGetColor($B + 1, $C + 1), 6)
    Next
Next
splashoff ()
Return $BArray
EndFunc

Func _save($SrcArray , $file)
$save = fileopen ($file , 10)
for $K = 0 to Ubound($SrcArray, 1) - 1
For $L = 0 To UBound($SrcArray, 2) - 1
filewrite ($save, $SrcArray[$K][$L] & @CRLF)
Next
Next
FileClose ($save)
EndFunc

Func _DrawPicfromArray($Srcarray, $TimerARG, $offsetX , $offsetY)

    Dim $ZArray[8100][3]
$k = 0
For $i = 0 To 89
    For $j = 0 To 89
        $ZArray[$k][0] = Random(0,10000,1)
        $ZArray[$k][1] = $i
        $ZArray[$k][2] = $j
        $k+=1
    Next
Next
_ArraySort($ZArray)

;========= Draw array of pixels to desktop at mouse button down ===============
Local $aMPos, $dc

$start1 = TimerInit ()
$dif = timerdiff($start1)

While 1
    If timerdiff($start1) >= $TimerARG Then
        ExitLoop
        Endif
  Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    Local $D, $E
    For $i = 0 To 8099
        $D = $ZArray[$i][1]
        $E = $ZArray[$i][2]
        _PixelSetColor($D + $offsetX, $E + $offsetY, $Srcarray[$D][$E])
        _HPSleep(100,0)
    Next
  DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])
WEnd
EndFunc

; Modified from http://www.autoitscript.com/forum/index.php?showtopic=7315&view=findpost&p=178779
Func _PixelSetColor($XCoord, $YCoord, $Color)
    Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    If Not IsArray($dc) Then Return -1
    DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $XCoord, "long", $YCoord, "long", _
            "0x" & StringRegExpReplace(hex($Color,6), "(..)(..)(..)", "\3\2\1")) ; Change to 0xBBGGRR hex colour format.
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])
EndFunc ;==>_PixelSetColor

Func _HPSleep($iSleep, $fMs = 1)
    ; default is milliseconds, otherwise microseconds (1 ms = 1000 µs)
    If $fMs Then $iSleep *= 1000 ; convert to ms
    DllCall("ntdll.dll", "dword", "NtDelayExecution", "int", 0, "int64*", -10 * $iSleep)
EndFunc

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Something like that for example:

:x Hmmmmmm !!!! no really... I've done that 2-3 years ago...:P

Nooooo I was thinking of something like that:

very quickly made...

#include <Array.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>



Global $hWnd3 = GUICreate("Picture", 1024, 768,-1,-1,$WS_POPUP)

GUISetBkColor( "0xFFFFFF", $hWnd3)
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

;sample pictures (replace them)
MsgBox(4096,"wait", "please wait...",3)
InetGet("http://www.autoitscript.com/autoit3/files/graphics/autoit_10_wall_1024x768.jpg", @TempDir & "\pics1.jpg")
InetGet("http://www.autoitscript.com/autoit3/files/graphics/autoit_fire_wall_1024x768.jpg", @TempDir & "\pics2.jpg")
InetGet("http://www.autoitscript.com/autoit3/files/graphics/autoit_metal_wall_1024x768.jpg", @TempDir & "\pics3.jpg")
InetGet("http://www.autoitscript.com/autoit3/files/graphics/autoit9_wall_1024x768.jpg", @TempDir & "\pics4.jpg")

_FadeGUIs(@TempDir & "\pics1.jpg", @TempDir & "\pics2.jpg")
_FadeGUIs(@TempDir & "\pics3.jpg", @TempDir & "\pics4.jpg")

Exit

While 1
    Sleep(10)
WEnd

Func _FadeGUIs($sPic1, $sPic2)
    Local $switch=1
    Local $hWnd1 = GUICreate("", 1024, 768,-1,-1,$WS_POPUP,-1,$hWnd3)
    $hPic1=GUICtrlCreatePic($sPic1, 1, 1, 1024, 768)
    Local $hWnd2 = GUICreate("", 1024, 768,-1,-1,$WS_POPUP,-1,$hWnd3)
    $hPic2=GUICtrlCreatePic($sPic2, 1, 1, 1024, 768)
    ;WinSetTrans($hWnd3,"",255)
    ;WinSetTrans($hWnd2,"",255)
    ;GUISetState(@SW_SHOW,$hWnd1)
    ;GUISetState(@SW_SHOW,$hWnd3)
    ;GUISetState(@SW_SHOW,$hWnd2)
    Sleep(1000)
    _TrayBoxAnimate($hWnd1, 3, 2000)
                Sleep(1000)
    _TrayBoxAnimate($hWnd2, 3, 2000)

    #cs
            For $i=0 To 255 Step 5
                ;Sleep(10)
                WinSetTrans($hWnd2,"",$i)
                WinSetTrans($hWnd3,"",255-$i)
            Next
    #ce
            GUICtrlDelete ( $hPic1 )
            GUIDelete($hWnd1)
            Sleep(1000)
            ;MsgBox(64,"End show","That's it!"&@CRLF&"Press OK to exit.")

EndFunc

Func WM_ERASEBKGND($hWnd, $msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hWnd3, 0, 0, 0)
    Return 1
EndFunc

Func _TrayBoxAnimate($TBGui, $Xstyle = 1, $Xspeed = 2000)
    ; $Xstyle - 1=Fade, 3=Explode, 5=L-Slide, 7=R-Slide, 9=T-Slide, 11=B-Slide,
    ;13=TL-Diag-Slide, 15=TR-Diag-Slide, 17=BL-Diag-Slide, 19=BR-Diag-Slide,21=Roll-Left
    ;23=Roll-Right
    Local $Xpick = StringSplit('80000,90000,40010,50010,40001,50002,40002,50001,40004,50008,40008,50004,40005,5000a,40006,50009,40009,50006,4000a,50005,20001,30002,20002,30001,20004,30008,20008,30004', ",")
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $TBGui, "int", $Xspeed, "long", "0x000" & $Xpick[$Xstyle])
EndFunc   ;==>_TrayBoxAnimate

Cramaboule :shifty:

Link to comment
Share on other sites

  • 2 weeks later...
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...