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

ENHMETAHEADER

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

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

フィールド

フィールドサイズx64x86説明
iTypeDWORD4+0+0レコードの種類。このメンバーには、EMR_HEADER 定数に割り当てられている値を指定しなければなりません。
nSizeDWORD4+4+4構造体のサイズ (バイト単位)。
rclBoundsRECTL16+8+8メタファイルに格納された図を囲むことができる最小の四角形の寸法 (デバイス単位)。 この四角形はグラフィックス デバイス インターフェイス (GDI) によって設定されます。その寸法には右端と下端が含まれます。
rclFrameRECTL16+24+24メタファイルに格納された図を囲む四角形の寸法 (0.01 ミリメートル単位)。 この四角形は、メタファイルを作成するアプリケーションが設定しなければなりません。その寸法には右端と下端が含まれます。
dSignatureDWORD4+40+40シグネチャ。このメンバーには、ENHMETA_SIGNATURE 定数に割り当てられている値を指定しなければなりません。
nVersionDWORD4+44+44メタファイルのバージョン。現在のバージョンの値は 0x10000 です。
nBytesDWORD4+48+48拡張メタファイルのサイズ (バイト単位)。
nRecordsDWORD4+52+52拡張メタファイル内のレコード数。
nHandlesWORD2+56+56拡張メタファイルのハンドル テーブル内のハンドル数 (このテーブルのインデックス 0 は予約済みです)。
sReservedWORD2+58+58予約済みです。0 でなければなりません。
nDescriptionDWORD4+60+60拡張メタファイルの内容の説明を格納する配列の文字数。 拡張メタファイルに説明文字列が含まれない場合、このメンバーには 0 を設定します。
offDescriptionDWORD4+64+64ENHMETAHEADER 構造体の先頭から、拡張メタファイルの内容の説明を格納する配列までのオフセット。 拡張メタファイルに説明文字列が含まれない場合、このメンバーには 0 を設定します。
nPalEntriesDWORD4+68+68拡張メタファイルのパレット内のエントリ数。
szlDeviceSIZE8+72+72参照デバイスの解像度 (ピクセル単位)。
szlMillimetersSIZE8+80+80参照デバイスの解像度 (ミリメートル単位)。
cbPixelFormatDWORD4+88+88メタファイルに最後に記録されたピクセル形式のサイズ。 記録の開始時に参照 DC でピクセル形式が設定されている場合、cbPixelFormat には PIXELFORMATDESCRIPTOR のサイズが設定されます。 メタファイルの記録時にピクセル形式が設定されていない場合、このメンバーには 0 が設定されます。 複数のピクセル形式が設定されている場合、ヘッダーは最後のピクセル形式を指します。
offPixelFormatDWORD4+92+92メタファイルの記録時に使用されたピクセル形式のオフセット。 記録の開始時または記録中に参照 DC でピクセル形式が設定されている場合、 offPixelFormat にはメタファイル内の PIXELFORMATDESCRIPTOR のオフセットが設定されます。 メタファイルの記録時にピクセル形式が設定されていない場合、このメンバーには 0 が設定されます。 複数のピクセル形式が設定されている場合、ヘッダーは最後のピクセル形式を指します。
bOpenGLDWORD4+96+96メタファイルに OpenGL レコードが含まれるかどうかを示します。 bOpenGL は単純なブール型のフラグで、拡張メタファイルに OpenGL の処理が必要かどうかを判断するために使用できます。 メタファイルに OpenGL レコードが含まれる場合、bOpenGLTRUE になり、それ以外の場合は FALSE になります。
szlMicrometersSIZE8+100+100参照デバイスのサイズ (マイクロメートル単位)。

公式ドキュメント

ENHMETAHEADER 構造体には、拡張メタファイルに格納された図の寸法、 拡張メタファイル内のレコード数、図が作成されたデバイスの解像度など、拡張メタファイルのデータが格納されます。

この構造体は、常に拡張メタファイルの 最初のレコードです。

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

各言語での定義

#include <windows.h>

// RECTL  (x64 16 / x86 16 バイト)
typedef struct RECTL {
    INT left;
    INT top;
    INT right;
    INT bottom;
} RECTL;

// SIZE  (x64 8 / x86 8 バイト)
typedef struct SIZE {
    INT cx;
    INT cy;
} SIZE;

// ENHMETAHEADER  (x64 108 / x86 108 バイト)
typedef struct ENHMETAHEADER {
    DWORD iType;
    DWORD nSize;
    RECTL rclBounds;
    RECTL rclFrame;
    DWORD dSignature;
    DWORD nVersion;
    DWORD nBytes;
    DWORD nRecords;
    WORD nHandles;
    WORD sReserved;
    DWORD nDescription;
    DWORD offDescription;
    DWORD nPalEntries;
    SIZE szlDevice;
    SIZE szlMillimeters;
    DWORD cbPixelFormat;
    DWORD offPixelFormat;
    DWORD bOpenGL;
    SIZE szlMicrometers;
} ENHMETAHEADER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RECTL
{
    public int left;
    public int top;
    public int right;
    public int bottom;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SIZE
{
    public int cx;
    public int cy;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ENHMETAHEADER
{
    public uint iType;
    public uint nSize;
    public RECTL rclBounds;
    public RECTL rclFrame;
    public uint dSignature;
    public uint nVersion;
    public uint nBytes;
    public uint nRecords;
    public ushort nHandles;
    public ushort sReserved;
    public uint nDescription;
    public uint offDescription;
    public uint nPalEntries;
    public SIZE szlDevice;
    public SIZE szlMillimeters;
    public uint cbPixelFormat;
    public uint offPixelFormat;
    public uint bOpenGL;
    public SIZE szlMicrometers;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RECTL
    Public left As Integer
    Public top As Integer
    Public right As Integer
    Public bottom As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SIZE
    Public cx As Integer
    Public cy As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ENHMETAHEADER
    Public iType As UInteger
    Public nSize As UInteger
    Public rclBounds As RECTL
    Public rclFrame As RECTL
    Public dSignature As UInteger
    Public nVersion As UInteger
    Public nBytes As UInteger
    Public nRecords As UInteger
    Public nHandles As UShort
    Public sReserved As UShort
    Public nDescription As UInteger
    Public offDescription As UInteger
    Public nPalEntries As UInteger
    Public szlDevice As SIZE
    Public szlMillimeters As SIZE
    Public cbPixelFormat As UInteger
    Public offPixelFormat As UInteger
    Public bOpenGL As UInteger
    Public szlMicrometers As SIZE
End Structure
import ctypes
from ctypes import wintypes

class RECTL(ctypes.Structure):
    _fields_ = [
        ("left", ctypes.c_int),
        ("top", ctypes.c_int),
        ("right", ctypes.c_int),
        ("bottom", ctypes.c_int),
    ]

class SIZE(ctypes.Structure):
    _fields_ = [
        ("cx", ctypes.c_int),
        ("cy", ctypes.c_int),
    ]

class ENHMETAHEADER(ctypes.Structure):
    _fields_ = [
        ("iType", wintypes.DWORD),
        ("nSize", wintypes.DWORD),
        ("rclBounds", RECTL),
        ("rclFrame", RECTL),
        ("dSignature", wintypes.DWORD),
        ("nVersion", wintypes.DWORD),
        ("nBytes", wintypes.DWORD),
        ("nRecords", wintypes.DWORD),
        ("nHandles", ctypes.c_ushort),
        ("sReserved", ctypes.c_ushort),
        ("nDescription", wintypes.DWORD),
        ("offDescription", wintypes.DWORD),
        ("nPalEntries", wintypes.DWORD),
        ("szlDevice", SIZE),
        ("szlMillimeters", SIZE),
        ("cbPixelFormat", wintypes.DWORD),
        ("offPixelFormat", wintypes.DWORD),
        ("bOpenGL", wintypes.DWORD),
        ("szlMicrometers", SIZE),
    ]
#[repr(C)]
pub struct RECTL {
    pub left: i32,
    pub top: i32,
    pub right: i32,
    pub bottom: i32,
}

#[repr(C)]
pub struct SIZE {
    pub cx: i32,
    pub cy: i32,
}

#[repr(C)]
pub struct ENHMETAHEADER {
    pub iType: u32,
    pub nSize: u32,
    pub rclBounds: RECTL,
    pub rclFrame: RECTL,
    pub dSignature: u32,
    pub nVersion: u32,
    pub nBytes: u32,
    pub nRecords: u32,
    pub nHandles: u16,
    pub sReserved: u16,
    pub nDescription: u32,
    pub offDescription: u32,
    pub nPalEntries: u32,
    pub szlDevice: SIZE,
    pub szlMillimeters: SIZE,
    pub cbPixelFormat: u32,
    pub offPixelFormat: u32,
    pub bOpenGL: u32,
    pub szlMicrometers: SIZE,
}
import "golang.org/x/sys/windows"

type RECTL struct {
	left int32
	top int32
	right int32
	bottom int32
}

type SIZE struct {
	cx int32
	cy int32
}

type ENHMETAHEADER struct {
	iType uint32
	nSize uint32
	rclBounds RECTL
	rclFrame RECTL
	dSignature uint32
	nVersion uint32
	nBytes uint32
	nRecords uint32
	nHandles uint16
	sReserved uint16
	nDescription uint32
	offDescription uint32
	nPalEntries uint32
	szlDevice SIZE
	szlMillimeters SIZE
	cbPixelFormat uint32
	offPixelFormat uint32
	bOpenGL uint32
	szlMicrometers SIZE
}
type
  RECTL = record
    left: Integer;
    top: Integer;
    right: Integer;
    bottom: Integer;
  end;

  SIZE = record
    cx: Integer;
    cy: Integer;
  end;

  ENHMETAHEADER = record
    iType: DWORD;
    nSize: DWORD;
    rclBounds: RECTL;
    rclFrame: RECTL;
    dSignature: DWORD;
    nVersion: DWORD;
    nBytes: DWORD;
    nRecords: DWORD;
    nHandles: Word;
    sReserved: Word;
    nDescription: DWORD;
    offDescription: DWORD;
    nPalEntries: DWORD;
    szlDevice: SIZE;
    szlMillimeters: SIZE;
    cbPixelFormat: DWORD;
    offPixelFormat: DWORD;
    bOpenGL: DWORD;
    szlMicrometers: SIZE;
  end;
const RECTL = extern struct {
    left: i32,
    top: i32,
    right: i32,
    bottom: i32,
};

const SIZE = extern struct {
    cx: i32,
    cy: i32,
};

const ENHMETAHEADER = extern struct {
    iType: u32,
    nSize: u32,
    rclBounds: RECTL,
    rclFrame: RECTL,
    dSignature: u32,
    nVersion: u32,
    nBytes: u32,
    nRecords: u32,
    nHandles: u16,
    sReserved: u16,
    nDescription: u32,
    offDescription: u32,
    nPalEntries: u32,
    szlDevice: SIZE,
    szlMillimeters: SIZE,
    cbPixelFormat: u32,
    offPixelFormat: u32,
    bOpenGL: u32,
    szlMicrometers: SIZE,
};
type
  RECTL {.bycopy.} = object
    left: int32
    top: int32
    right: int32
    bottom: int32

  SIZE {.bycopy.} = object
    cx: int32
    cy: int32

  ENHMETAHEADER {.bycopy.} = object
    iType: uint32
    nSize: uint32
    rclBounds: RECTL
    rclFrame: RECTL
    dSignature: uint32
    nVersion: uint32
    nBytes: uint32
    nRecords: uint32
    nHandles: uint16
    sReserved: uint16
    nDescription: uint32
    offDescription: uint32
    nPalEntries: uint32
    szlDevice: SIZE
    szlMillimeters: SIZE
    cbPixelFormat: uint32
    offPixelFormat: uint32
    bOpenGL: uint32
    szlMicrometers: SIZE
struct RECTL
{
    int left;
    int top;
    int right;
    int bottom;
}

struct SIZE
{
    int cx;
    int cy;
}

struct ENHMETAHEADER
{
    uint iType;
    uint nSize;
    RECTL rclBounds;
    RECTL rclFrame;
    uint dSignature;
    uint nVersion;
    uint nBytes;
    uint nRecords;
    ushort nHandles;
    ushort sReserved;
    uint nDescription;
    uint offDescription;
    uint nPalEntries;
    SIZE szlDevice;
    SIZE szlMillimeters;
    uint cbPixelFormat;
    uint offPixelFormat;
    uint bOpenGL;
    SIZE szlMicrometers;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ENHMETAHEADER サイズ: 108 バイト(x64)
dim st, 27    ; 4byte整数×27(構造体サイズ 108 / 4 切り上げ)
; iType : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; nSize : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; rclBounds : RECTL (+8, 16byte)  varptr(st)+8 を基点に操作(16byte:入れ子/配列)
; rclFrame : RECTL (+24, 16byte)  varptr(st)+24 を基点に操作(16byte:入れ子/配列)
; dSignature : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; nVersion : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; nBytes : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; nRecords : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; nHandles : WORD (+56, 2byte)  wpoke st,56,値  /  値 = wpeek(st,56)
; sReserved : WORD (+58, 2byte)  wpoke st,58,値  /  値 = wpeek(st,58)
; nDescription : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; offDescription : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; nPalEntries : DWORD (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; szlDevice : SIZE (+72, 8byte)  varptr(st)+72 を基点に操作(8byte:入れ子/配列)
; szlMillimeters : SIZE (+80, 8byte)  varptr(st)+80 を基点に操作(8byte:入れ子/配列)
; cbPixelFormat : DWORD (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; offPixelFormat : DWORD (+92, 4byte)  st.23 = 値  /  値 = st.23   (lpoke/lpeek も可)
; bOpenGL : DWORD (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; szlMicrometers : SIZE (+100, 8byte)  varptr(st)+100 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global RECTL
    #field int left
    #field int top
    #field int right
    #field int bottom
#endstruct

#defstruct global SIZE
    #field int cx
    #field int cy
#endstruct

#defstruct global ENHMETAHEADER
    #field int iType
    #field int nSize
    #field RECTL rclBounds
    #field RECTL rclFrame
    #field int dSignature
    #field int nVersion
    #field int nBytes
    #field int nRecords
    #field short nHandles
    #field short sReserved
    #field int nDescription
    #field int offDescription
    #field int nPalEntries
    #field SIZE szlDevice
    #field SIZE szlMillimeters
    #field int cbPixelFormat
    #field int offPixelFormat
    #field int bOpenGL
    #field SIZE szlMicrometers
#endstruct

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