Cr�e un objet bitmap � partir d'une ressource d'une application ou d'une DLL
#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromResource ( $hInst, $vResourceName )
$hInst | Handle d'une instance d'un module dont le fichier ex�cutable contient une ressource bitmap |
$vResourceName | La cha�ne du nom de la ressource ou l'identifiant de la ressource |
Succ�s: | Retourne le handle du nouvel objet Bitmap. |
�chec: | Retourne 0 et d�finit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*). |
Lorsque vous en avez termin� avec l'objet, appelez _GDIPlus_ImageDispose() pour lib�rer les ressources de l'objet.
_GDIPlus_ImageDispose, _WinAPI_GetModuleHandle
Consultez GdipCreateBitmapFromResource dans la Librairie MSDN.
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPIRes.au3> Example() Func Example() _GDIPlus_Startup() ; Initialise GDI+ Local Const $iWidth = 300, $iHeight = 300, $iBgColor = 0x404040 ; $iBgColor est au format RRGGBB Local $hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Cr�e une GUI de test GUISetBkColor($iBgColor, $hGUI) ; D�finit la couleur de fond de la GUI GUISetState(@SW_SHOW) Local $sAut2Exe = StringRegExpReplace(@AutoItExe, "\\\w+.exe", "\\Aut2Exe\\Aut2Exe.exe") ; Obtient le chemin vers le fichier Aut2Exe.exe If @AutoItX64 Then $sAut2Exe = StringRegExpReplace(@AutoItExe, "\\\w+.exe", "\\Aut2Exe\\Aut2Exe_X64.exe") Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Cr�e un objet graphique � partir d'un handle de fen�tre Local $hInst = _WinAPI_LoadLibrary($sAut2Exe) ; Mappe un module ex�cutable sp�cifi� dans l'espace d'adressage du processus appelant Local $hBitmap = _GDIPlus_BitmapCreateFromResource($hInst, "BMP_MAINLOGO") ; Charge la ressource bitmap "BMP_MAINLOGO" et la convertit au format bitmap GDI+ Local $iW = _GDIPlus_ImageGetWidth($hBitmap), $iH = _GDIPlus_ImageGetHeight($hBitmap) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, ($iWidth - $iW) / 2, ($iHeight - $iH) / 2) ; Affiche l'image dans la GUI centr�e Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Nettoie les ressources GDI+ _WinAPI_FreeLibrary($hInst) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit EndFunc ;==>Example