Page 1 sur 1
[R] .PNG et GDIPlus.au3
Posté : sam. 23 nov. 2013 18:53
par Amesamana
Bonjour,
L'image .png disparait si je déplace la gui dans le barre de tâche même voir que la moitié de l'image .png ???
Idem si je déplace une autre fenêtre par dessus la GUI.
Même compilé j'ai le même résultat.
Savez-vous pourquoi ?
Merci
► Afficher le texteShowPNG.au3
Code : Tout sélectionner
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
; ===============================================================================================================================
; Description ...: Shows how to display a PNG image
; Author ........: Paul Campbell (PaulIA)
; Notes .........:
; ===============================================================================================================================
; ===============================================================================================================================
; Global variables
; ===============================================================================================================================
Global $hGUI, $hImage, $hGraphic
; Create GUI
$hGUI = GUICreate("Show PNG", 240, 240)
GUISetState()
; Load PNG image
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("..\Torus.png")
; Draw PNG image
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Re: [..] .PNG et GDIPlus.au3
Posté : sam. 23 nov. 2013 21:57
par TT22
Salut, la solution la plus simple est de redessiner l'image en continu dans la boucle :
Code : Tout sélectionner
; Loop until user exits
Do
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Re: [..] .PNG et GDIPlus.au3
Posté : dim. 24 nov. 2013 01:26
par mikell
Titoo, ok c'est la solution la plus simple mais bonjour la charge cpu ^^
► Afficher le texte
Code : Tout sélectionner
#include <GDIPlus.au3>
$image = "G:\Program Files\AutoIt3\Examples\GUI\Torus.png" ; chemin perso
$hGUI = GUICreate("GDI+", 200, 200)
$Pic = GUICtrlCreatePic("", 0, 0, 200, 200)
GUISetState()
_SetPic($hGui, GuiCtrlGetHandle($Pic), $image)
Do
Until GUIGetMsg() = -3 ;$GUI_EVENT_CLOSE
;===================================================
Func _SetPic($hWnd, $hPic, $png)
Local $aBmp, $hbmp, $MainImage, $MainGraphic, $hGraphic
_GDIPlus_Startup()
; on charge le png
$hImg = _GDIPlus_ImageLoadFromFile($png)
$w = _GDIPlus_ImageGetWidth($hImg)
$h = _GDIPlus_ImageGetHeight($hImg)
; on crée une image
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$MainImage = _GDIPlus_BitmapCreateFromGraphics(200, 200, $hGraphic)
$MainGraphic = _GDIPlus_ImageGetGraphicsContext($MainImage)
; on y met ce qu'on veut
_GDIPlus_GraphicsDrawImageRect($MainGraphic, $hImg, 10, 10, $w, $h)
; on balance l'image dans le controle
$hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($MainImage)
$aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hPic, "int", "0x0172", "int", "0", "int", $hbmp)
If $aBmp[0] <> 0 Then _WinAPI_DeleteObject($aBmp[0])
_WinAPI_DeleteObject($hbmp)
; et on fait le ménage
_GDIPlus_ImageDispose($hImg)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($MainImage)
_GDIPlus_GraphicsDispose($MainGraphic)
_GDIPlus_Shutdown()
EndFunc
Re: [..] .PNG et GDIPlus.au3
Posté : dim. 24 nov. 2013 12:14
par Amesamana
Bonjour,
Merci ça fonctionne nickel
