[UDF] SplashPNG
Posté : mer. 24 août 2011 21:38
par karime1
bonjours,
je tient a dire tout dabord que le veritable script a ete crée par noman: http://autoitscript.fr/forum/viewtopic. ... 4542&hilit
j'ai utilisé cette fonction pour en faire un UDF avec plus d'options
faites en bon usage.
je tient a dire tout dabord que le veritable script a ete crée par noman: http://autoitscript.fr/forum/viewtopic. ... 4542&hilit
j'ai utilisé cette fonction pour en faire un UDF avec plus d'options
► Afficher le texteUDF
Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version : 3.3.6.1
Auteur: Sephiros e-mail: karim3_fs@yahoo.fr
Fonction du Script :
SplashPNGOn - SplashImageOn pour les PNG
SplashPNGOff - SplashImageOff pour les PNG
#ce ----------------------------------------------------------------------------
#include-once
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
Opt("MustDeclareVars", 0)
Global Const $AC_SRC_ALPHA = 1
; #FONCTION# ==============================================================================
; Nom ...........:
; Description ...: SplashImageOn pour les PNG
; Syntaxe .......: SplashPNGOn($Path_Logo[, $NomLogo])
; Paramètres ....: $Path_Logo - Chemin et nom du fichier PNG
; $NomLogo - Nom de la fenetre, default: Logo
; Valeurs Retour : $Array[2] pour SplashPNGOff
; Auteur ........: Sephiros
; Modifié .......:
; Remarques .....: Utilisez SplashPNGOff pour cacher l'image PNG
; Apparenté .....: SetBitmap
; =========================================================================================
Func SplashPNGOn($Path_Logo, $NomLogo = "Logo")
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($Path_Logo)
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
$GUI = GUICreate($NomLogo, $width, $height, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
SetBitmap($GUI, $hImage, 0)
GUISetState()
For $i = 0 To 255 Step 10
SetBitmap($GUI, $hImage, $i)
Next
Local $Array[2] = [$GUI, $hImage]
Return $Array
EndFunc ;==>SplashPNGOn
; #FONCTION# ==============================================================================
; Nom ...........: SplashPNGOff
; Description ...: SplashImageOff pour les PNG
; Syntaxe .......: SplashPNGOff($GUIAndImg[, $Direct])
; Paramètres ....: $GUIAndImg - Array donné par SplashPNGOn
; $Direct - cache directemnt la gui, default: 0 (non)
; Valeurs Retour :
; Auteur ........: Sephiros
; =========================================================================================
Func SplashPNGOff($GUIAndImg, $Direct = 0)
If $Direct = 0 Then
For $i = 255 To 0 Step -10
SetBitmap($GUIAndImg[0], $GUIAndImg[1], $i)
Next
EndIf
_WinAPI_DeleteObject($GUIAndImg[1])
_GDIPlus_Shutdown()
GUIDelete($GUIAndImg[0])
EndFunc ;==>SplashPNGOff
;========= Foncion interne ==============
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", $AC_SRC_ALPHA)
_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
► Afficher le texteExemples
Code : Tout sélectionner
#include "SplashPNG.au3"
;Exemple 1
$SplashVar = SplashPNGOn(@DesktopDir"\img.png")
sleep(2800)
SplashPNGOff($SplashVar, 1)
;Exemple 2
$SplashVar = SplashPNGOn(@DesktopDir&"\img.png","Mon Logo")
sleep(2800)
SplashPNGOff($SplashVar)