vous permet d'afficher les formats d'images non supportés par cette dernière (comme les *.png)
$src = chemin du fichier
$x = position X du contrôle
$y = position Y du contrôle
$scale = 1 ratio d'agrandissement ou de réduction de l'image ( un ratio de 1 = dimensions de l'image)
$alt = "texte à afficher lors du survol de l'image"
* Scale n'est pas parfait et si vous changez la grandeur de l'image, il est possible qu'une "ombre" apparaisse sur l'image.
Si vous en connaissez la cause, n'hésitez pas à m'en faire part. Si laissé à 1, il n'y a aucun problème.
Code : Tout sélectionner
#include<gdiplus.au3>
; Func PngGuiCreatePic($src, $x, $y, $scale = 1, $alt = "",$gdi = 1)
Func PngGuiCreatePic($src, $x, $y, $scale = 1, $alt = "")
Local $gdi_state = $ghGDIPDll
If $ghGDIPDll = 0 Then _GDIPlus_Startup()
$hImage2 = _GDIPlus_ImageLoadFromFile($src)
$ImageHeight = (_GDIPlus_ImageGetHeight($hImage2)) * $scale
$ImageWidth = (_GDIPlus_ImageGetWidth($hImage2)) * $scale
If $scale <> 1 Then
$hBitmap = _WinAPI_CreateBitmap($ImageWidth, $ImageHeight, 1, 32)
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
$hgraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
_GDIPlus_GraphicsDrawImageRect($hgraphic, $hImage2, 0, 0, $ImageWidth, $ImageHeight)
$hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_GraphicsDispose($hgraphic)
Else
Local _
$hBitmap = _GDIPlus_BitmapCreateFromFile($src), _
$hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
EndIf
$pic = GUICtrlCreatePic("", $x, $y, $ImageWidth, $ImageHeight)
If $alt <> "" Then GUICtrlSetTip($pic, $alt)
GUICtrlSendMsg($pic, 0x0172, 0, $hBitmap2)
If $gdi_state = 0 Then _GDIPlus_Shutdown()
Return $pic
EndFunc ;==>PngGuiCreatePic