Jump to content

Animated Splash


wakillon
 Share

Recommended Posts

  • 1 month later...

So im using this as a splash screen for my GrooveShark Player.

The issue is that i dont know how long it takes to load.

So i re-wrote the code a bit and now it works aslong as $i = 1.

To test, press F3

#include-once
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Math.au3>

Local $_Gui, $_Guititle='AnimatedSplashs'
Local $_Image1, $_Width, $_Height, $_Ratio, $_LastWidth, $_LastHeight, $i = 1

AdlibRegister ( '_ReduceMemory', 5000 )

HotKeySet("{F3}", "_Raise")

_Splash ( @TempDir & "\Png\AWorldofKefling2.png" )

;~ Exit
Func _Raise()
    $i = 0
EndFunc

while $i = 1
    sleep (40)
WEnd

Func _Splash( $_PngPath )
    If Not $_Image1 Then _ImageInit ( '', $_PngPath )
    If Not $_Gui Then $_Gui = GUICreate ( $_Guititle, $_Width , $_Height, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) )
    $_Width = @DesktopWidth/4
    WinMove ( $_Gui, "", ( @DesktopWidth - $_Width )/2, ( @DesktopHeight - $_Height )/3, $_Width, $_Width/$_Ratio )
    GUISetState ( @SW_SHOW )
    $_Image1 = _ImageResize ( $_PngPath, $_Width, $_Width/$_Ratio )
    _SetBitMap ( $_Gui, $_Image1, 255, $_Width, $_Width/$_Ratio )
    _WinGetPos ( )
EndFunc ;==> _SplashCome ( )



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

Func _ImageInit ( $_PngUrl2, $_PngPath2 )
    _GDIPlus_Startup ( )
    $_Image1 = _GDIPlus_ImageLoadFromFile ( $_PngPath2 )
    $_Width = _GDIPlus_ImageGetWidth ( $_Image1 )
    $_Height = _GDIPlus_ImageGetHeight ( $_Image1 )
    $_Ratio = Round ( $_Width / $_Height )
EndFunc ;==> _ImageInit ( )

Func _ImageDispose ( $_Image )
    GUIDelete ( WinGetHandle ( $_Guititle, '' ) )
    _GDIPlus_GraphicsDispose ( $_Image )
    _GDIPlus_Shutdown ( )
    $_Image1=0
    $_Gui=0
EndFunc ;==> _ImageDispose ( )

Func _WinGetPos ( )
    $_Pos = WinGetPos ( $_Gui )
    $_LastWidth = $_Pos[2]
    $_LastHeight = $_Pos[3]
EndFunc ;==> _WinGetPos ( )

Func _ReduceMemory ( )
    Local $_Handle = DllCall ( "kernel32.dll", "int", "OpenProcess", "int", 2035711, "int", False, "int", @AutoItPID )
    If Not @error Then Return DllCall ( "psapi.dll", "int", "EmptyWorkingSet", "long", $_Handle[0] )
EndFunc ;==> _ReduceMemory ( )

Func _Exit ( )
    ToolTip ( '' )
    _ImageDispose ( $_Image1 )
    Exit
EndFunc ;==> _Exit

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • 1 year later...

wakillon, Where have you been my whole life?

On a more serious note, this little UDF is simply amazing. Nice work. :thumbsup:

Thanks BinaryBrother !

by the same occasion i have cleaned script and re-uploaded missing pngs in

:)

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

  • 8 months later...
  • 11 months later...

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...