ホーム › Devices.Display › COLORSPACE_TRANSFORM_3x4
COLORSPACE_TRANSFORM_3x4
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ColorMatrix3x4 | FLOAT | 48 | +0 | +0 | 3行4列の色変換行列を表す浮動小数点配列。線形変換と平行移動を含む。 |
| ScalarMultiplier | FLOAT | 4 | +48 | +48 | 色値全体に乗じるスカラ係数を表す浮動小数点値。 |
| LookupTable1D | GAMMA_RAMP_RGB | 49152 | +52 | +52 | 適用する1次元ルックアップテーブルをGAMMA_RAMP_RGBで保持する。 |
各言語での定義
#include <windows.h>
// GAMMA_RAMP_RGB (x64 12 / x86 12 バイト)
typedef struct GAMMA_RAMP_RGB {
FLOAT Red;
FLOAT Green;
FLOAT Blue;
} GAMMA_RAMP_RGB;
// COLORSPACE_TRANSFORM_3x4 (x64 49204 / x86 49204 バイト)
typedef struct COLORSPACE_TRANSFORM_3x4 {
FLOAT ColorMatrix3x4[12];
FLOAT ScalarMultiplier;
GAMMA_RAMP_RGB LookupTable1D[4096];
} COLORSPACE_TRANSFORM_3x4;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct GAMMA_RAMP_RGB
{
public float Red;
public float Green;
public float Blue;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct COLORSPACE_TRANSFORM_3x4
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public float[] ColorMatrix3x4;
public float ScalarMultiplier;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4096)] public GAMMA_RAMP_RGB[] LookupTable1D;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure GAMMA_RAMP_RGB
Public Red As Single
Public Green As Single
Public Blue As Single
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure COLORSPACE_TRANSFORM_3x4
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> Public ColorMatrix3x4() As Single
Public ScalarMultiplier As Single
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=4096)> Public LookupTable1D() As GAMMA_RAMP_RGB
End Structureimport ctypes
from ctypes import wintypes
class GAMMA_RAMP_RGB(ctypes.Structure):
_fields_ = [
("Red", ctypes.c_float),
("Green", ctypes.c_float),
("Blue", ctypes.c_float),
]
class COLORSPACE_TRANSFORM_3x4(ctypes.Structure):
_fields_ = [
("ColorMatrix3x4", ctypes.c_float * 12),
("ScalarMultiplier", ctypes.c_float),
("LookupTable1D", GAMMA_RAMP_RGB * 4096),
]#[repr(C)]
pub struct GAMMA_RAMP_RGB {
pub Red: f32,
pub Green: f32,
pub Blue: f32,
}
#[repr(C)]
pub struct COLORSPACE_TRANSFORM_3x4 {
pub ColorMatrix3x4: [f32; 12],
pub ScalarMultiplier: f32,
pub LookupTable1D: [GAMMA_RAMP_RGB; 4096],
}import "golang.org/x/sys/windows"
type GAMMA_RAMP_RGB struct {
Red float32
Green float32
Blue float32
}
type COLORSPACE_TRANSFORM_3x4 struct {
ColorMatrix3x4 [12]float32
ScalarMultiplier float32
LookupTable1D [4096]GAMMA_RAMP_RGB
}type
GAMMA_RAMP_RGB = record
Red: Single;
Green: Single;
Blue: Single;
end;
COLORSPACE_TRANSFORM_3x4 = record
ColorMatrix3x4: array[0..11] of Single;
ScalarMultiplier: Single;
LookupTable1D: array[0..4095] of GAMMA_RAMP_RGB;
end;const GAMMA_RAMP_RGB = extern struct {
Red: f32,
Green: f32,
Blue: f32,
};
const COLORSPACE_TRANSFORM_3x4 = extern struct {
ColorMatrix3x4: [12]f32,
ScalarMultiplier: f32,
LookupTable1D: [4096]GAMMA_RAMP_RGB,
};type
GAMMA_RAMP_RGB {.bycopy.} = object
Red: float32
Green: float32
Blue: float32
COLORSPACE_TRANSFORM_3x4 {.bycopy.} = object
ColorMatrix3x4: array[12, float32]
ScalarMultiplier: float32
LookupTable1D: array[4096, GAMMA_RAMP_RGB]struct GAMMA_RAMP_RGB
{
float Red;
float Green;
float Blue;
}
struct COLORSPACE_TRANSFORM_3x4
{
float[12] ColorMatrix3x4;
float ScalarMultiplier;
GAMMA_RAMP_RGB[4096] LookupTable1D;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; COLORSPACE_TRANSFORM_3x4 サイズ: 49204 バイト(x64)
dim st, 12301 ; 4byte整数×12301(構造体サイズ 49204 / 4 切り上げ)
; ColorMatrix3x4 : FLOAT (+0, 48byte) varptr(st)+0 を基点に操作(48byte:入れ子/配列)
; ScalarMultiplier : FLOAT (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; LookupTable1D : GAMMA_RAMP_RGB (+52, 49152byte) varptr(st)+52 を基点に操作(49152byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GAMMA_RAMP_RGB
#field float Red
#field float Green
#field float Blue
#endstruct
#defstruct global COLORSPACE_TRANSFORM_3x4
#field float ColorMatrix3x4 12
#field float ScalarMultiplier
#field GAMMA_RAMP_RGB LookupTable1D 4096
#endstruct
stdim st, COLORSPACE_TRANSFORM_3x4 ; NSTRUCT 変数を確保
st->ScalarMultiplier = 100
mes "ScalarMultiplier=" + st->ScalarMultiplier