Win32 API 日本語リファレンス
ホームGraphics.GdiPlus › GdipSetImageAttributesColorMatrix

GdipSetImageAttributesColorMatrix

関数
イメージ属性に色変換用のカラーマトリックスを設定する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

// gdiplus.dll
#include <windows.h>

Status GdipSetImageAttributesColorMatrix(
    GpImageAttributes* imageattr,
    ColorAdjustType type,
    BOOL enableFlag,
    const ColorMatrix* colorMatrix,
    const ColorMatrix* grayMatrix,
    ColorMatrixFlags flags
);

パラメーター

名前方向
imageattrGpImageAttributes*inout
typeColorAdjustTypein
enableFlagBOOLin
colorMatrixColorMatrix*in
grayMatrixColorMatrix*in
flagsColorMatrixFlagsin

戻り値の型: Status

各言語での呼び出し定義

// gdiplus.dll
#include <windows.h>

Status GdipSetImageAttributesColorMatrix(
    GpImageAttributes* imageattr,
    ColorAdjustType type,
    BOOL enableFlag,
    const ColorMatrix* colorMatrix,
    const ColorMatrix* grayMatrix,
    ColorMatrixFlags flags
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipSetImageAttributesColorMatrix(
    IntPtr imageattr,   // GpImageAttributes* in/out
    int type,   // ColorAdjustType
    bool enableFlag,   // BOOL
    IntPtr colorMatrix,   // ColorMatrix*
    IntPtr grayMatrix,   // ColorMatrix*
    int flags   // ColorMatrixFlags
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipSetImageAttributesColorMatrix(
    imageattr As IntPtr,   ' GpImageAttributes* in/out
    type As Integer,   ' ColorAdjustType
    enableFlag As Boolean,   ' BOOL
    colorMatrix As IntPtr,   ' ColorMatrix*
    grayMatrix As IntPtr,   ' ColorMatrix*
    flags As Integer   ' ColorMatrixFlags
) As Integer
End Function
' imageattr : GpImageAttributes* in/out
' type : ColorAdjustType
' enableFlag : BOOL
' colorMatrix : ColorMatrix*
' grayMatrix : ColorMatrix*
' flags : ColorMatrixFlags
Declare PtrSafe Function GdipSetImageAttributesColorMatrix Lib "gdiplus" ( _
    ByVal imageattr As LongPtr, _
    ByVal type As Long, _
    ByVal enableFlag As Long, _
    ByVal colorMatrix As LongPtr, _
    ByVal grayMatrix As LongPtr, _
    ByVal flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipSetImageAttributesColorMatrix = ctypes.windll.gdiplus.GdipSetImageAttributesColorMatrix
GdipSetImageAttributesColorMatrix.restype = ctypes.c_int
GdipSetImageAttributesColorMatrix.argtypes = [
    ctypes.c_void_p,  # imageattr : GpImageAttributes* in/out
    ctypes.c_int,  # type : ColorAdjustType
    wintypes.BOOL,  # enableFlag : BOOL
    ctypes.c_void_p,  # colorMatrix : ColorMatrix*
    ctypes.c_void_p,  # grayMatrix : ColorMatrix*
    ctypes.c_int,  # flags : ColorMatrixFlags
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipSetImageAttributesColorMatrix = Fiddle::Function.new(
  lib['GdipSetImageAttributesColorMatrix'],
  [
    Fiddle::TYPE_VOIDP,  # imageattr : GpImageAttributes* in/out
    Fiddle::TYPE_INT,  # type : ColorAdjustType
    Fiddle::TYPE_INT,  # enableFlag : BOOL
    Fiddle::TYPE_VOIDP,  # colorMatrix : ColorMatrix*
    Fiddle::TYPE_VOIDP,  # grayMatrix : ColorMatrix*
    Fiddle::TYPE_INT,  # flags : ColorMatrixFlags
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipSetImageAttributesColorMatrix(
        imageattr: *mut GpImageAttributes,  // GpImageAttributes* in/out
        type: i32,  // ColorAdjustType
        enableFlag: i32,  // BOOL
        colorMatrix: *const ColorMatrix,  // ColorMatrix*
        grayMatrix: *const ColorMatrix,  // ColorMatrix*
        flags: i32  // ColorMatrixFlags
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipSetImageAttributesColorMatrix(IntPtr imageattr, int type, bool enableFlag, IntPtr colorMatrix, IntPtr grayMatrix, int flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipSetImageAttributesColorMatrix' -Namespace Win32 -PassThru
# $api::GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)
#uselib "gdiplus.dll"
#func global GdipSetImageAttributesColorMatrix "GdipSetImageAttributesColorMatrix" sptr, sptr, sptr, sptr, sptr, sptr
; GdipSetImageAttributesColorMatrix varptr(imageattr), type, enableFlag, varptr(colorMatrix), varptr(grayMatrix), flags   ; 戻り値は stat
; imageattr : GpImageAttributes* in/out -> "sptr"
; type : ColorAdjustType -> "sptr"
; enableFlag : BOOL -> "sptr"
; colorMatrix : ColorMatrix* -> "sptr"
; grayMatrix : ColorMatrix* -> "sptr"
; flags : ColorMatrixFlags -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipSetImageAttributesColorMatrix "GdipSetImageAttributesColorMatrix" var, int, int, var, var, int
; res = GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)
; imageattr : GpImageAttributes* in/out -> "var"
; type : ColorAdjustType -> "int"
; enableFlag : BOOL -> "int"
; colorMatrix : ColorMatrix* -> "var"
; grayMatrix : ColorMatrix* -> "var"
; flags : ColorMatrixFlags -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipSetImageAttributesColorMatrix(GpImageAttributes* imageattr, ColorAdjustType type, BOOL enableFlag, ColorMatrix* colorMatrix, ColorMatrix* grayMatrix, ColorMatrixFlags flags)
#uselib "gdiplus.dll"
#cfunc global GdipSetImageAttributesColorMatrix "GdipSetImageAttributesColorMatrix" var, int, int, var, var, int
; res = GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)
; imageattr : GpImageAttributes* in/out -> "var"
; type : ColorAdjustType -> "int"
; enableFlag : BOOL -> "int"
; colorMatrix : ColorMatrix* -> "var"
; grayMatrix : ColorMatrix* -> "var"
; flags : ColorMatrixFlags -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipSetImageAttributesColorMatrix = gdiplus.NewProc("GdipSetImageAttributesColorMatrix")
)

// imageattr (GpImageAttributes* in/out), type (ColorAdjustType), enableFlag (BOOL), colorMatrix (ColorMatrix*), grayMatrix (ColorMatrix*), flags (ColorMatrixFlags)
r1, _, err := procGdipSetImageAttributesColorMatrix.Call(
	uintptr(imageattr),
	uintptr(type),
	uintptr(enableFlag),
	uintptr(colorMatrix),
	uintptr(grayMatrix),
	uintptr(flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipSetImageAttributesColorMatrix(
  imageattr: Pointer;   // GpImageAttributes* in/out
  type: Integer;   // ColorAdjustType
  enableFlag: BOOL;   // BOOL
  colorMatrix: Pointer;   // ColorMatrix*
  grayMatrix: Pointer;   // ColorMatrix*
  flags: Integer   // ColorMatrixFlags
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipSetImageAttributesColorMatrix';
result := DllCall("gdiplus\GdipSetImageAttributesColorMatrix"
    , "Ptr", imageattr   ; GpImageAttributes* in/out
    , "Int", type   ; ColorAdjustType
    , "Int", enableFlag   ; BOOL
    , "Ptr", colorMatrix   ; ColorMatrix*
    , "Ptr", grayMatrix   ; ColorMatrix*
    , "Int", flags   ; ColorMatrixFlags
    , "Int")   ; return: Status
●GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags) = DLL("gdiplus.dll", "int GdipSetImageAttributesColorMatrix(void*, int, bool, void*, void*, int)")
# 呼び出し: GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)
# imageattr : GpImageAttributes* in/out -> "void*"
# type : ColorAdjustType -> "int"
# enableFlag : BOOL -> "bool"
# colorMatrix : ColorMatrix* -> "void*"
# grayMatrix : ColorMatrix* -> "void*"
# flags : ColorMatrixFlags -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。