ホーム › Graphics.Gdi › EMRSETPALETTEENTRIES
EMRSETPALETTEENTRIES
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| emr | EMR | 8 | +0 | +0 | 共通レコードヘッダを表すEMR構造体。 |
| ihPal | DWORD | 4 | +8 | +8 | 対象パレットのハンドルテーブル内インデックスを表す。 |
| iStart | DWORD | 4 | +12 | +12 | エントリ設定を開始する位置(先頭インデックス)を表す。 |
| cEntries | DWORD | 4 | +16 | +16 | 設定するパレットエントリの個数を表す。 |
| aPalEntries | PALETTEENTRY | 4 | +20 | +20 | 設定する色情報を格納するPALETTEENTRY配列の先頭(可変長)。 |
各言語での定義
#include <windows.h>
// EMR (x64 8 / x86 8 バイト)
typedef struct EMR {
ENHANCED_METAFILE_RECORD_TYPE iType;
DWORD nSize;
} EMR;
// PALETTEENTRY (x64 4 / x86 4 バイト)
typedef struct PALETTEENTRY {
BYTE peRed;
BYTE peGreen;
BYTE peBlue;
BYTE peFlags;
} PALETTEENTRY;
// EMRSETPALETTEENTRIES (x64 24 / x86 24 バイト)
typedef struct EMRSETPALETTEENTRIES {
EMR emr;
DWORD ihPal;
DWORD iStart;
DWORD cEntries;
PALETTEENTRY aPalEntries[1];
} EMRSETPALETTEENTRIES;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMR
{
public uint iType;
public uint nSize;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PALETTEENTRY
{
public byte peRed;
public byte peGreen;
public byte peBlue;
public byte peFlags;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMRSETPALETTEENTRIES
{
public EMR emr;
public uint ihPal;
public uint iStart;
public uint cEntries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public PALETTEENTRY[] aPalEntries;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMR
Public iType As UInteger
Public nSize As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PALETTEENTRY
Public peRed As Byte
Public peGreen As Byte
Public peBlue As Byte
Public peFlags As Byte
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMRSETPALETTEENTRIES
Public emr As EMR
Public ihPal As UInteger
Public iStart As UInteger
Public cEntries As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public aPalEntries() As PALETTEENTRY
End Structureimport ctypes
from ctypes import wintypes
class EMR(ctypes.Structure):
_fields_ = [
("iType", wintypes.DWORD),
("nSize", wintypes.DWORD),
]
class PALETTEENTRY(ctypes.Structure):
_fields_ = [
("peRed", ctypes.c_ubyte),
("peGreen", ctypes.c_ubyte),
("peBlue", ctypes.c_ubyte),
("peFlags", ctypes.c_ubyte),
]
class EMRSETPALETTEENTRIES(ctypes.Structure):
_fields_ = [
("emr", EMR),
("ihPal", wintypes.DWORD),
("iStart", wintypes.DWORD),
("cEntries", wintypes.DWORD),
("aPalEntries", PALETTEENTRY * 1),
]#[repr(C)]
pub struct EMR {
pub iType: u32,
pub nSize: u32,
}
#[repr(C)]
pub struct PALETTEENTRY {
pub peRed: u8,
pub peGreen: u8,
pub peBlue: u8,
pub peFlags: u8,
}
#[repr(C)]
pub struct EMRSETPALETTEENTRIES {
pub emr: EMR,
pub ihPal: u32,
pub iStart: u32,
pub cEntries: u32,
pub aPalEntries: [PALETTEENTRY; 1],
}import "golang.org/x/sys/windows"
type EMR struct {
iType uint32
nSize uint32
}
type PALETTEENTRY struct {
peRed byte
peGreen byte
peBlue byte
peFlags byte
}
type EMRSETPALETTEENTRIES struct {
emr EMR
ihPal uint32
iStart uint32
cEntries uint32
aPalEntries [1]PALETTEENTRY
}type
EMR = record
iType: DWORD;
nSize: DWORD;
end;
PALETTEENTRY = record
peRed: Byte;
peGreen: Byte;
peBlue: Byte;
peFlags: Byte;
end;
EMRSETPALETTEENTRIES = record
emr: EMR;
ihPal: DWORD;
iStart: DWORD;
cEntries: DWORD;
aPalEntries: array[0..0] of PALETTEENTRY;
end;const EMR = extern struct {
iType: u32,
nSize: u32,
};
const PALETTEENTRY = extern struct {
peRed: u8,
peGreen: u8,
peBlue: u8,
peFlags: u8,
};
const EMRSETPALETTEENTRIES = extern struct {
emr: EMR,
ihPal: u32,
iStart: u32,
cEntries: u32,
aPalEntries: [1]PALETTEENTRY,
};type
EMR {.bycopy.} = object
iType: uint32
nSize: uint32
PALETTEENTRY {.bycopy.} = object
peRed: uint8
peGreen: uint8
peBlue: uint8
peFlags: uint8
EMRSETPALETTEENTRIES {.bycopy.} = object
emr: EMR
ihPal: uint32
iStart: uint32
cEntries: uint32
aPalEntries: array[1, PALETTEENTRY]struct EMR
{
uint iType;
uint nSize;
}
struct PALETTEENTRY
{
ubyte peRed;
ubyte peGreen;
ubyte peBlue;
ubyte peFlags;
}
struct EMRSETPALETTEENTRIES
{
EMR emr;
uint ihPal;
uint iStart;
uint cEntries;
PALETTEENTRY[1] aPalEntries;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EMRSETPALETTEENTRIES サイズ: 24 バイト(x64)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; emr : EMR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; ihPal : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; iStart : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; cEntries : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; aPalEntries : PALETTEENTRY (+20, 4byte) varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global EMR
#field int iType
#field int nSize
#endstruct
#defstruct global PALETTEENTRY
#field byte peRed
#field byte peGreen
#field byte peBlue
#field byte peFlags
#endstruct
#defstruct global EMRSETPALETTEENTRIES
#field EMR emr
#field int ihPal
#field int iStart
#field int cEntries
#field PALETTEENTRY aPalEntries 1
#endstruct
stdim st, EMRSETPALETTEENTRIES ; NSTRUCT 変数を確保
st->ihPal = 100
mes "ihPal=" + st->ihPal