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

ENHMETAHEADER

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

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

フィールド

フィールドサイズx64x86説明
iTypeDWORD4+0+0レコードの種別。拡張メタファイルヘッダーを示す値。
nSizeDWORD4+4+4このヘッダーレコードのサイズ(バイト数)。
rclBoundsRECTL16+8+8描画の境界矩形をデバイス単位で表すRECTL。
rclFrameRECTL16+24+24画像の枠を0.01ミリ単位で表すRECTL。
dSignatureDWORD4+40+40拡張メタファイルを示す署名値(" EMF")。
nVersionDWORD4+44+44メタファイルのバージョン番号。
nBytesDWORD4+48+48メタファイル全体のサイズ(バイト数)。
nRecordsDWORD4+52+52メタファイルに含まれるレコードの総数。
nHandlesWORD2+56+56ハンドルテーブルに含まれるハンドル数。
sReservedWORD2+58+58予約フィールド。0でなければならない。
nDescriptionDWORD4+60+60説明文字列の文字数。説明がなければ0。
offDescriptionDWORD4+64+64説明文字列へのバイトオフセット。
nPalEntriesDWORD4+68+68メタファイルのパレットエントリ数。
szlDeviceSIZE8+72+72参照デバイスの解像度(ピクセル単位)を表すSIZE。
szlMillimetersSIZE8+80+80参照デバイスのサイズ(ミリメートル単位)を表すSIZE。
cbPixelFormatDWORD4+88+88ピクセルフォーマット記述子のバイト数。
offPixelFormatDWORD4+92+92ピクセルフォーマット記述子へのバイトオフセット。
bOpenGLDWORD4+96+96メタファイルにOpenGLレコードが含まれるかを示すフラグ。
szlMicrometersSIZE8+100+100参照デバイスのサイズ(マイクロメートル単位)を表すSIZE。

各言語での定義

#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