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

CMYKCOLOR

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

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

フィールド

フィールドサイズx64x86説明
cyanWORD2+0+0シアン成分の値(16ビット)。
magentaWORD2+2+2マゼンタ成分の値(16ビット)。
yellowWORD2+4+4イエロー成分の値(16ビット)。
blackWORD2+6+6ブラック成分の値(16ビット)。

各言語での定義

#include <windows.h>

// CMYKCOLOR  (x64 8 / x86 8 バイト)
typedef struct CMYKCOLOR {
    WORD cyan;
    WORD magenta;
    WORD yellow;
    WORD black;
} CMYKCOLOR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CMYKCOLOR
{
    public ushort cyan;
    public ushort magenta;
    public ushort yellow;
    public ushort black;
}
Imports System.Runtime.InteropServices

<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
import ctypes
from ctypes import wintypes

class CMYKCOLOR(ctypes.Structure):
    _fields_ = [
        ("cyan", ctypes.c_ushort),
        ("magenta", ctypes.c_ushort),
        ("yellow", ctypes.c_ushort),
        ("black", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct CMYKCOLOR {
    pub cyan: u16,
    pub magenta: u16,
    pub yellow: u16,
    pub black: u16,
}
import "golang.org/x/sys/windows"

type CMYKCOLOR struct {
	cyan uint16
	magenta uint16
	yellow uint16
	black uint16
}
type
  CMYKCOLOR = record
    cyan: Word;
    magenta: Word;
    yellow: Word;
    black: Word;
  end;
const CMYKCOLOR = extern struct {
    cyan: u16,
    magenta: u16,
    yellow: u16,
    black: u16,
};
type
  CMYKCOLOR {.bycopy.} = object
    cyan: uint16
    magenta: uint16
    yellow: uint16
    black: uint16
struct CMYKCOLOR
{
    ushort cyan;
    ushort magenta;
    ushort yellow;
    ushort black;
}

HSP用 定義

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

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

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