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

LabCOLOR

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

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

フィールド

フィールドサイズx64x86説明
LWORD2+0+0CIE Lab色空間のL(明度)成分(16ビット)。
aWORD2+2+2CIE Lab色空間のa(赤緑軸)成分(16ビット)。
bWORD2+4+4CIE Lab色空間のb(黄青軸)成分(16ビット)。

各言語での定義

#include <windows.h>

// LabCOLOR  (x64 6 / x86 6 バイト)
typedef struct LabCOLOR {
    WORD L;
    WORD a;
    WORD b;
} LabCOLOR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LabCOLOR
{
    public ushort L;
    public ushort a;
    public ushort b;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LabCOLOR
    Public L As UShort
    Public a As UShort
    Public b As UShort
End Structure
import ctypes
from ctypes import wintypes

class LabCOLOR(ctypes.Structure):
    _fields_ = [
        ("L", ctypes.c_ushort),
        ("a", ctypes.c_ushort),
        ("b", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct LabCOLOR {
    pub L: u16,
    pub a: u16,
    pub b: u16,
}
import "golang.org/x/sys/windows"

type LabCOLOR struct {
	L uint16
	a uint16
	b uint16
}
type
  LabCOLOR = record
    L: Word;
    a: Word;
    b: Word;
  end;
const LabCOLOR = extern struct {
    L: u16,
    a: u16,
    b: u16,
};
type
  LabCOLOR {.bycopy.} = object
    L: uint16
    a: uint16
    b: uint16
struct LabCOLOR
{
    ushort L;
    ushort a;
    ushort b;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; LabCOLOR サイズ: 6 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 6 / 4 切り上げ)
; L : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; a : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; b : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global LabCOLOR
    #field short L
    #field short a
    #field short b
#endstruct

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