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

EMRSETCOLORADJUSTMENT

構造体
サイズx64: 32 バイト / x86: 32 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
emrEMR8+0+0共通レコードヘッダを表すEMR構造体。
ColorAdjustmentCOLORADJUSTMENT24+8+8設定する色調整パラメータを表すCOLORADJUSTMENT構造体。

各言語での定義

#include <windows.h>

// EMR  (x64 8 / x86 8 バイト)
typedef struct EMR {
    ENHANCED_METAFILE_RECORD_TYPE iType;
    DWORD nSize;
} EMR;

// COLORADJUSTMENT  (x64 24 / x86 24 バイト)
typedef struct COLORADJUSTMENT {
    WORD caSize;
    WORD caFlags;
    WORD caIlluminantIndex;
    WORD caRedGamma;
    WORD caGreenGamma;
    WORD caBlueGamma;
    WORD caReferenceBlack;
    WORD caReferenceWhite;
    SHORT caContrast;
    SHORT caBrightness;
    SHORT caColorfulness;
    SHORT caRedGreenTint;
} COLORADJUSTMENT;

// EMRSETCOLORADJUSTMENT  (x64 32 / x86 32 バイト)
typedef struct EMRSETCOLORADJUSTMENT {
    EMR emr;
    COLORADJUSTMENT ColorAdjustment;
} EMRSETCOLORADJUSTMENT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMR
{
    public uint iType;
    public uint nSize;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct COLORADJUSTMENT
{
    public ushort caSize;
    public ushort caFlags;
    public ushort caIlluminantIndex;
    public ushort caRedGamma;
    public ushort caGreenGamma;
    public ushort caBlueGamma;
    public ushort caReferenceBlack;
    public ushort caReferenceWhite;
    public short caContrast;
    public short caBrightness;
    public short caColorfulness;
    public short caRedGreenTint;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMRSETCOLORADJUSTMENT
{
    public EMR emr;
    public COLORADJUSTMENT ColorAdjustment;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMR
    Public iType As UInteger
    Public nSize As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure COLORADJUSTMENT
    Public caSize As UShort
    Public caFlags As UShort
    Public caIlluminantIndex As UShort
    Public caRedGamma As UShort
    Public caGreenGamma As UShort
    Public caBlueGamma As UShort
    Public caReferenceBlack As UShort
    Public caReferenceWhite As UShort
    Public caContrast As Short
    Public caBrightness As Short
    Public caColorfulness As Short
    Public caRedGreenTint As Short
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMRSETCOLORADJUSTMENT
    Public emr As EMR
    Public ColorAdjustment As COLORADJUSTMENT
End Structure
import ctypes
from ctypes import wintypes

class EMR(ctypes.Structure):
    _fields_ = [
        ("iType", wintypes.DWORD),
        ("nSize", wintypes.DWORD),
    ]

class COLORADJUSTMENT(ctypes.Structure):
    _fields_ = [
        ("caSize", ctypes.c_ushort),
        ("caFlags", ctypes.c_ushort),
        ("caIlluminantIndex", ctypes.c_ushort),
        ("caRedGamma", ctypes.c_ushort),
        ("caGreenGamma", ctypes.c_ushort),
        ("caBlueGamma", ctypes.c_ushort),
        ("caReferenceBlack", ctypes.c_ushort),
        ("caReferenceWhite", ctypes.c_ushort),
        ("caContrast", ctypes.c_short),
        ("caBrightness", ctypes.c_short),
        ("caColorfulness", ctypes.c_short),
        ("caRedGreenTint", ctypes.c_short),
    ]

class EMRSETCOLORADJUSTMENT(ctypes.Structure):
    _fields_ = [
        ("emr", EMR),
        ("ColorAdjustment", COLORADJUSTMENT),
    ]
#[repr(C)]
pub struct EMR {
    pub iType: u32,
    pub nSize: u32,
}

#[repr(C)]
pub struct COLORADJUSTMENT {
    pub caSize: u16,
    pub caFlags: u16,
    pub caIlluminantIndex: u16,
    pub caRedGamma: u16,
    pub caGreenGamma: u16,
    pub caBlueGamma: u16,
    pub caReferenceBlack: u16,
    pub caReferenceWhite: u16,
    pub caContrast: i16,
    pub caBrightness: i16,
    pub caColorfulness: i16,
    pub caRedGreenTint: i16,
}

#[repr(C)]
pub struct EMRSETCOLORADJUSTMENT {
    pub emr: EMR,
    pub ColorAdjustment: COLORADJUSTMENT,
}
import "golang.org/x/sys/windows"

type EMR struct {
	iType uint32
	nSize uint32
}

type COLORADJUSTMENT struct {
	caSize uint16
	caFlags uint16
	caIlluminantIndex uint16
	caRedGamma uint16
	caGreenGamma uint16
	caBlueGamma uint16
	caReferenceBlack uint16
	caReferenceWhite uint16
	caContrast int16
	caBrightness int16
	caColorfulness int16
	caRedGreenTint int16
}

type EMRSETCOLORADJUSTMENT struct {
	emr EMR
	ColorAdjustment COLORADJUSTMENT
}
type
  EMR = record
    iType: DWORD;
    nSize: DWORD;
  end;

  COLORADJUSTMENT = record
    caSize: Word;
    caFlags: Word;
    caIlluminantIndex: Word;
    caRedGamma: Word;
    caGreenGamma: Word;
    caBlueGamma: Word;
    caReferenceBlack: Word;
    caReferenceWhite: Word;
    caContrast: Smallint;
    caBrightness: Smallint;
    caColorfulness: Smallint;
    caRedGreenTint: Smallint;
  end;

  EMRSETCOLORADJUSTMENT = record
    emr: EMR;
    ColorAdjustment: COLORADJUSTMENT;
  end;
const EMR = extern struct {
    iType: u32,
    nSize: u32,
};

const COLORADJUSTMENT = extern struct {
    caSize: u16,
    caFlags: u16,
    caIlluminantIndex: u16,
    caRedGamma: u16,
    caGreenGamma: u16,
    caBlueGamma: u16,
    caReferenceBlack: u16,
    caReferenceWhite: u16,
    caContrast: i16,
    caBrightness: i16,
    caColorfulness: i16,
    caRedGreenTint: i16,
};

const EMRSETCOLORADJUSTMENT = extern struct {
    emr: EMR,
    ColorAdjustment: COLORADJUSTMENT,
};
type
  EMR {.bycopy.} = object
    iType: uint32
    nSize: uint32

  COLORADJUSTMENT {.bycopy.} = object
    caSize: uint16
    caFlags: uint16
    caIlluminantIndex: uint16
    caRedGamma: uint16
    caGreenGamma: uint16
    caBlueGamma: uint16
    caReferenceBlack: uint16
    caReferenceWhite: uint16
    caContrast: int16
    caBrightness: int16
    caColorfulness: int16
    caRedGreenTint: int16

  EMRSETCOLORADJUSTMENT {.bycopy.} = object
    emr: EMR
    ColorAdjustment: COLORADJUSTMENT
struct EMR
{
    uint iType;
    uint nSize;
}

struct COLORADJUSTMENT
{
    ushort caSize;
    ushort caFlags;
    ushort caIlluminantIndex;
    ushort caRedGamma;
    ushort caGreenGamma;
    ushort caBlueGamma;
    ushort caReferenceBlack;
    ushort caReferenceWhite;
    short caContrast;
    short caBrightness;
    short caColorfulness;
    short caRedGreenTint;
}

struct EMRSETCOLORADJUSTMENT
{
    EMR emr;
    COLORADJUSTMENT ColorAdjustment;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EMRSETCOLORADJUSTMENT サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; emr : EMR (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; ColorAdjustment : COLORADJUSTMENT (+8, 24byte)  varptr(st)+8 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global EMR
    #field int iType
    #field int nSize
#endstruct

#defstruct global COLORADJUSTMENT
    #field short caSize
    #field short caFlags
    #field short caIlluminantIndex
    #field short caRedGamma
    #field short caGreenGamma
    #field short caBlueGamma
    #field short caReferenceBlack
    #field short caReferenceWhite
    #field short caContrast
    #field short caBrightness
    #field short caColorfulness
    #field short caRedGreenTint
#endstruct

#defstruct global EMRSETCOLORADJUSTMENT
    #field EMR emr
    #field COLORADJUSTMENT ColorAdjustment
#endstruct

stdim st, EMRSETCOLORADJUSTMENT        ; NSTRUCT 変数を確保