Win32 API 日本語リファレンス
ホームGraphics.DirectWrite › DWRITE_PAINT_COLOR

DWRITE_PAINT_COLOR

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

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

フィールド

フィールドサイズx64x86説明
valueDWRITE_COLOR_F16+0+0塗りに用いる色をDWRITE_COLOR_F(RGBA)で表す値。
paletteEntryIndexWORD2+16+16使用するカラーパレット内のエントリ番号。0xFFFFは前景色を表す。
alphaMultiplierFLOAT4+20+20色のアルファ値に乗算する係数(0.0〜1.0)。
colorAttributesDWRITE_PAINT_ATTRIBUTES4+24+24パレット参照かどうかなどの色の扱いを示す属性フラグ。

各言語での定義

#include <windows.h>

// DWRITE_COLOR_F  (x64 16 / x86 16 バイト)
typedef struct DWRITE_COLOR_F {
    FLOAT r;
    FLOAT g;
    FLOAT b;
    FLOAT a;
} DWRITE_COLOR_F;

// DWRITE_PAINT_COLOR  (x64 28 / x86 28 バイト)
typedef struct DWRITE_PAINT_COLOR {
    DWRITE_COLOR_F value;
    WORD paletteEntryIndex;
    FLOAT alphaMultiplier;
    DWRITE_PAINT_ATTRIBUTES colorAttributes;
} DWRITE_PAINT_COLOR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_COLOR_F
{
    public float r;
    public float g;
    public float b;
    public float a;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_PAINT_COLOR
{
    public DWRITE_COLOR_F value;
    public ushort paletteEntryIndex;
    public float alphaMultiplier;
    public int colorAttributes;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_COLOR_F
    Public r As Single
    Public g As Single
    Public b As Single
    Public a As Single
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_PAINT_COLOR
    Public value As DWRITE_COLOR_F
    Public paletteEntryIndex As UShort
    Public alphaMultiplier As Single
    Public colorAttributes As Integer
End Structure
import ctypes
from ctypes import wintypes

class DWRITE_COLOR_F(ctypes.Structure):
    _fields_ = [
        ("r", ctypes.c_float),
        ("g", ctypes.c_float),
        ("b", ctypes.c_float),
        ("a", ctypes.c_float),
    ]

class DWRITE_PAINT_COLOR(ctypes.Structure):
    _fields_ = [
        ("value", DWRITE_COLOR_F),
        ("paletteEntryIndex", ctypes.c_ushort),
        ("alphaMultiplier", ctypes.c_float),
        ("colorAttributes", ctypes.c_int),
    ]
#[repr(C)]
pub struct DWRITE_COLOR_F {
    pub r: f32,
    pub g: f32,
    pub b: f32,
    pub a: f32,
}

#[repr(C)]
pub struct DWRITE_PAINT_COLOR {
    pub value: DWRITE_COLOR_F,
    pub paletteEntryIndex: u16,
    pub alphaMultiplier: f32,
    pub colorAttributes: i32,
}
import "golang.org/x/sys/windows"

type DWRITE_COLOR_F struct {
	r float32
	g float32
	b float32
	a float32
}

type DWRITE_PAINT_COLOR struct {
	value DWRITE_COLOR_F
	paletteEntryIndex uint16
	alphaMultiplier float32
	colorAttributes int32
}
type
  DWRITE_COLOR_F = record
    r: Single;
    g: Single;
    b: Single;
    a: Single;
  end;

  DWRITE_PAINT_COLOR = record
    value: DWRITE_COLOR_F;
    paletteEntryIndex: Word;
    alphaMultiplier: Single;
    colorAttributes: Integer;
  end;
const DWRITE_COLOR_F = extern struct {
    r: f32,
    g: f32,
    b: f32,
    a: f32,
};

const DWRITE_PAINT_COLOR = extern struct {
    value: DWRITE_COLOR_F,
    paletteEntryIndex: u16,
    alphaMultiplier: f32,
    colorAttributes: i32,
};
type
  DWRITE_COLOR_F {.bycopy.} = object
    r: float32
    g: float32
    b: float32
    a: float32

  DWRITE_PAINT_COLOR {.bycopy.} = object
    value: DWRITE_COLOR_F
    paletteEntryIndex: uint16
    alphaMultiplier: float32
    colorAttributes: int32
struct DWRITE_COLOR_F
{
    float r;
    float g;
    float b;
    float a;
}

struct DWRITE_PAINT_COLOR
{
    DWRITE_COLOR_F value;
    ushort paletteEntryIndex;
    float alphaMultiplier;
    int colorAttributes;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DWRITE_PAINT_COLOR サイズ: 28 バイト(x64)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; value : DWRITE_COLOR_F (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; paletteEntryIndex : WORD (+16, 2byte)  wpoke st,16,値  /  値 = wpeek(st,16)
; alphaMultiplier : FLOAT (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; colorAttributes : DWRITE_PAINT_ATTRIBUTES (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DWRITE_COLOR_F
    #field float r
    #field float g
    #field float b
    #field float a
#endstruct

#defstruct global DWRITE_PAINT_COLOR
    #field DWRITE_COLOR_F value
    #field short paletteEntryIndex
    #field float alphaMultiplier
    #field int colorAttributes
#endstruct

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