ホーム › UI.ColorSystem › COLOR
COLOR
共用体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| gray | GRAYCOLOR | 2 | +0 | +0 | グレースケール色として解釈する共用体メンバ。 |
| rgb | RGBCOLOR | 6 | +0 | +0 | RGB色として解釈する共用体メンバ。 |
| cmyk | CMYKCOLOR | 8 | +0 | +0 | CMYK色として解釈する共用体メンバ。 |
| XYZ | XYZCOLOR | 6 | +0 | +0 | CIE XYZ色として解釈する共用体メンバ。 |
| Yxy | YxyCOLOR | 6 | +0 | +0 | Yxy色として解釈する共用体メンバ。 |
| Lab | LabCOLOR | 6 | +0 | +0 | CIE Lab色として解釈する共用体メンバ。 |
| gen3ch | GENERIC3CHANNEL | 6 | +0 | +0 | 汎用3チャネル色として解釈する共用体メンバ。 |
| named | NAMEDCOLOR | 4 | +0 | +0 | 名前付き色として解釈する共用体メンバ。 |
| hifi | HiFiCOLOR | 8 | +0 | +0 | ハイファイ(多チャネル)色として解釈する共用体メンバ。 |
| Anonymous | _Anonymous_e__Struct | 16/8 | +0 | +0 | 8チャネルまでの色値を保持する匿名構造体メンバ。 |
構造体: _Anonymous_e__Struct x64 16B / x86 8B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| reserved1 | DWORD | 4 | +0 | +0 |
| reserved2 | void* | 8/4 | +8 | +4 |
各言語での定義
#include <windows.h>
// GRAYCOLOR (x64 2 / x86 2 バイト)
typedef struct GRAYCOLOR {
WORD gray;
} GRAYCOLOR;
// RGBCOLOR (x64 6 / x86 6 バイト)
typedef struct RGBCOLOR {
WORD red;
WORD green;
WORD blue;
} RGBCOLOR;
// CMYKCOLOR (x64 8 / x86 8 バイト)
typedef struct CMYKCOLOR {
WORD cyan;
WORD magenta;
WORD yellow;
WORD black;
} CMYKCOLOR;
// XYZCOLOR (x64 6 / x86 6 バイト)
typedef struct XYZCOLOR {
WORD X;
WORD Y;
WORD Z;
} XYZCOLOR;
// YxyCOLOR (x64 6 / x86 6 バイト)
typedef struct YxyCOLOR {
WORD Y;
WORD x;
WORD y;
} YxyCOLOR;
// LabCOLOR (x64 6 / x86 6 バイト)
typedef struct LabCOLOR {
WORD L;
WORD a;
WORD b;
} LabCOLOR;
// GENERIC3CHANNEL (x64 6 / x86 6 バイト)
typedef struct GENERIC3CHANNEL {
WORD ch1;
WORD ch2;
WORD ch3;
} GENERIC3CHANNEL;
// NAMEDCOLOR (x64 4 / x86 4 バイト)
typedef struct NAMEDCOLOR {
DWORD dwIndex;
} NAMEDCOLOR;
// HiFiCOLOR (x64 8 / x86 8 バイト)
typedef struct HiFiCOLOR {
BYTE channel[8];
} HiFiCOLOR;
// COLOR (x64 16 / x86 8 バイト)
typedef struct COLOR {
GRAYCOLOR gray;
RGBCOLOR rgb;
CMYKCOLOR cmyk;
XYZCOLOR XYZ;
YxyCOLOR Yxy;
LabCOLOR Lab;
GENERIC3CHANNEL gen3ch;
NAMEDCOLOR named;
HiFiCOLOR hifi;
_Anonymous_e__Struct Anonymous;
} COLOR;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct GRAYCOLOR
{
public ushort gray;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RGBCOLOR
{
public ushort red;
public ushort green;
public ushort blue;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CMYKCOLOR
{
public ushort cyan;
public ushort magenta;
public ushort yellow;
public ushort black;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct XYZCOLOR
{
public ushort X;
public ushort Y;
public ushort Z;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct YxyCOLOR
{
public ushort Y;
public ushort x;
public ushort y;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LabCOLOR
{
public ushort L;
public ushort a;
public ushort b;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct GENERIC3CHANNEL
{
public ushort ch1;
public ushort ch2;
public ushort ch3;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NAMEDCOLOR
{
public uint dwIndex;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HiFiCOLOR
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] channel;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct COLOR
{
public GRAYCOLOR gray;
public RGBCOLOR rgb;
public CMYKCOLOR cmyk;
public XYZCOLOR XYZ;
public YxyCOLOR Yxy;
public LabCOLOR Lab;
public GENERIC3CHANNEL gen3ch;
public NAMEDCOLOR named;
public HiFiCOLOR hifi;
public _Anonymous_e__Struct Anonymous;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure GRAYCOLOR
Public gray As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RGBCOLOR
Public red As UShort
Public green As UShort
Public blue As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CMYKCOLOR
Public cyan As UShort
Public magenta As UShort
Public yellow As UShort
Public black As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure XYZCOLOR
Public X As UShort
Public Y As UShort
Public Z As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure YxyCOLOR
Public Y As UShort
Public x As UShort
Public y As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LabCOLOR
Public L As UShort
Public a As UShort
Public b As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure GENERIC3CHANNEL
Public ch1 As UShort
Public ch2 As UShort
Public ch3 As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NAMEDCOLOR
Public dwIndex As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure HiFiCOLOR
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public channel() As Byte
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure COLOR
Public gray As GRAYCOLOR
Public rgb As RGBCOLOR
Public cmyk As CMYKCOLOR
Public XYZ As XYZCOLOR
Public Yxy As YxyCOLOR
Public Lab As LabCOLOR
Public gen3ch As GENERIC3CHANNEL
Public named As NAMEDCOLOR
Public hifi As HiFiCOLOR
Public Anonymous As _Anonymous_e__Struct
End Structureimport ctypes
from ctypes import wintypes
class GRAYCOLOR(ctypes.Structure):
_fields_ = [
("gray", ctypes.c_ushort),
]
class RGBCOLOR(ctypes.Structure):
_fields_ = [
("red", ctypes.c_ushort),
("green", ctypes.c_ushort),
("blue", ctypes.c_ushort),
]
class CMYKCOLOR(ctypes.Structure):
_fields_ = [
("cyan", ctypes.c_ushort),
("magenta", ctypes.c_ushort),
("yellow", ctypes.c_ushort),
("black", ctypes.c_ushort),
]
class XYZCOLOR(ctypes.Structure):
_fields_ = [
("X", ctypes.c_ushort),
("Y", ctypes.c_ushort),
("Z", ctypes.c_ushort),
]
class YxyCOLOR(ctypes.Structure):
_fields_ = [
("Y", ctypes.c_ushort),
("x", ctypes.c_ushort),
("y", ctypes.c_ushort),
]
class LabCOLOR(ctypes.Structure):
_fields_ = [
("L", ctypes.c_ushort),
("a", ctypes.c_ushort),
("b", ctypes.c_ushort),
]
class GENERIC3CHANNEL(ctypes.Structure):
_fields_ = [
("ch1", ctypes.c_ushort),
("ch2", ctypes.c_ushort),
("ch3", ctypes.c_ushort),
]
class NAMEDCOLOR(ctypes.Structure):
_fields_ = [
("dwIndex", wintypes.DWORD),
]
class HiFiCOLOR(ctypes.Structure):
_fields_ = [
("channel", ctypes.c_ubyte * 8),
]
class COLOR(ctypes.Structure):
_fields_ = [
("gray", GRAYCOLOR),
("rgb", RGBCOLOR),
("cmyk", CMYKCOLOR),
("XYZ", XYZCOLOR),
("Yxy", YxyCOLOR),
("Lab", LabCOLOR),
("gen3ch", GENERIC3CHANNEL),
("named", NAMEDCOLOR),
("hifi", HiFiCOLOR),
("Anonymous", _Anonymous_e__Struct),
]#[repr(C)]
pub struct GRAYCOLOR {
pub gray: u16,
}
#[repr(C)]
pub struct RGBCOLOR {
pub red: u16,
pub green: u16,
pub blue: u16,
}
#[repr(C)]
pub struct CMYKCOLOR {
pub cyan: u16,
pub magenta: u16,
pub yellow: u16,
pub black: u16,
}
#[repr(C)]
pub struct XYZCOLOR {
pub X: u16,
pub Y: u16,
pub Z: u16,
}
#[repr(C)]
pub struct YxyCOLOR {
pub Y: u16,
pub x: u16,
pub y: u16,
}
#[repr(C)]
pub struct LabCOLOR {
pub L: u16,
pub a: u16,
pub b: u16,
}
#[repr(C)]
pub struct GENERIC3CHANNEL {
pub ch1: u16,
pub ch2: u16,
pub ch3: u16,
}
#[repr(C)]
pub struct NAMEDCOLOR {
pub dwIndex: u32,
}
#[repr(C)]
pub struct HiFiCOLOR {
pub channel: [u8; 8],
}
#[repr(C)]
pub struct COLOR {
pub gray: GRAYCOLOR,
pub rgb: RGBCOLOR,
pub cmyk: CMYKCOLOR,
pub XYZ: XYZCOLOR,
pub Yxy: YxyCOLOR,
pub Lab: LabCOLOR,
pub gen3ch: GENERIC3CHANNEL,
pub named: NAMEDCOLOR,
pub hifi: HiFiCOLOR,
pub Anonymous: _Anonymous_e__Struct,
}import "golang.org/x/sys/windows"
type GRAYCOLOR struct {
gray uint16
}
type RGBCOLOR struct {
red uint16
green uint16
blue uint16
}
type CMYKCOLOR struct {
cyan uint16
magenta uint16
yellow uint16
black uint16
}
type XYZCOLOR struct {
X uint16
Y uint16
Z uint16
}
type YxyCOLOR struct {
Y uint16
x uint16
y uint16
}
type LabCOLOR struct {
L uint16
a uint16
b uint16
}
type GENERIC3CHANNEL struct {
ch1 uint16
ch2 uint16
ch3 uint16
}
type NAMEDCOLOR struct {
dwIndex uint32
}
type HiFiCOLOR struct {
channel [8]byte
}
type COLOR struct {
gray GRAYCOLOR
rgb RGBCOLOR
cmyk CMYKCOLOR
XYZ XYZCOLOR
Yxy YxyCOLOR
Lab LabCOLOR
gen3ch GENERIC3CHANNEL
named NAMEDCOLOR
hifi HiFiCOLOR
Anonymous _Anonymous_e__Struct
}type
GRAYCOLOR = record
gray: Word;
end;
RGBCOLOR = record
red: Word;
green: Word;
blue: Word;
end;
CMYKCOLOR = record
cyan: Word;
magenta: Word;
yellow: Word;
black: Word;
end;
XYZCOLOR = record
X: Word;
Y: Word;
Z: Word;
end;
YxyCOLOR = record
Y: Word;
x: Word;
y: Word;
end;
LabCOLOR = record
L: Word;
a: Word;
b: Word;
end;
GENERIC3CHANNEL = record
ch1: Word;
ch2: Word;
ch3: Word;
end;
NAMEDCOLOR = record
dwIndex: DWORD;
end;
HiFiCOLOR = record
channel: array[0..7] of Byte;
end;
COLOR = record
gray: GRAYCOLOR;
rgb: RGBCOLOR;
cmyk: CMYKCOLOR;
XYZ: XYZCOLOR;
Yxy: YxyCOLOR;
Lab: LabCOLOR;
gen3ch: GENERIC3CHANNEL;
named: NAMEDCOLOR;
hifi: HiFiCOLOR;
Anonymous: _Anonymous_e__Struct;
end;const GRAYCOLOR = extern struct {
gray: u16,
};
const RGBCOLOR = extern struct {
red: u16,
green: u16,
blue: u16,
};
const CMYKCOLOR = extern struct {
cyan: u16,
magenta: u16,
yellow: u16,
black: u16,
};
const XYZCOLOR = extern struct {
X: u16,
Y: u16,
Z: u16,
};
const YxyCOLOR = extern struct {
Y: u16,
x: u16,
y: u16,
};
const LabCOLOR = extern struct {
L: u16,
a: u16,
b: u16,
};
const GENERIC3CHANNEL = extern struct {
ch1: u16,
ch2: u16,
ch3: u16,
};
const NAMEDCOLOR = extern struct {
dwIndex: u32,
};
const HiFiCOLOR = extern struct {
channel: [8]u8,
};
const COLOR = extern struct {
gray: GRAYCOLOR,
rgb: RGBCOLOR,
cmyk: CMYKCOLOR,
XYZ: XYZCOLOR,
Yxy: YxyCOLOR,
Lab: LabCOLOR,
gen3ch: GENERIC3CHANNEL,
named: NAMEDCOLOR,
hifi: HiFiCOLOR,
Anonymous: _Anonymous_e__Struct,
};type
GRAYCOLOR {.bycopy.} = object
gray: uint16
RGBCOLOR {.bycopy.} = object
red: uint16
green: uint16
blue: uint16
CMYKCOLOR {.bycopy.} = object
cyan: uint16
magenta: uint16
yellow: uint16
black: uint16
XYZCOLOR {.bycopy.} = object
X: uint16
Y: uint16
Z: uint16
YxyCOLOR {.bycopy.} = object
Y: uint16
x: uint16
y: uint16
LabCOLOR {.bycopy.} = object
L: uint16
a: uint16
b: uint16
GENERIC3CHANNEL {.bycopy.} = object
ch1: uint16
ch2: uint16
ch3: uint16
NAMEDCOLOR {.bycopy.} = object
dwIndex: uint32
HiFiCOLOR {.bycopy.} = object
channel: array[8, uint8]
COLOR {.bycopy.} = object
gray: GRAYCOLOR
rgb: RGBCOLOR
cmyk: CMYKCOLOR
XYZ: XYZCOLOR
Yxy: YxyCOLOR
Lab: LabCOLOR
gen3ch: GENERIC3CHANNEL
named: NAMEDCOLOR
hifi: HiFiCOLOR
Anonymous: _Anonymous_e__Structstruct GRAYCOLOR
{
ushort gray;
}
struct RGBCOLOR
{
ushort red;
ushort green;
ushort blue;
}
struct CMYKCOLOR
{
ushort cyan;
ushort magenta;
ushort yellow;
ushort black;
}
struct XYZCOLOR
{
ushort X;
ushort Y;
ushort Z;
}
struct YxyCOLOR
{
ushort Y;
ushort x;
ushort y;
}
struct LabCOLOR
{
ushort L;
ushort a;
ushort b;
}
struct GENERIC3CHANNEL
{
ushort ch1;
ushort ch2;
ushort ch3;
}
struct NAMEDCOLOR
{
uint dwIndex;
}
struct HiFiCOLOR
{
ubyte[8] channel;
}
struct COLOR
{
GRAYCOLOR gray;
RGBCOLOR rgb;
CMYKCOLOR cmyk;
XYZCOLOR XYZ;
YxyCOLOR Yxy;
LabCOLOR Lab;
GENERIC3CHANNEL gen3ch;
NAMEDCOLOR named;
HiFiCOLOR hifi;
_Anonymous_e__Struct Anonymous;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; COLOR サイズ: 8 バイト(x86)
dim st, 2 ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; gray : GRAYCOLOR (+0, 2byte) varptr(st)+0 を基点に操作(2byte:入れ子/配列)
; rgb : RGBCOLOR (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; cmyk : CMYKCOLOR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; XYZ : XYZCOLOR (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; Yxy : YxyCOLOR (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; Lab : LabCOLOR (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; gen3ch : GENERIC3CHANNEL (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; named : NAMEDCOLOR (+0, 4byte) varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; hifi : HiFiCOLOR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; Anonymous : _Anonymous_e__Struct (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; COLOR サイズ: 16 バイト(x64)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; gray : GRAYCOLOR (+0, 2byte) varptr(st)+0 を基点に操作(2byte:入れ子/配列)
; rgb : RGBCOLOR (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; cmyk : CMYKCOLOR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; XYZ : XYZCOLOR (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; Yxy : YxyCOLOR (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; Lab : LabCOLOR (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; gen3ch : GENERIC3CHANNEL (+0, 6byte) varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; named : NAMEDCOLOR (+0, 4byte) varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; hifi : HiFiCOLOR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; Anonymous : _Anonymous_e__Struct (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GRAYCOLOR
#field short gray
#endstruct
#defstruct global RGBCOLOR
#field short red
#field short green
#field short blue
#endstruct
#defstruct global CMYKCOLOR
#field short cyan
#field short magenta
#field short yellow
#field short black
#endstruct
#defstruct global XYZCOLOR
#field short X
#field short Y
#field short Z
#endstruct
#defstruct global YxyCOLOR
#field short Y
#field short x
#field short y
#endstruct
#defstruct global LabCOLOR
#field short L
#field short a
#field short b
#endstruct
#defstruct global GENERIC3CHANNEL
#field short ch1
#field short ch2
#field short ch3
#endstruct
#defstruct global NAMEDCOLOR
#field int dwIndex
#endstruct
#defstruct global HiFiCOLOR
#field byte channel 8
#endstruct
#defstruct global COLOR
#field GRAYCOLOR gray
#field RGBCOLOR rgb
#field CMYKCOLOR cmyk
#field XYZCOLOR XYZ
#field YxyCOLOR Yxy
#field LabCOLOR Lab
#field GENERIC3CHANNEL gen3ch
#field NAMEDCOLOR named
#field HiFiCOLOR hifi
#field _Anonymous_e__Struct Anonymous
#endstruct
stdim st, COLOR ; NSTRUCT 変数を確保