Jump to content

Animated Splash


wakillon
 Share

Recommended Posts

So, at first, I just wanted a transparent png splash screen and the idea came to me to simulate their movements just for fun

and it gives this : 3 examples
 

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
Dim $_GuiDelete

$sPngUrl = 'http://s21.postimg.org/4hofttn9z/20141102175221.png'
$sPngPath = @TempDir & '\temp1.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

; example 1
For $iWidth = 200 To @DesktopWidth/2 Step 10
    $_Gui = GUICreate ( 'gui', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iWidth / $fRatio )
    _SetBitMap ( $_Gui, $hImage, 255, $iWidth, $iWidth / $fRatio )
    GUISetState ( @SW_SHOW )
Next

Sleep ( 2000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
While Not $_GuiDelete
    $_GuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
WEnd
Sleep ( 3000 )

; example 2
$sPngUrl = 'http://s17.postimg.org/v95y9tnvj/20141102180621.png'
$sPngPath = @TempDir & '\temp2.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

For $iWidth = 50 To @DesktopWidth/3 Step 10
    $_Gui = GUICreate ( 'gui', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iHeight )
    _SetBitMap ( $_Gui, $hImage, 255, $iWidth, $iHeight )
    GUISetState ( @SW_SHOW )
Next

Sleep ( 3000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
$_GuiDelete= Not $_GuiDelete
While Not $_GuiDelete
    $_GuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
WEnd
Sleep ( 2000 )

; example 3
$sPngUrl = 'http://s11.postimg.org/5xco0uw77/20141102174904.png'
$sPngPath = @TempDir & '\temp3.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

For $iWidth = 300 To @DesktopWidth/2 Step 10
    $_Gui = GUICreate ( '', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iHeight )
    _SetBitMap ( $_Gui, $hImage, 255, $iWidth, $iWidth / $fRatio )
    GUISetState ( @SW_SHOW )
Next

Sleep ( 3000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
$_GuiDelete= Not $_GuiDelete
While Not $_GuiDelete
    $_GuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
WEnd
Exit

Func _SetBitmap ( $hGUI, $hImage, $iOpacity, $n_width, $n_height )
    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', $n_width )
    DllStructSetData ( $tSize, 'Y', $n_height )
    $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 ()

Func _ImageResize ( $sInImage, $newW, $newH, $sOutImage = '' )
    Local $oldImage, $GC, $newBmp, $newGC
    If $sOutImage = '' Then _GDIPlus_Startup ()
    $oldImage = _GDIPlus_ImageLoadFromFile ( $sInImage )
    $GC = _GDIPlus_ImageGetGraphicsContext ( $oldImage )
    $newBmp = _GDIPlus_BitmapCreateFromGraphics ( $newW, $newH, $GC )
    $newGC = _GDIPlus_ImageGetGraphicsContext ( $newBmp )
    _GDIPlus_GraphicsDrawImageRect ( $newGC, $oldImage, 0, 0, $newW, $newH )
    _GDIPlus_GraphicsDispose ( $GC )
    _GDIPlus_GraphicsDispose ( $newGC )
    _GDIPlus_ImageDispose ( $oldImage )
    If $sOutImage = '' Then
    Return $newBmp
    Else
    _GDIPlus_ImageSaveToFile ( $newBmp, $sOutImage )
    _GDIPlus_BitmapDispose ( $newBmp )
    _GDIPlus_Shutdown ()
    Return 1
    EndIf
EndFunc ;==> _ImageResize ()
gui erasure is a bit jerky i don't know why...
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Link to comment
Share on other sites

Thanks ! :P
and as you like it, I put 3 other examples ! :mellow:
 

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
Global $bGuiDelete

$sPngUrl = 'http://s27.postimg.org/i5tbtkt9f/20141102181657.png'
$sPngPath = @TempDir & '\temp4.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

; example 4
For $iWidth = 200 To @DesktopWidth/2 Step 15
    $hGui = GUICreate ( 'gui', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iWidth / $fRatio )
    _SetBitMap ( $hGui, $hImage, 255, $iWidth, $iWidth / $fRatio )
    GUISetState ( @SW_SHOW )
    Sleep ( 20 )
Next

Sleep ( 2000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
While Not $bGuiDelete
    $bGuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
    Sleep ( 10 )
WEnd
Sleep ( 3000 )

; example 5
$sPngUrl = 'http://s3.postimg.org/psjavjlsj/20141102181755.png'
$sPngPath = @TempDir & '\temp5.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

For $iWidth = 50 To @DesktopWidth/3 Step 20
    $hGui = GUICreate ( 'gui', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iHeight )
    _SetBitMap ( $hGui, $hImage, 255, $iWidth, $iHeight )
    GUISetState ( @SW_SHOW )
    Sleep ( 20 )
Next

Sleep ( 2000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
$bGuiDelete= Not $bGuiDelete
While Not $bGuiDelete
    $bGuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
    Sleep ( 10 )
WEnd
Sleep ( 3000 )

; example 6
$sPngUrl = 'http://s21.postimg.org/6gwtk1d7b/20141102181824.png'
$sPngPath = @TempDir & '\temp6.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

For $iWidth = 300 To @DesktopWidth/2 Step 15
    $hGui = GUICreate ( '', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iHeight )
    _SetBitMap ( $hGui, $hImage, 255, $iWidth, $iWidth / $fRatio )
    GUISetState ( @SW_SHOW )
    Sleep ( 20 )
Next

Sleep ( 3000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
$bGuiDelete= Not $bGuiDelete
While Not $bGuiDelete
    $bGuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
    Sleep ( 10 )
WEnd
Exit

Func _SetBitmap ( $hGUI, $hImage, $iOpacity, $n_width, $n_height )
    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', $n_width )
    DllStructSetData ( $tSize, 'Y', $n_height )
    $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 ()

Func _ImageResize ( $sInImage, $newW, $newH, $sOutImage='' )
    Local $oldImage, $GC, $newBmp, $newGC
    If $sOutImage = '' Then _GDIPlus_Startup ()
    $oldImage = _GDIPlus_ImageLoadFromFile ( $sInImage )
    $GC = _GDIPlus_ImageGetGraphicsContext ( $oldImage )
    $newBmp = _GDIPlus_BitmapCreateFromGraphics ( $newW, $newH, $GC )
    $newGC = _GDIPlus_ImageGetGraphicsContext ( $newBmp )
    _GDIPlus_GraphicsDrawImageRect ( $newGC, $oldImage, 0, 0, $newW, $newH )
    _GDIPlus_GraphicsDispose ( $GC )
    _GDIPlus_GraphicsDispose ( $newGC )
    _GDIPlus_ImageDispose ( $oldImage )
    If $sOutImage = '' Then
    Return $newBmp
    Else
    _GDIPlus_ImageSaveToFile ( $newBmp, $sOutImage )
    _GDIPlus_BitmapDispose ( $newBmp )
    _GDIPlus_Shutdown ()
    Return 1
    EndIf
EndFunc ;==> _ImageResize ()

Voila, voila !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Link to comment
Share on other sites

Thanks to all
3 last examples...

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
Global $bGuiDelete

$sPngUrl = 'http://s21.postimg.org/pvbw8bpqv/20141102183731.png'
$sPngPath = @TempDir & '\temp7.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

; example 7
For $iWidth = 200 To @DesktopWidth/2 Step 15
    $hGui = GUICreate ( 'gui', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iWidth / $fRatio )
    _SetBitMap ( $hGui, $hImage, 255, $iWidth, $iWidth / $fRatio )
    GUISetState ( @SW_SHOW )
    Sleep ( 20 )
Next

Sleep ( 2000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
While Not $bGuiDelete
    $bGuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
    Sleep ( 10 )
WEnd
Sleep ( 3000 )

; example 8
$sPngUrl = 'http://s17.postimg.org/695u3lpgf/20141102183037.png'
$sPngPath = @TempDir & '\temp8.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

For $iWidth = 50 To @DesktopWidth/3 Step 20
    $hGui = GUICreate ( 'gui', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iHeight )
    _SetBitMap ( $hGui, $hImage, 255, $iWidth, $iHeight )
    GUISetState ( @SW_SHOW )
    Sleep ( 20 )
Next

Sleep ( 2000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
$bGuiDelete= Not $bGuiDelete
While Not $bGuiDelete
    $bGuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
    Sleep ( 10 )
WEnd
Sleep ( 3000 )

; example 9
$sPngUrl = 'http://s3.postimg.org/4aibj8hzn/20141102190506.png'
$sPngPath = @TempDir & '\temp9.png'
If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 )
_GDIPlus_Startup ()
$hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath )
$iWidth = _GDIPlus_ImageGetWidth ( $hImage )
$iHeight = _GDIPlus_ImageGetHeight ( $hImage )
$fRatio = $iWidth / $iHeight

For $iWidth = 300 To @DesktopWidth/2 Step 15
    $hGui = GUICreate ( '', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $hImage = _ImageResize ( $sPngPath, $iWidth, $iHeight )
    _SetBitMap ( $hGui, $hImage, 255, $iWidth, $iWidth / $fRatio )
    GUISetState ( @SW_SHOW )
;~  Sleep ( 20 )
Next

Sleep ( 3000 )
_GDIPlus_GraphicsDispose ( $hImage )
_GDIPlus_Shutdown ()
$bGuiDelete= Not $bGuiDelete
While Not $bGuiDelete
    $bGuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) )
    Sleep ( 10 )
WEnd
Exit

Func _SetBitmap ( $hGUI, $hImage, $iOpacity, $n_width, $n_height )
    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', $n_width )
    DllStructSetData ( $tSize, 'Y', $n_height )
    $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 ()

Func _ImageResize ( $sInImage, $newW, $newH, $sOutImage='' )
    Local $oldImage, $GC, $newBmp, $newGC
    If $sOutImage = '' Then _GDIPlus_Startup ()
    $oldImage = _GDIPlus_ImageLoadFromFile ( $sInImage )
    $GC = _GDIPlus_ImageGetGraphicsContext ( $oldImage )
    $newBmp = _GDIPlus_BitmapCreateFromGraphics ( $newW, $newH, $GC )
    $newGC = _GDIPlus_ImageGetGraphicsContext ( $newBmp )
    _GDIPlus_GraphicsDrawImageRect ( $newGC, $oldImage, 0, 0, $newW, $newH )
    _GDIPlus_GraphicsDispose ( $GC )
    _GDIPlus_GraphicsDispose ( $newGC )
    _GDIPlus_ImageDispose ( $oldImage )
    If $sOutImage = '' Then
    Return $newBmp
    Else
    _GDIPlus_ImageSaveToFile ( $newBmp, $sOutImage )
    _GDIPlus_BitmapDispose ( $newBmp )
    _GDIPlus_Shutdown ()
    Return 1
    EndIf
EndFunc ;==> _ImageResize ()
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I take your first example and modified it:

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
HotKeySet("{Esc}", "_exit")
Dim $_GuiDelete

$_PngUrl = 'http://1.2.3.12/bmi/www.autoit.de/wcf/images/future/autoit_logo_gtaspider.png'
$_PngPath = @TempDir & "\autoIt.png"
If Not FileExists($_PngPath) Then InetGet($_PngUrl, $_PngPath, 1)
_GDIPlus_Startup()
$_Image = _GDIPlus_ImageLoadFromFile($_PngPath)
$_Width = _GDIPlus_ImageGetWidth($_Image)
$_Height = _GDIPlus_ImageGetHeight($_Image)
$_Ratio = $_Width / $_Height

$_Gui = GUICreate("gui", 1, 1, 1, 1, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetState(@SW_SHOW)
For $_Width = 200 To @DesktopWidth Step 20
    WinMove($_Gui, "", (@DesktopWidth - $_Width) / 2, (@DesktopHeight - $_Height) / 2, $_Width, $_Width / $_Ratio)
    $_Image = _ImageResize($_PngPath, $_Width, $_Width / $_Ratio)
    _SetBitMap($_Gui, $_Image, 255, $_Width, $_Width / $_Ratio)
    Sleep(210-$_Width)
Next

For $_Width = @DesktopWidth To 200 Step -20
    WinMove($_Gui, "", (@DesktopWidth - $_Width) / 2, (@DesktopHeight - $_Height) / 2, $_Width, $_Width / $_Ratio)
    $_Image = _ImageResize($_PngPath, $_Width, $_Width / $_Ratio)
    _SetBitMap($_Gui, $_Image, 255, $_Width, $_Width / $_Ratio)
    Sleep(210-$_Width)
Next
_exit()

Func _exit()
    _GDIPlus_GraphicsDispose($_Image)
    _GDIPlus_Shutdown()
EndFunc   ;==>_exit

Func _SetBitmap($hGUI, $hImage, $iOpacity, $n_width, $n_height)
;http://www.autoitscript.com/forum/index.php?showtopic=115391&view=findpost&p=806020
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", $n_width)
    DllStructSetData($tSize, "Y", $n_height)
    $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

Func _ImageResize($sInImage, $newW, $newH, $sOutImage = "")
;http://www.autoitscript.com/forum/index.php?showtopic=115391&view=findpost&p=806020
    Local $oldImage, $GC, $newBmp, $newGC
    If $sOutImage = "" Then _GDIPlus_Startup()
    $oldImage = _GDIPlus_ImageLoadFromFile($sInImage)
    $GC = _GDIPlus_ImageGetGraphicsContext($oldImage)
    $newBmp = _GDIPlus_BitmapCreateFromGraphics($newW, $newH, $GC)
    $newGC = _GDIPlus_ImageGetGraphicsContext($newBmp)
    _GDIPlus_GraphicsDrawImageRect($newGC, $oldImage, 0, 0, $newW, $newH)
    _GDIPlus_GraphicsDispose($GC)
    _GDIPlus_GraphicsDispose($newGC)
    _GDIPlus_ImageDispose($oldImage)
    If $sOutImage = "" Then
        Return $newBmp
    Else
        _GDIPlus_ImageSaveToFile($newBmp, $sOutImage)
        _GDIPlus_BitmapDispose($newBmp)
        _GDIPlus_Shutdown()
        Return 1
    EndIf
EndFunc   ;==>_ImageResize
I think this is the better solution, because the Gui is only created once

Link to comment
Share on other sites

  • 2 weeks later...

I take your first example and modified it

You are right, it's nice, but this is multi Gui who give this animated effect !

Change your $_PngUrl for http://www.autoit.de/wcf/images/future/autoit_logo_gtaspider.png

Thank's :mellow:

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

On my computer, it starts zooming in ok, but when it gets close to its max size, it starts to shake. Same with zooming out. It shakes when it is close to the max size.

Edit: It has to do with the WinMove call. I changed the WinMove location to 0, 0 and it works fine. The math for centering the gui is obviously correct, but I don't know why the GUI would shake like it is currently.

Edited by dantay9
Link to comment
Share on other sites

On my computer, it starts zooming in ok, but when it gets close to its max size, it starts to shake. Same with zooming out. It shakes when it is close to the max size.

Edit: It has to do with the WinMove call. I changed the WinMove location to 0, 0 and it works fine. The math for centering the gui is obviously correct, but I don't know why the GUI would shake like it is currently.

If it shake, try a Png splash fade ! :mellow:

#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 ( )

Five examples for fun too ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • 2 weeks later...

wakillon,

I've used one of these in the first-run startup sequence for iTunesTweet :blink: Hopefully when I release the update people will like it ;)

James

Hi james, Posted Image

i'm sincerly very proud to help you in your project ! Posted Image

Let me know if people like it !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • 7 months later...

PNG with transparency are great for splashscreen and taking the idea of AutoBert,
I had fun trying differents combinations, and it gives this :

Previous downloads : 1065

AnimatedSplash2014.2.au3

I hope you enjoy these few examples ! :king:

All Png are downloaded on postimg.org at first execution.
 

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

My God what a beautiful (^.^)

Congratulations nice script very well prepared

-------------------------------------------------------------------------------------------------------------------------------------------- [center][/center][center]Autoit Support Forum in Portuguese | AutoitBrasil.com[/center] [sub]My Script :[/sub]Simples Login for Program

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

×
×
  • Create New...