Page 1 sur 1

[R] Agrandir une image dans interface avec GIFANIMATION  

Posté : mar. 14 juil. 2020 19:45
par franco
Bonjour.


Suite à un projet de visualisation d'image (et aussi de gif animé), j'aimerais trouver un moyen de "redimensionner" l'interface (GUI) ET l'image concernée également.

J'utilise donc GIFAnimation
- https://code.google.com/archive/p/gif-a ... /downloads
- https://www.autoitscript.com/forum/topi ... animation/

Je pensais y arriver, mais, à ma grande surprise : l'image redimensionnée l'est mal.
- Soit elle sort (un peu) du cadre.
- Soit tronquée
- Soit "réduite".

Voici le code en question - que j'ai volontairement réduit autant que possible, afin de me consacrer uniquement au sujet.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GIFAnimation.au3>

$image = 'carre.gif'

Global $Form1 = GUICreate("Form1", 200, 200, 192, 124, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetBkColor(0xFFFFFF, $Form1)
$img = _GUICtrlCreateGIF($image, "", 0, 0, 200, 200)



GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit

      Case $GUI_EVENT_RESIZED

         $pos = WinGetPos($Form1)
         $NLargeur = $pos[2]
         $NHauteur = $pos[3]

         _GIF_DeleteGIF($img)
         $img = _GUICtrlCreateGIF($image, "", 0, 0, $NLargeur, $NHauteur)

         GUISetBkColor(0xFFFFFF, $Form1)
         _WinAPI_SetLayeredWindowAttributes($Form1, 0xFFFFFF, 250)


   EndSwitch
WEnd
l'image utilisée en question : https://i.imgur.com/ch3t4i0.gif
carre.gif
carre.gif (761 Octets) Vu 2552 fois
Petite remarque : quand il s'agit d'image animé, c'est là que survient le souci.
Sinon, non.


Pouvez-vous me dire où j'ai "foiré" ?

Peut-être qu'il y a un moyen plus simple, mais honnêtement, même si c'est pas au point, c'est le seul qui arrive à ce résultat. ^^


Merci pour vos réponses.
++

Re: [..] Agrandir une image dans interface avec GIFANIMATION

Posté : mer. 15 juil. 2020 16:04
par walkson
Bonjour,
J'ai rajouté l'image dans votre commentaire pour qu'elle ne se perde pas avec le temps
Sinon, j'ai cela à vous proposer avec le fond transparent (c'est ce que vous vouliez ?)

Code : Tout sélectionner

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GIFAnimation.au3>

$image = @ScriptDir & '\carre.gif'

Global $Form1 = GUICreate("Form1", 200, 200, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_THICKFRAME) , $WS_EX_LAYERED)
GUISetBkColor(0xabcdef, $Form1)
$img = _GUICtrlCreateGIF($image, "", 0, 0, 200, 200)
_WinAPI_SetLayeredWindowAttributes($Form1, 0xabcdef)


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
; Additional processing of some windows messages (for example)
GUIRegisterMsg(133, "_Refresh") ; WM_NCPAINT
GUIRegisterMsg(15, "_ValidateGIFs") ; WM_PAINT
While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit

      Case $GUI_EVENT_RESIZED

         $pos = WinGetPos($Form1)
         $NLargeur = $pos[2] - 20
         $NHauteur = $pos[3] - 40

         _GIF_DeleteGIF($img)
         $img = _GUICtrlCreateGIF($image, "", 0, 0, $NLargeur, $NHauteur)

         ;GUISetBkColor(0xFFFFFF, $Form1)
         _WinAPI_SetLayeredWindowAttributes($Form1, 0xabcdef)


   EndSwitch
WEnd
Func _Refresh($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    _GIF_RefreshGIF($img)

EndFunc ;==>_Refresh

Func _ValidateGIFs($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    _GIF_ValidateGIF($img)

EndFunc ;==>_ValidateGIFs

Re: [..] Agrandir une image dans interface avec GIFANIMATION

Posté : mer. 15 juil. 2020 22:52
par franco
Salut.


En fait, pour la transparence : non, cela n'a aucune importance.
Bien que ça peut me servir plus tard.

Le fait est qu'avec ton script, j'arrive à redimensionner correctement le gif animé que j'ai (
blblbl.gif
blblbl.gif (26.31 Kio) Vu 2539 fois
)
Mais ensuite, la fenêtre n'est plus redimensionnable...

j'ai néanmoins (comme le phynx) regardé le script, et j'ai vu ce que tu avais modifié pour que le redimensionnement se passe sans souci.


Du coup, j'ai adapté mon script, et ça fonctionne.


Donc merci à toi, c'est résolu :D


Le script final ( si on peut dire cela comme ça ^^)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GIFAnimation.au3>

$image = 'blblbl.gif'

Global $Form1 = GUICreate("Form1", 200, 200, 192, 124, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetBkColor(0xFFFFFF, $Form1)
$img = _GUICtrlCreateGIF($image, "", 0, 0, 200, 200)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)

;~ GUICtrlSetResizing(-1, $GUI_DOCKAUTO + $GUI_DOCKSTATEBAR)



GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit

      Case $GUI_EVENT_RESIZED

         $pos = WinGetPos($Form1)
         $NLargeur = $pos[2]-20
         $NHauteur = $pos[3]-40

         _GIF_DeleteGIF($img)
         $img = _GUICtrlCreateGIF($image, "", -1,-1, $NLargeur, $NHauteur)

         GUISetBkColor(0xFFFFFF, $Form1)
         _WinAPI_SetLayeredWindowAttributes($Form1, 0xFFFFFF, 250)


   EndSwitch
WEnd

++