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操作対象のGpImageAttributesオブジェクトへのポインタ。
typeColorAdjustTypein適用対象のカテゴリを示すColorAdjustType列挙値。
enableFlagBOOLin色行列調整を有効にするかを示すBOOL(FALSEで無効化)。
colorMatrixColorMatrix*in色変換に用いる5x5のColorMatrix構造体へのポインタ。
grayMatrixColorMatrix*inグレースケール調整に用いるColorMatrixへのポインタ。flags次第でNULL可。
flagsColorMatrixFlagsin行列の適用方法を示すColorMatrixFlags列挙値(Default/SkipGrays/AltGray)。

戻り値の型: 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)。
const std = @import("std");

extern "gdiplus" fn GdipSetImageAttributesColorMatrix(
    imageattr: [*c]GpImageAttributes, // GpImageAttributes* in/out
    type: i32, // ColorAdjustType
    enableFlag: i32, // BOOL
    colorMatrix: [*c]ColorMatrix, // ColorMatrix*
    grayMatrix: [*c]ColorMatrix, // ColorMatrix*
    flags: i32 // ColorMatrixFlags
) callconv(std.os.windows.WINAPI) i32;
proc GdipSetImageAttributesColorMatrix(
    imageattr: ptr GpImageAttributes,  # GpImageAttributes* in/out
    `type`: int32,  # ColorAdjustType
    enableFlag: int32,  # BOOL
    colorMatrix: ptr ColorMatrix,  # ColorMatrix*
    grayMatrix: ptr ColorMatrix,  # ColorMatrix*
    flags: int32  # ColorMatrixFlags
): int32 {.importc: "GdipSetImageAttributesColorMatrix", stdcall, dynlib: "gdiplus.dll".}
pragma(lib, "gdiplus");
extern(Windows)
int GdipSetImageAttributesColorMatrix(
    GpImageAttributes* imageattr,   // GpImageAttributes* in/out
    int type,   // ColorAdjustType
    int enableFlag,   // BOOL
    ColorMatrix* colorMatrix,   // ColorMatrix*
    ColorMatrix* grayMatrix,   // ColorMatrix*
    int flags   // ColorMatrixFlags
);
ccall((:GdipSetImageAttributesColorMatrix, "gdiplus.dll"), stdcall, Int32,
      (Ptr{GpImageAttributes}, Int32, Int32, Ptr{ColorMatrix}, Ptr{ColorMatrix}, Int32),
      imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)
# imageattr : GpImageAttributes* in/out -> Ptr{GpImageAttributes}
# type : ColorAdjustType -> Int32
# enableFlag : BOOL -> Int32
# colorMatrix : ColorMatrix* -> Ptr{ColorMatrix}
# grayMatrix : ColorMatrix* -> Ptr{ColorMatrix}
# flags : ColorMatrixFlags -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GdipSetImageAttributesColorMatrix(
    void* imageattr,
    int32_t type,
    int32_t enableFlag,
    void* colorMatrix,
    void* grayMatrix,
    int32_t flags);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)
-- imageattr : GpImageAttributes* in/out
-- type : ColorAdjustType
-- enableFlag : BOOL
-- colorMatrix : ColorMatrix*
-- grayMatrix : ColorMatrix*
-- flags : ColorMatrixFlags
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipSetImageAttributesColorMatrix = lib.func('__stdcall', 'GdipSetImageAttributesColorMatrix', 'int32_t', ['void *', 'int32_t', 'int32_t', 'void *', 'void *', 'int32_t']);
// GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)
// imageattr : GpImageAttributes* in/out -> 'void *'
// type : ColorAdjustType -> 'int32_t'
// enableFlag : BOOL -> 'int32_t'
// colorMatrix : ColorMatrix* -> 'void *'
// grayMatrix : ColorMatrix* -> 'void *'
// flags : ColorMatrixFlags -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("gdiplus.dll", {
  GdipSetImageAttributesColorMatrix: { parameters: ["pointer", "i32", "i32", "pointer", "pointer", "i32"], result: "i32" },
});
// lib.symbols.GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)
// imageattr : GpImageAttributes* in/out -> "pointer"
// type : ColorAdjustType -> "i32"
// enableFlag : BOOL -> "i32"
// colorMatrix : ColorMatrix* -> "pointer"
// grayMatrix : ColorMatrix* -> "pointer"
// flags : ColorMatrixFlags -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GdipSetImageAttributesColorMatrix(
    void* imageattr,
    int32_t type,
    int32_t enableFlag,
    void* colorMatrix,
    void* grayMatrix,
    int32_t flags);
C, "gdiplus.dll");
// $ffi->GdipSetImageAttributesColorMatrix(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags);
// imageattr : GpImageAttributes* in/out
// type : ColorAdjustType
// enableFlag : BOOL
// colorMatrix : ColorMatrix*
// grayMatrix : ColorMatrix*
// flags : ColorMatrixFlags
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Gdiplus extends StdCallLibrary {
    Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class);
    int GdipSetImageAttributesColorMatrix(
        Pointer imageattr,   // GpImageAttributes* in/out
        int type,   // ColorAdjustType
        boolean enableFlag,   // BOOL
        Pointer colorMatrix,   // ColorMatrix*
        Pointer grayMatrix,   // ColorMatrix*
        int flags   // ColorMatrixFlags
    );
}
@[Link("gdiplus")]
lib Libgdiplus
  fun GdipSetImageAttributesColorMatrix = GdipSetImageAttributesColorMatrix(
    imageattr : GpImageAttributes*,   # GpImageAttributes* in/out
    type_ : Int32,   # ColorAdjustType
    enableFlag : Int32,   # BOOL
    colorMatrix : ColorMatrix*,   # ColorMatrix*
    grayMatrix : ColorMatrix*,   # ColorMatrix*
    flags : Int32   # ColorMatrixFlags
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GdipSetImageAttributesColorMatrixNative = Int32 Function(Pointer<Void>, Int32, Int32, Pointer<Void>, Pointer<Void>, Int32);
typedef GdipSetImageAttributesColorMatrixDart = int Function(Pointer<Void>, int, int, Pointer<Void>, Pointer<Void>, int);
final GdipSetImageAttributesColorMatrix = DynamicLibrary.open('gdiplus.dll')
    .lookupFunction<GdipSetImageAttributesColorMatrixNative, GdipSetImageAttributesColorMatrixDart>('GdipSetImageAttributesColorMatrix');
// imageattr : GpImageAttributes* in/out -> Pointer<Void>
// type : ColorAdjustType -> Int32
// enableFlag : BOOL -> Int32
// colorMatrix : ColorMatrix* -> Pointer<Void>
// grayMatrix : ColorMatrix* -> Pointer<Void>
// flags : ColorMatrixFlags -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GdipSetImageAttributesColorMatrix"
  c_GdipSetImageAttributesColorMatrix :: Ptr () -> Int32 -> CInt -> Ptr () -> Ptr () -> Int32 -> IO Int32
-- imageattr : GpImageAttributes* in/out -> Ptr ()
-- type : ColorAdjustType -> Int32
-- enableFlag : BOOL -> CInt
-- colorMatrix : ColorMatrix* -> Ptr ()
-- grayMatrix : ColorMatrix* -> Ptr ()
-- flags : ColorMatrixFlags -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let gdipsetimageattributescolormatrix =
  foreign "GdipSetImageAttributesColorMatrix"
    ((ptr void) @-> int32_t @-> int32_t @-> (ptr void) @-> (ptr void) @-> int32_t @-> returning int32_t)
(* imageattr : GpImageAttributes* in/out -> (ptr void) *)
(* type : ColorAdjustType -> int32_t *)
(* enableFlag : BOOL -> int32_t *)
(* colorMatrix : ColorMatrix* -> (ptr void) *)
(* grayMatrix : ColorMatrix* -> (ptr void) *)
(* flags : ColorMatrixFlags -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)

(cffi:defcfun ("GdipSetImageAttributesColorMatrix" gdip-set-image-attributes-color-matrix :convention :stdcall) :int32
  (imageattr :pointer)   ; GpImageAttributes* in/out
  (type :int32)   ; ColorAdjustType
  (enable-flag :int32)   ; BOOL
  (color-matrix :pointer)   ; ColorMatrix*
  (gray-matrix :pointer)   ; ColorMatrix*
  (flags :int32))   ; ColorMatrixFlags
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GdipSetImageAttributesColorMatrix = Win32::API::More->new('gdiplus',
    'int GdipSetImageAttributesColorMatrix(LPVOID imageattr, int type, BOOL enableFlag, LPVOID colorMatrix, LPVOID grayMatrix, int flags)');
# my $ret = $GdipSetImageAttributesColorMatrix->Call($imageattr, $type, $enableFlag, $colorMatrix, $grayMatrix, $flags);
# imageattr : GpImageAttributes* in/out -> LPVOID
# type : ColorAdjustType -> int
# enableFlag : BOOL -> BOOL
# colorMatrix : ColorMatrix* -> LPVOID
# grayMatrix : ColorMatrix* -> LPVOID
# flags : ColorMatrixFlags -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型