Retourne le format des pixels d'une image: bits par pixel, les canaux alpha et RVB, niveaux de gris, index�s, etc.
#include <GDIPlus.au3>
_GDIPlus_ImageGetPixelFormat ( $hImage )
$hImage | Handle de l'objet image |
Succ�s: | Retourne un tableau avec le format suivant: [0] - Constante du format de pixel [1] - Cha�ne de format de pixel |
�chec: | D�finit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*). |
@error: | 10 - Le format de pixel est invalide. 11 - Le handle de l'image est invalide. 12 - Le format de pixel est inconnu. |
_GDIPlus_BitmapCloneArea, _GDIPlus_BitmapLockBits, _GDIPlus_ImageGetFlags
Consultez GdipGetImagePixelFormat dans la Librairie MSDN.
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> #include <WindowsConstants.au3> Global $g_idMemo Example() Func Example() Local $hBitmap, $hImage, $aRet ; Cr�e une GUI GUICreate("GDI+", 600, 400) $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; Initialise la biblioth�que GDI+ _GDIPlus_Startup() ; Capture un bitmap 32 bits $hBitmap = _ScreenCapture_Capture("") $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) ; Affiche le format de pixel pour la capture d'�cran $aRet = _GDIPlus_ImageGetPixelFormat($hImage) MemoWrite("Image pixel format of screen capture: " & $aRet[1]); MemoWrite("Image pixel format constant: " & $aRet[0]); MemoWrite(); ; Enregistre le bitmap de la capture d'�cran dans un fichier _GDIPlus_ImageSaveToFile($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg") ; Nettoie les ressources _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBitmap) ; Charge le bitmap de la capture d'�cran � partir du fichier $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg") ; Affiche le format de pixel du fichier sauvegard� $aRet = _GDIPlus_ImageGetPixelFormat($hImage) MemoWrite("Image pixel format of saved file: " & $aRet[1]); MemoWrite("Image pixel format constant: " & $aRet[0]); ; Nettoie les ressources _GDIPlus_ImageDispose($hImage) ; Arr�te la biblioth�que GDI+ _GDIPlus_Shutdown() ; Boucle jusqu'� ce que l'utilisateur quitte. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; �crit une ligne dans le contr�le m�mo Func MemoWrite($sMessage = '') GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite