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