Function Reference

_GDIPlus_ImageGetPixelFormat

画像のピクセルフォーマットを返します。1ピクセルあたりのビット数、アルファチャンネル、グレースケール、インデックスetc...

#Include <GDIPlus.au3>
_GDIPlus_ImageGetPixelFormat($hImage)

 

パラメータ

$hImage Imageオブジェクトのハンドル

 

返し値

成功: 次のフォーマットの配列
[0] - - ピクセルフォーマット定数の整数
[1] - - ピクセルフォーマット文字列
失敗: 空の配列を返し@errorを設定します。@extended にはエラー位置を設定します。
@error: 0 - 正常終了
10 - 無効な画像ハンドル

 

注意

@errorが4のエラー時にはGDI+UDFは画像ハンドルの代わりに-1または0を返します。

 

関連

_GDIPlus_ImageGetFlags, _GDIPlus_BitmapLockBits, _GDIPlus_BitmapCloneArea

 

こちらも参照

MSDNライブラリでGdipGetImagePixelFormatを検索して下さい。

 


#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>


Opt('MustDeclareVars', 1)

Global $iMemo

_Main()

Func _Main()
    Local $hBitmap, $hImage, $aRet

    ; GUI作成
    GUICreate("GDI+", 600, 400)
    $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; GDI+ライブラリを初期化
    _GDIPlus_Startup()

    ; 32ビットのビットマップをキャプチャ
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; スクリーンキャプチャのピクセルフォーマットを表示
    $aRet = _GDIPlus_ImageGetPixelFormat($hImage)
    MemoWrite("Image pixel format of screen capture: " & $aRet[1]);
    MemoWrite("Image pixel format constant: " & $aRet[0]);
    MemoWrite();

    ; スクリーンキャプチャビットマップをファイルに保存
    _GDIPlus_ImageSaveToFile($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; リソースを破棄
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; スクリーンキャプチャビットマップをファイルからロード
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; 保存されたファイルのピクセルフォーマットを表示
    $aRet = _GDIPlus_ImageGetPixelFormat($hImage)
    MemoWrite("Image pixel format of saved file: " & $aRet[1]);
    MemoWrite("Image pixel format constant: " & $aRet[0]);

    ; リソースを破棄
    _GDIPlus_ImageDispose($hImage)

    ; GDI+ライブラリを閉じる
    _GDIPlus_Shutdown()

    ; ユーザーが終了するまでループ
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; メモコントロールに1行書き込み
Func MemoWrite($sMessage = '')
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite