ホーム › Graphics.OpenGL › EMRPIXELFORMAT
EMRPIXELFORMAT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| emr | EMR | 8 | +0 | +0 | 拡張メタファイルレコードの共通ヘッダ(EMR)。レコード種別とサイズを保持する。 |
| pfd | PIXELFORMATDESCRIPTOR | 40 | +8 | +8 | 記録されたピクセル形式記述子(PIXELFORMATDESCRIPTOR)。 |
各言語での定義
#include <windows.h>
// EMR (x64 8 / x86 8 バイト)
typedef struct EMR {
ENHANCED_METAFILE_RECORD_TYPE iType;
DWORD nSize;
} EMR;
// PIXELFORMATDESCRIPTOR (x64 40 / x86 40 バイト)
typedef struct PIXELFORMATDESCRIPTOR {
WORD nSize;
WORD nVersion;
PFD_FLAGS dwFlags;
PFD_PIXEL_TYPE iPixelType;
BYTE cColorBits;
BYTE cRedBits;
BYTE cRedShift;
BYTE cGreenBits;
BYTE cGreenShift;
BYTE cBlueBits;
BYTE cBlueShift;
BYTE cAlphaBits;
BYTE cAlphaShift;
BYTE cAccumBits;
BYTE cAccumRedBits;
BYTE cAccumGreenBits;
BYTE cAccumBlueBits;
BYTE cAccumAlphaBits;
BYTE cDepthBits;
BYTE cStencilBits;
BYTE cAuxBuffers;
BYTE iLayerType;
BYTE bReserved;
DWORD dwLayerMask;
DWORD dwVisibleMask;
DWORD dwDamageMask;
} PIXELFORMATDESCRIPTOR;
// EMRPIXELFORMAT (x64 48 / x86 48 バイト)
typedef struct EMRPIXELFORMAT {
EMR emr;
PIXELFORMATDESCRIPTOR pfd;
} EMRPIXELFORMAT;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 PIXELFORMATDESCRIPTOR
{
public ushort nSize;
public ushort nVersion;
public uint dwFlags;
public byte iPixelType;
public byte cColorBits;
public byte cRedBits;
public byte cRedShift;
public byte cGreenBits;
public byte cGreenShift;
public byte cBlueBits;
public byte cBlueShift;
public byte cAlphaBits;
public byte cAlphaShift;
public byte cAccumBits;
public byte cAccumRedBits;
public byte cAccumGreenBits;
public byte cAccumBlueBits;
public byte cAccumAlphaBits;
public byte cDepthBits;
public byte cStencilBits;
public byte cAuxBuffers;
public byte iLayerType;
public byte bReserved;
public uint dwLayerMask;
public uint dwVisibleMask;
public uint dwDamageMask;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMRPIXELFORMAT
{
public EMR emr;
public PIXELFORMATDESCRIPTOR pfd;
}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 PIXELFORMATDESCRIPTOR
Public nSize As UShort
Public nVersion As UShort
Public dwFlags As UInteger
Public iPixelType As Byte
Public cColorBits As Byte
Public cRedBits As Byte
Public cRedShift As Byte
Public cGreenBits As Byte
Public cGreenShift As Byte
Public cBlueBits As Byte
Public cBlueShift As Byte
Public cAlphaBits As Byte
Public cAlphaShift As Byte
Public cAccumBits As Byte
Public cAccumRedBits As Byte
Public cAccumGreenBits As Byte
Public cAccumBlueBits As Byte
Public cAccumAlphaBits As Byte
Public cDepthBits As Byte
Public cStencilBits As Byte
Public cAuxBuffers As Byte
Public iLayerType As Byte
Public bReserved As Byte
Public dwLayerMask As UInteger
Public dwVisibleMask As UInteger
Public dwDamageMask As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMRPIXELFORMAT
Public emr As EMR
Public pfd As PIXELFORMATDESCRIPTOR
End Structureimport ctypes
from ctypes import wintypes
class EMR(ctypes.Structure):
_fields_ = [
("iType", wintypes.DWORD),
("nSize", wintypes.DWORD),
]
class PIXELFORMATDESCRIPTOR(ctypes.Structure):
_fields_ = [
("nSize", ctypes.c_ushort),
("nVersion", ctypes.c_ushort),
("dwFlags", wintypes.DWORD),
("iPixelType", ctypes.c_ubyte),
("cColorBits", ctypes.c_ubyte),
("cRedBits", ctypes.c_ubyte),
("cRedShift", ctypes.c_ubyte),
("cGreenBits", ctypes.c_ubyte),
("cGreenShift", ctypes.c_ubyte),
("cBlueBits", ctypes.c_ubyte),
("cBlueShift", ctypes.c_ubyte),
("cAlphaBits", ctypes.c_ubyte),
("cAlphaShift", ctypes.c_ubyte),
("cAccumBits", ctypes.c_ubyte),
("cAccumRedBits", ctypes.c_ubyte),
("cAccumGreenBits", ctypes.c_ubyte),
("cAccumBlueBits", ctypes.c_ubyte),
("cAccumAlphaBits", ctypes.c_ubyte),
("cDepthBits", ctypes.c_ubyte),
("cStencilBits", ctypes.c_ubyte),
("cAuxBuffers", ctypes.c_ubyte),
("iLayerType", ctypes.c_ubyte),
("bReserved", ctypes.c_ubyte),
("dwLayerMask", wintypes.DWORD),
("dwVisibleMask", wintypes.DWORD),
("dwDamageMask", wintypes.DWORD),
]
class EMRPIXELFORMAT(ctypes.Structure):
_fields_ = [
("emr", EMR),
("pfd", PIXELFORMATDESCRIPTOR),
]#[repr(C)]
pub struct EMR {
pub iType: u32,
pub nSize: u32,
}
#[repr(C)]
pub struct PIXELFORMATDESCRIPTOR {
pub nSize: u16,
pub nVersion: u16,
pub dwFlags: u32,
pub iPixelType: u8,
pub cColorBits: u8,
pub cRedBits: u8,
pub cRedShift: u8,
pub cGreenBits: u8,
pub cGreenShift: u8,
pub cBlueBits: u8,
pub cBlueShift: u8,
pub cAlphaBits: u8,
pub cAlphaShift: u8,
pub cAccumBits: u8,
pub cAccumRedBits: u8,
pub cAccumGreenBits: u8,
pub cAccumBlueBits: u8,
pub cAccumAlphaBits: u8,
pub cDepthBits: u8,
pub cStencilBits: u8,
pub cAuxBuffers: u8,
pub iLayerType: u8,
pub bReserved: u8,
pub dwLayerMask: u32,
pub dwVisibleMask: u32,
pub dwDamageMask: u32,
}
#[repr(C)]
pub struct EMRPIXELFORMAT {
pub emr: EMR,
pub pfd: PIXELFORMATDESCRIPTOR,
}import "golang.org/x/sys/windows"
type EMR struct {
iType uint32
nSize uint32
}
type PIXELFORMATDESCRIPTOR struct {
nSize uint16
nVersion uint16
dwFlags uint32
iPixelType byte
cColorBits byte
cRedBits byte
cRedShift byte
cGreenBits byte
cGreenShift byte
cBlueBits byte
cBlueShift byte
cAlphaBits byte
cAlphaShift byte
cAccumBits byte
cAccumRedBits byte
cAccumGreenBits byte
cAccumBlueBits byte
cAccumAlphaBits byte
cDepthBits byte
cStencilBits byte
cAuxBuffers byte
iLayerType byte
bReserved byte
dwLayerMask uint32
dwVisibleMask uint32
dwDamageMask uint32
}
type EMRPIXELFORMAT struct {
emr EMR
pfd PIXELFORMATDESCRIPTOR
}type
EMR = record
iType: DWORD;
nSize: DWORD;
end;
PIXELFORMATDESCRIPTOR = record
nSize: Word;
nVersion: Word;
dwFlags: DWORD;
iPixelType: Byte;
cColorBits: Byte;
cRedBits: Byte;
cRedShift: Byte;
cGreenBits: Byte;
cGreenShift: Byte;
cBlueBits: Byte;
cBlueShift: Byte;
cAlphaBits: Byte;
cAlphaShift: Byte;
cAccumBits: Byte;
cAccumRedBits: Byte;
cAccumGreenBits: Byte;
cAccumBlueBits: Byte;
cAccumAlphaBits: Byte;
cDepthBits: Byte;
cStencilBits: Byte;
cAuxBuffers: Byte;
iLayerType: Byte;
bReserved: Byte;
dwLayerMask: DWORD;
dwVisibleMask: DWORD;
dwDamageMask: DWORD;
end;
EMRPIXELFORMAT = record
emr: EMR;
pfd: PIXELFORMATDESCRIPTOR;
end;const EMR = extern struct {
iType: u32,
nSize: u32,
};
const PIXELFORMATDESCRIPTOR = extern struct {
nSize: u16,
nVersion: u16,
dwFlags: u32,
iPixelType: u8,
cColorBits: u8,
cRedBits: u8,
cRedShift: u8,
cGreenBits: u8,
cGreenShift: u8,
cBlueBits: u8,
cBlueShift: u8,
cAlphaBits: u8,
cAlphaShift: u8,
cAccumBits: u8,
cAccumRedBits: u8,
cAccumGreenBits: u8,
cAccumBlueBits: u8,
cAccumAlphaBits: u8,
cDepthBits: u8,
cStencilBits: u8,
cAuxBuffers: u8,
iLayerType: u8,
bReserved: u8,
dwLayerMask: u32,
dwVisibleMask: u32,
dwDamageMask: u32,
};
const EMRPIXELFORMAT = extern struct {
emr: EMR,
pfd: PIXELFORMATDESCRIPTOR,
};type
EMR {.bycopy.} = object
iType: uint32
nSize: uint32
PIXELFORMATDESCRIPTOR {.bycopy.} = object
nSize: uint16
nVersion: uint16
dwFlags: uint32
iPixelType: uint8
cColorBits: uint8
cRedBits: uint8
cRedShift: uint8
cGreenBits: uint8
cGreenShift: uint8
cBlueBits: uint8
cBlueShift: uint8
cAlphaBits: uint8
cAlphaShift: uint8
cAccumBits: uint8
cAccumRedBits: uint8
cAccumGreenBits: uint8
cAccumBlueBits: uint8
cAccumAlphaBits: uint8
cDepthBits: uint8
cStencilBits: uint8
cAuxBuffers: uint8
iLayerType: uint8
bReserved: uint8
dwLayerMask: uint32
dwVisibleMask: uint32
dwDamageMask: uint32
EMRPIXELFORMAT {.bycopy.} = object
emr: EMR
pfd: PIXELFORMATDESCRIPTORstruct EMR
{
uint iType;
uint nSize;
}
struct PIXELFORMATDESCRIPTOR
{
ushort nSize;
ushort nVersion;
uint dwFlags;
ubyte iPixelType;
ubyte cColorBits;
ubyte cRedBits;
ubyte cRedShift;
ubyte cGreenBits;
ubyte cGreenShift;
ubyte cBlueBits;
ubyte cBlueShift;
ubyte cAlphaBits;
ubyte cAlphaShift;
ubyte cAccumBits;
ubyte cAccumRedBits;
ubyte cAccumGreenBits;
ubyte cAccumBlueBits;
ubyte cAccumAlphaBits;
ubyte cDepthBits;
ubyte cStencilBits;
ubyte cAuxBuffers;
ubyte iLayerType;
ubyte bReserved;
uint dwLayerMask;
uint dwVisibleMask;
uint dwDamageMask;
}
struct EMRPIXELFORMAT
{
EMR emr;
PIXELFORMATDESCRIPTOR pfd;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EMRPIXELFORMAT サイズ: 48 バイト(x64)
dim st, 12 ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; emr : EMR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; pfd : PIXELFORMATDESCRIPTOR (+8, 40byte) varptr(st)+8 を基点に操作(40byte:入れ子/配列)
; ※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 PIXELFORMATDESCRIPTOR
#field short nSize
#field short nVersion
#field int dwFlags
#field byte iPixelType
#field byte cColorBits
#field byte cRedBits
#field byte cRedShift
#field byte cGreenBits
#field byte cGreenShift
#field byte cBlueBits
#field byte cBlueShift
#field byte cAlphaBits
#field byte cAlphaShift
#field byte cAccumBits
#field byte cAccumRedBits
#field byte cAccumGreenBits
#field byte cAccumBlueBits
#field byte cAccumAlphaBits
#field byte cDepthBits
#field byte cStencilBits
#field byte cAuxBuffers
#field byte iLayerType
#field byte bReserved
#field int dwLayerMask
#field int dwVisibleMask
#field int dwDamageMask
#endstruct
#defstruct global EMRPIXELFORMAT
#field EMR emr
#field PIXELFORMATDESCRIPTOR pfd
#endstruct
stdim st, EMRPIXELFORMAT ; NSTRUCT 変数を確保