Win32 API 日本語リファレンス
ホームUI.ColorSystem › LOGCOLORSPACEW

LOGCOLORSPACEW

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

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

フィールド

フィールドサイズx64x86説明
lcsSignatureDWORD4+0+0色空間のシグネチャです。現時点では、このメンバーは常に LCS_SIGNATURE に設定してください。
lcsVersionDWORD4+4+4バージョン番号です。0x400 でなければなりません。
lcsSizeDWORD4+8+8この構造体のサイズ (バイト単位) です。
lcsCSTypeLCSCSTYPE4+12+12

色空間の種類です。このメンバーには次のいずれかの値を指定できます。

意味
LCS_CALIBRATED_RGB 色の値はキャリブレーション済みの RGB 値です。これらの値は、デバイスに渡される前に lcsEndpoints メンバーで指定されたエンドポイントを使用して変換されます。
LCS_sRGB 色の値は sRGB 値です。
LCS_WINDOWS_COLOR_SPACE 色の値は Windows 既定の色空間の色の値です。

LCS_CALIBRATED_RGB が指定されていない場合、lcsEndpoints メンバーは無視されます。

lcsIntentINT4+16+16

色域のマッピング方法です。このメンバーには次のいずれかの値を指定できます。

インテント ICC 名 意味
LCS_GM_ABS_
COLORIMETRIC
マッチ 絶対比色的 白色点を維持します。色を出力先の色域内で最も近い色に合わせます。
LCS_GM_
BUSINESS
グラフィック 彩度 彩度を維持します。ビジネス チャートなど、ディザリングされていない色が必要な場合に使用します。
LCS_GM_
GRAPHICS
プルーフ 相対比色的 測色的な一致を維持します。グラフィック デザインや名前付きの色に使用します。
LCS_GM_
IMAGES
ピクチャ 知覚的 コントラストを維持します。写真や自然画像に使用します。
lcsEndpointsCIEXYZTRIPLE36+20+20赤、緑、青のエンドポイントです。
lcsGammaRedDWORD4+56+56赤の座標のスケールです。
lcsGammaGreenDWORD4+60+60緑の座標のスケールです。
lcsGammaBlueDWORD4+64+64青の座標のスケールです。
lcsFilenameWCHAR520+68+68カラー プロファイル ファイルの名前を表す、null で終わる文字列です。このメンバーは通常 0 に設定しますが、カラー プロファイルで指定されたとおりに色空間を正確に設定するために使用することもできます。これは、特定のプリンター向けの色の値を入力するデバイスや、インストール可能なイメージ カラー マッチャーを使用する場合に役立ちます。カラー プロファイルを指定する場合は、この構造体の他のすべてのメンバーにも、完全に正確な値でなくとも妥当な値を設定してください。

公式ドキュメント

LOGCOLORSPACE 構造体には、論理色空間を定義する情報が含まれます。

解説(Remarks)

パレットと同様に (ただしペンやブラシとは異なり)、LogColorSpace を作成するときはポインターを渡す必要があります。

lcsCSType メンバーが LCS_sRGB または LCS_WINDOWS_COLOR_SPACE に設定されている場合、この構造体の他のメンバーは無視され、WCS は sRGB 色空間を使用します。lcsEndpoints、lcsGammaRed、lcsGammaGreen、および lcsGammaBlue の各メンバーは、論理色空間を記述するために使用されます。lcsEndpoints メンバーは CIEXYZTRIPLE であり、色空間の RGB エンドポイントの x、y、z の値が格納されます。

lcsGammaRedlcsGammaGreenlcsGammaBlue に必要な DWORD のビット形式は、8 ビット左シフトされた 8.8 固定小数点整数です。つまり、8 ビットの整数部の後に 8 ビットの小数部が続きます。ビット シフトを考慮すると、32 ビット DWORD に必要な形式は次のとおりです。

00000000nnnnnnnnffffffff00000000

lcsFilename メンバーにファイル名が格納されており、lcsCSType メンバーが LCS_CALIBRATED_RGB に設定されている場合、WCS はこの構造体の他のメンバーを無視します。この場合、ファイル内の色空間が、この LOGCOLORSPACE 構造体が参照する色空間として使用されます。

三刺激値 X、Y、Z と色度値 x、y、z の関係は次のとおりです。

x = X/(X+Y+Z)

y = Y/(X+Y+Z)

z = Z/(X+Y+Z)

lcsCSType メンバーが LCS_sRGB または LCS_WINDOWS_COLOR_SPACE に設定されている場合、この構造体の他のメンバーは無視され、ICM は sRGB 色空間を使用します。ただし、CreateProfileFromLogColorSpace は lcsCSType メンバーを無視し、lcsEndpoints、lcsGammaRed、lcsGammaGreen、lcsGammaBlue の各メンバーを使用してプロファイルを作成するため、アプリケーションは構造体の残りの部分も初期化する必要があります。これらのメンバーは、LCS_sRGB または LCS_WINDOWS_COLOR_SPACE の色空間の場合には初期化されていない可能性があります。

メモ

wingdi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして LOGCOLORSPACE を定義しています。エンコード中立のエイリアスを、エンコード中立でないコードと混在させて使用すると、不一致が生じ、コンパイル エラーや実行時エラーの原因となる可能性があります。詳細については、「Conventions for Function Prototypes」を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// CIEXYZ  (x64 12 / x86 12 バイト)
typedef struct CIEXYZ {
    INT ciexyzX;
    INT ciexyzY;
    INT ciexyzZ;
} CIEXYZ;

// CIEXYZTRIPLE  (x64 36 / x86 36 バイト)
typedef struct CIEXYZTRIPLE {
    CIEXYZ ciexyzRed;
    CIEXYZ ciexyzGreen;
    CIEXYZ ciexyzBlue;
} CIEXYZTRIPLE;

// LOGCOLORSPACEW  (x64 588 / x86 588 バイト)
typedef struct LOGCOLORSPACEW {
    DWORD lcsSignature;
    DWORD lcsVersion;
    DWORD lcsSize;
    LCSCSTYPE lcsCSType;
    INT lcsIntent;
    CIEXYZTRIPLE lcsEndpoints;
    DWORD lcsGammaRed;
    DWORD lcsGammaGreen;
    DWORD lcsGammaBlue;
    WCHAR lcsFilename[260];
} LOGCOLORSPACEW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CIEXYZ
{
    public int ciexyzX;
    public int ciexyzY;
    public int ciexyzZ;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CIEXYZTRIPLE
{
    public CIEXYZ ciexyzRed;
    public CIEXYZ ciexyzGreen;
    public CIEXYZ ciexyzBlue;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LOGCOLORSPACEW
{
    public uint lcsSignature;
    public uint lcsVersion;
    public uint lcsSize;
    public int lcsCSType;
    public int lcsIntent;
    public CIEXYZTRIPLE lcsEndpoints;
    public uint lcsGammaRed;
    public uint lcsGammaGreen;
    public uint lcsGammaBlue;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string lcsFilename;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CIEXYZ
    Public ciexyzX As Integer
    Public ciexyzY As Integer
    Public ciexyzZ As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CIEXYZTRIPLE
    Public ciexyzRed As CIEXYZ
    Public ciexyzGreen As CIEXYZ
    Public ciexyzBlue As CIEXYZ
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LOGCOLORSPACEW
    Public lcsSignature As UInteger
    Public lcsVersion As UInteger
    Public lcsSize As UInteger
    Public lcsCSType As Integer
    Public lcsIntent As Integer
    Public lcsEndpoints As CIEXYZTRIPLE
    Public lcsGammaRed As UInteger
    Public lcsGammaGreen As UInteger
    Public lcsGammaBlue As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public lcsFilename As String
End Structure
import ctypes
from ctypes import wintypes

class CIEXYZ(ctypes.Structure):
    _fields_ = [
        ("ciexyzX", ctypes.c_int),
        ("ciexyzY", ctypes.c_int),
        ("ciexyzZ", ctypes.c_int),
    ]

class CIEXYZTRIPLE(ctypes.Structure):
    _fields_ = [
        ("ciexyzRed", CIEXYZ),
        ("ciexyzGreen", CIEXYZ),
        ("ciexyzBlue", CIEXYZ),
    ]

class LOGCOLORSPACEW(ctypes.Structure):
    _fields_ = [
        ("lcsSignature", wintypes.DWORD),
        ("lcsVersion", wintypes.DWORD),
        ("lcsSize", wintypes.DWORD),
        ("lcsCSType", ctypes.c_int),
        ("lcsIntent", ctypes.c_int),
        ("lcsEndpoints", CIEXYZTRIPLE),
        ("lcsGammaRed", wintypes.DWORD),
        ("lcsGammaGreen", wintypes.DWORD),
        ("lcsGammaBlue", wintypes.DWORD),
        ("lcsFilename", ctypes.c_wchar * 260),
    ]
#[repr(C)]
pub struct CIEXYZ {
    pub ciexyzX: i32,
    pub ciexyzY: i32,
    pub ciexyzZ: i32,
}

#[repr(C)]
pub struct CIEXYZTRIPLE {
    pub ciexyzRed: CIEXYZ,
    pub ciexyzGreen: CIEXYZ,
    pub ciexyzBlue: CIEXYZ,
}

#[repr(C)]
pub struct LOGCOLORSPACEW {
    pub lcsSignature: u32,
    pub lcsVersion: u32,
    pub lcsSize: u32,
    pub lcsCSType: i32,
    pub lcsIntent: i32,
    pub lcsEndpoints: CIEXYZTRIPLE,
    pub lcsGammaRed: u32,
    pub lcsGammaGreen: u32,
    pub lcsGammaBlue: u32,
    pub lcsFilename: [u16; 260],
}
import "golang.org/x/sys/windows"

type CIEXYZ struct {
	ciexyzX int32
	ciexyzY int32
	ciexyzZ int32
}

type CIEXYZTRIPLE struct {
	ciexyzRed CIEXYZ
	ciexyzGreen CIEXYZ
	ciexyzBlue CIEXYZ
}

type LOGCOLORSPACEW struct {
	lcsSignature uint32
	lcsVersion uint32
	lcsSize uint32
	lcsCSType int32
	lcsIntent int32
	lcsEndpoints CIEXYZTRIPLE
	lcsGammaRed uint32
	lcsGammaGreen uint32
	lcsGammaBlue uint32
	lcsFilename [260]uint16
}
type
  CIEXYZ = record
    ciexyzX: Integer;
    ciexyzY: Integer;
    ciexyzZ: Integer;
  end;

  CIEXYZTRIPLE = record
    ciexyzRed: CIEXYZ;
    ciexyzGreen: CIEXYZ;
    ciexyzBlue: CIEXYZ;
  end;

  LOGCOLORSPACEW = record
    lcsSignature: DWORD;
    lcsVersion: DWORD;
    lcsSize: DWORD;
    lcsCSType: Integer;
    lcsIntent: Integer;
    lcsEndpoints: CIEXYZTRIPLE;
    lcsGammaRed: DWORD;
    lcsGammaGreen: DWORD;
    lcsGammaBlue: DWORD;
    lcsFilename: array[0..259] of WideChar;
  end;
const CIEXYZ = extern struct {
    ciexyzX: i32,
    ciexyzY: i32,
    ciexyzZ: i32,
};

const CIEXYZTRIPLE = extern struct {
    ciexyzRed: CIEXYZ,
    ciexyzGreen: CIEXYZ,
    ciexyzBlue: CIEXYZ,
};

const LOGCOLORSPACEW = extern struct {
    lcsSignature: u32,
    lcsVersion: u32,
    lcsSize: u32,
    lcsCSType: i32,
    lcsIntent: i32,
    lcsEndpoints: CIEXYZTRIPLE,
    lcsGammaRed: u32,
    lcsGammaGreen: u32,
    lcsGammaBlue: u32,
    lcsFilename: [260]u16,
};
type
  CIEXYZ {.bycopy.} = object
    ciexyzX: int32
    ciexyzY: int32
    ciexyzZ: int32

  CIEXYZTRIPLE {.bycopy.} = object
    ciexyzRed: CIEXYZ
    ciexyzGreen: CIEXYZ
    ciexyzBlue: CIEXYZ

  LOGCOLORSPACEW {.bycopy.} = object
    lcsSignature: uint32
    lcsVersion: uint32
    lcsSize: uint32
    lcsCSType: int32
    lcsIntent: int32
    lcsEndpoints: CIEXYZTRIPLE
    lcsGammaRed: uint32
    lcsGammaGreen: uint32
    lcsGammaBlue: uint32
    lcsFilename: array[260, uint16]
struct CIEXYZ
{
    int ciexyzX;
    int ciexyzY;
    int ciexyzZ;
}

struct CIEXYZTRIPLE
{
    CIEXYZ ciexyzRed;
    CIEXYZ ciexyzGreen;
    CIEXYZ ciexyzBlue;
}

struct LOGCOLORSPACEW
{
    uint lcsSignature;
    uint lcsVersion;
    uint lcsSize;
    int lcsCSType;
    int lcsIntent;
    CIEXYZTRIPLE lcsEndpoints;
    uint lcsGammaRed;
    uint lcsGammaGreen;
    uint lcsGammaBlue;
    wchar[260] lcsFilename;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; LOGCOLORSPACEW サイズ: 588 バイト(x64)
dim st, 147    ; 4byte整数×147(構造体サイズ 588 / 4 切り上げ)
; lcsSignature : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; lcsVersion : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; lcsSize : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; lcsCSType : LCSCSTYPE (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; lcsIntent : INT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; lcsEndpoints : CIEXYZTRIPLE (+20, 36byte)  varptr(st)+20 を基点に操作(36byte:入れ子/配列)
; lcsGammaRed : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; lcsGammaGreen : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; lcsGammaBlue : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; lcsFilename : WCHAR (+68, 520byte)  varptr(st)+68 を基点に操作(520byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CIEXYZ
    #field int ciexyzX
    #field int ciexyzY
    #field int ciexyzZ
#endstruct

#defstruct global CIEXYZTRIPLE
    #field CIEXYZ ciexyzRed
    #field CIEXYZ ciexyzGreen
    #field CIEXYZ ciexyzBlue
#endstruct

#defstruct global LOGCOLORSPACEW
    #field int lcsSignature
    #field int lcsVersion
    #field int lcsSize
    #field int lcsCSType
    #field int lcsIntent
    #field CIEXYZTRIPLE lcsEndpoints
    #field int lcsGammaRed
    #field int lcsGammaGreen
    #field int lcsGammaBlue
    #field wchar lcsFilename 260
#endstruct

stdim st, LOGCOLORSPACEW        ; NSTRUCT 変数を確保
st->lcsSignature = 100
mes "lcsSignature=" + st->lcsSignature