ホーム › Graphics.GdiPlus › MetafileHeader
MetafileHeader
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Type | MetafileType | 4 | +0 | +0 | メタファイルの種類を表す列挙値。WMF、EMF、EMF+等。 |
| Size | DWORD | 4 | +4 | +4 | メタファイル全体のサイズをバイト単位で表す。 |
| Version | DWORD | 4 | +8 | +8 | メタファイルのバージョン番号を表す。 |
| EmfPlusFlags | DWORD | 4 | +12 | +12 | EMF+メタファイルに関するフラグを表す。 |
| DpiX | FLOAT | 4 | +16 | +16 | 水平方向の解像度をDPIで表す。 |
| DpiY | FLOAT | 4 | +20 | +20 | 垂直方向の解像度をDPIで表す。 |
| X | INT | 4 | +24 | +24 | メタファイル枠の左上X座標をデバイス単位で表す。 |
| Y | INT | 4 | +28 | +28 | メタファイル枠の左上Y座標をデバイス単位で表す。 |
| Width | INT | 4 | +32 | +32 | メタファイル枠の幅をデバイス単位で表す。 |
| Height | INT | 4 | +36 | +36 | メタファイル枠の高さをデバイス単位で表す。 |
| Anonymous | _Anonymous_e__Union | 88 | +40 | +40 | WMFまたはEMFヘッダのいずれかを保持する無名共用体。 |
| EmfPlusHeaderSize | INT | 4 | +128 | +128 | EMF+ヘッダレコードのサイズをバイト単位で表す。 |
| LogicalDpiX | INT | 4 | +132 | +132 | 論理的な水平解像度をDPIで表す。 |
| LogicalDpiY | INT | 4 | +136 | +136 | 論理的な垂直解像度をDPIで表す。 |
共用体: _Anonymous_e__Union x64 88B / x86 88B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| WmfHeader | METAHEADER | 18 | +0 | +0 |
| EmfHeader | ENHMETAHEADER3 | 88 | +0 | +0 |
各言語での定義
#include <windows.h>
// MetafileHeader (x64 140 / x86 140 バイト)
typedef struct MetafileHeader {
MetafileType Type;
DWORD Size;
DWORD Version;
DWORD EmfPlusFlags;
FLOAT DpiX;
FLOAT DpiY;
INT X;
INT Y;
INT Width;
INT Height;
_Anonymous_e__Union Anonymous;
INT EmfPlusHeaderSize;
INT LogicalDpiX;
INT LogicalDpiY;
} MetafileHeader;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MetafileHeader
{
public int Type;
public uint Size;
public uint Version;
public uint EmfPlusFlags;
public float DpiX;
public float DpiY;
public int X;
public int Y;
public int Width;
public int Height;
public _Anonymous_e__Union Anonymous;
public int EmfPlusHeaderSize;
public int LogicalDpiX;
public int LogicalDpiY;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MetafileHeader
Public Type As Integer
Public Size As UInteger
Public Version As UInteger
Public EmfPlusFlags As UInteger
Public DpiX As Single
Public DpiY As Single
Public X As Integer
Public Y As Integer
Public Width As Integer
Public Height As Integer
Public Anonymous As _Anonymous_e__Union
Public EmfPlusHeaderSize As Integer
Public LogicalDpiX As Integer
Public LogicalDpiY As Integer
End Structureimport ctypes
from ctypes import wintypes
class MetafileHeader(ctypes.Structure):
_fields_ = [
("Type", ctypes.c_int),
("Size", wintypes.DWORD),
("Version", wintypes.DWORD),
("EmfPlusFlags", wintypes.DWORD),
("DpiX", ctypes.c_float),
("DpiY", ctypes.c_float),
("X", ctypes.c_int),
("Y", ctypes.c_int),
("Width", ctypes.c_int),
("Height", ctypes.c_int),
("Anonymous", _Anonymous_e__Union),
("EmfPlusHeaderSize", ctypes.c_int),
("LogicalDpiX", ctypes.c_int),
("LogicalDpiY", ctypes.c_int),
]#[repr(C)]
pub struct MetafileHeader {
pub Type: i32,
pub Size: u32,
pub Version: u32,
pub EmfPlusFlags: u32,
pub DpiX: f32,
pub DpiY: f32,
pub X: i32,
pub Y: i32,
pub Width: i32,
pub Height: i32,
pub Anonymous: _Anonymous_e__Union,
pub EmfPlusHeaderSize: i32,
pub LogicalDpiX: i32,
pub LogicalDpiY: i32,
}import "golang.org/x/sys/windows"
type MetafileHeader struct {
Type int32
Size uint32
Version uint32
EmfPlusFlags uint32
DpiX float32
DpiY float32
X int32
Y int32
Width int32
Height int32
Anonymous _Anonymous_e__Union
EmfPlusHeaderSize int32
LogicalDpiX int32
LogicalDpiY int32
}type
MetafileHeader = record
Type: Integer;
Size: DWORD;
Version: DWORD;
EmfPlusFlags: DWORD;
DpiX: Single;
DpiY: Single;
X: Integer;
Y: Integer;
Width: Integer;
Height: Integer;
Anonymous: _Anonymous_e__Union;
EmfPlusHeaderSize: Integer;
LogicalDpiX: Integer;
LogicalDpiY: Integer;
end;const MetafileHeader = extern struct {
Type: i32,
Size: u32,
Version: u32,
EmfPlusFlags: u32,
DpiX: f32,
DpiY: f32,
X: i32,
Y: i32,
Width: i32,
Height: i32,
Anonymous: _Anonymous_e__Union,
EmfPlusHeaderSize: i32,
LogicalDpiX: i32,
LogicalDpiY: i32,
};type
MetafileHeader {.bycopy.} = object
Type: int32
Size: uint32
Version: uint32
EmfPlusFlags: uint32
DpiX: float32
DpiY: float32
X: int32
Y: int32
Width: int32
Height: int32
Anonymous: _Anonymous_e__Union
EmfPlusHeaderSize: int32
LogicalDpiX: int32
LogicalDpiY: int32struct MetafileHeader
{
int Type;
uint Size;
uint Version;
uint EmfPlusFlags;
float DpiX;
float DpiY;
int X;
int Y;
int Width;
int Height;
_Anonymous_e__Union Anonymous;
int EmfPlusHeaderSize;
int LogicalDpiX;
int LogicalDpiY;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MetafileHeader サイズ: 140 バイト(x64)
dim st, 35 ; 4byte整数×35(構造体サイズ 140 / 4 切り上げ)
; Type : MetafileType (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Version : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; EmfPlusFlags : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; DpiX : FLOAT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; DpiY : FLOAT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; X : INT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; Y : INT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; Width : INT (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; Height : INT (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+40, 88byte) varptr(st)+40 を基点に操作(88byte:入れ子/配列)
; EmfPlusHeaderSize : INT (+128, 4byte) st.32 = 値 / 値 = st.32 (lpoke/lpeek も可)
; LogicalDpiX : INT (+132, 4byte) st.33 = 値 / 値 = st.33 (lpoke/lpeek も可)
; LogicalDpiY : INT (+136, 4byte) st.34 = 値 / 値 = st.34 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MetafileHeader
#field int Type
#field int Size
#field int Version
#field int EmfPlusFlags
#field float DpiX
#field float DpiY
#field int X
#field int Y
#field int Width
#field int Height
#field byte Anonymous 88
#field int EmfPlusHeaderSize
#field int LogicalDpiX
#field int LogicalDpiY
#endstruct
stdim st, MetafileHeader ; NSTRUCT 変数を確保
st->Type = 100
mes "Type=" + st->Type
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。