#Include <APIConstants.au3>
#Include <GDIP.au3>
#Include <WinAPIEx.au3>
_GDIPlus_Startup()
$hForm = GUICreate('MyGUI', 256, 256, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
GUISetState(@SW_SHOWNOACTIVATE)
_ShowPreview($hForm, _CreatePreview(_GDIPlus_ImageLoadFromFile(@ScriptDir & '\Test.png'), 256, 256, 1), -1, -1, 80, 1)
Do
Until GUIGetMsg() = -3
Func _CreatePreview($hImage, $iWidth, $iHeight, $fDelete = 0)
Local $K[2], $Size, $hGraphics, $hBrush, $hPreview
$Size = _GDIPlus_ImageGetDimension($hImage)
If Not IsArray($Size) Then
Return 0
EndIf
If ($iWidth - 2) < $Size[0] Then
$K[0] = ($iWidth - 2) / $Size[0]
Else
$K[0] = 1
EndIf
If ($iHeight - 2) < $Size[1] Then
$K[1] = ($iHeight - 2) / $Size[1]
Else
$K[1] = 1
EndIf
For $i = 0 To 1
If $K[1] > $K[0] Then
$Size[$i] *= $K[0]
Else
$Size[$i] *= $K[1]
EndIf
Next
$hPreview = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hPreview)
$hBrush = _GDIPlus_HatchBrushCreate($HatchStyleLargeCheckerBoard, 0xFFFFFFFF, 0xFFEBEBEB)
_GDIPlus_GraphicsClear($hGraphics, 0xFF969696)
_GDIPlus_GraphicsFillRect($hGraphics, 1, 1, $iWidth - 2, $iHeight - 2, $hBrush)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, Round(($iWidth - $Size[0]) / 2), Round(($iHeight - $Size[1]) / 2), $Size[0], $Size[1])
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BrushDispose($hBrush)
If ($hPreview) And ($fDelete) Then
_GDIPlus_ImageDispose($hImage)
EndIf
Return $hPreview
EndFunc ;==>_CreatePreview
Func _ShowPreview($hWnd, $hPreview, $iX, $iY, $iSpeed = 100, $fDelete = 0)
Local $W, $H, $Size, $Timer, $Delay, $hGraphics, $hImage
If Not IsHWnd($hWnd) Then
Return 0
EndIf
$Size = _GDIPlus_ImageGetDimension($hPreview)
If Not IsArray($Size) Then
Return 0
EndIf
If ($iX <> -1) And ($iY <> -1) Then
$iX -= $Size[0] / 2
$iY -= $Size[1] / 2
EndIf
$hImage = _GDIPlus_BitmapCreateFromScan0($Size[0], $Size[1])
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)
For $i = 15 To 255 Step 40
$Timer = TimerInit()
If $i = 255 Then
$W = $Size[0]
$H = $Size[1]
Else
$W = Round($Size[0] * Sin(2 * ATan(1) * $i / 255))
If Mod($W, 2) Then
$W += 1
EndIf
$H = Round($Size[1] * Sin(2 * ATan(1) * $i / 255))
If Mod($H, 2) Then
$H += 1
EndIf
EndIf
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hPreview, ($Size[0] - $W) / 2, ($Size[1] - $H) / 2, $W, $H)
_WinAPI_UpdateLayeredWindowEx($hWnd, $iX, $iY, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage), $i, 1)
$Delay = $iSpeed / 7 - TimerDiff($Timer)
If $Delay < 0 Then
$Delay = 0
EndIf
$Timer = TimerInit()
Do
Until TimerDiff($Timer) >= $Delay
Next
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($hImage)
If $fDelete Then
_GDIPlus_ImageDispose($hPreview)
EndIf
Return 1
EndFunc ;==>_ShowPreview