Redimensionne une image à une taille donnée
#include <GDIPlus.au3>
_GDIPlus_ImageResize ( $hImage, $iNewWidth, $iNewHeight [, $iInterpolationMode = $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC] )
$hImage | Handle de l'image |
$iNewWidth | La nouvelle largeur (nombre entier) |
$iNewHeight | La nouvelle hauteur (nombre entier) |
$iInterpolationMode | [optionnel] Le mode d'interpolation (nombre entier). Par défaut, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC. |
Succès: | Retourne le handle du nouvel objet Bitmap |
Échec: | Retourne 0 et définit @error <> 0. |
@error: | 1 - Impossible de créer un nouveau bitmap 2 - Impossible de créer le contexte graphique 3 - Impossible de régler le mode d'interpolation sur le contexte graphique 4 - Impossible de copier l'image dans le bitmap redimensionné |
_GDIPlus_BitmapCreateFromScan0, _GDIPlus_GraphicsDrawImageRect, _GDIPlus_GraphicsSetInterpolationMode, _GDIPlus_ImageGetGraphicsContext
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> Example() Func Example() _GDIPlus_Startup() Local Const $iW = @DesktopWidth, $iH = @DesktopHeight Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH) ; Crée un bitmap GDI en capturant le bureau en entier Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ; Convertit le bitmap GDI en GDI+ _WinAPI_DeleteObject($hHBmp) ; Libère la ressource du bitmap GDI car elle n'est plus utile Local $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap, $iW / 4, $iH / 4) ; Redimensionne l'image Local $hGUI = GUICreate("GDI+ test", $iW / 4, $iH / 4, -1, -1) ; Crée une GUI de test pour afficher l'image redimensionnée GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Crée un objet Graphics à partir du handle de la fenêtre _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ; Affiche l'image redimensionnée Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Nettoie les ressources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_Scaled) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example