ホーム › Graphics.Direct2D › D2D1_BITMAP_PROPERTIES1
D2D1_BITMAP_PROPERTIES1
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| pixelFormat | D2D1_PIXEL_FORMAT | 8 | +0 | +0 | ビットマップのピクセル形式とアルファモード。 |
| dpiX | FLOAT | 4 | +8 | +8 | 水平方向DPI。 |
| dpiY | FLOAT | 4 | +12 | +12 | 垂直方向DPI。 |
| bitmapOptions | D2D1_BITMAP_OPTIONS | 4 | +16 | +16 | ビットマップの用途オプション(ターゲット可、CPU読み取り可等)。 |
| colorContext | ID2D1ColorContext* | 8/4 | +24 | +20 | 関連付ける色コンテキスト。NULL可。 |
各言語での定義
#include <windows.h>
// D2D1_PIXEL_FORMAT (x64 8 / x86 8 バイト)
typedef struct D2D1_PIXEL_FORMAT {
DXGI_FORMAT format;
D2D1_ALPHA_MODE alphaMode;
} D2D1_PIXEL_FORMAT;
// D2D1_BITMAP_PROPERTIES1 (x64 32 / x86 24 バイト)
typedef struct D2D1_BITMAP_PROPERTIES1 {
D2D1_PIXEL_FORMAT pixelFormat;
FLOAT dpiX;
FLOAT dpiY;
D2D1_BITMAP_OPTIONS bitmapOptions;
ID2D1ColorContext* colorContext;
} D2D1_BITMAP_PROPERTIES1;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D2D1_PIXEL_FORMAT
{
public int format;
public int alphaMode;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D2D1_BITMAP_PROPERTIES1
{
public D2D1_PIXEL_FORMAT pixelFormat;
public float dpiX;
public float dpiY;
public int bitmapOptions;
public IntPtr colorContext;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D2D1_PIXEL_FORMAT
Public format As Integer
Public alphaMode As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D2D1_BITMAP_PROPERTIES1
Public pixelFormat As D2D1_PIXEL_FORMAT
Public dpiX As Single
Public dpiY As Single
Public bitmapOptions As Integer
Public colorContext As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class D2D1_PIXEL_FORMAT(ctypes.Structure):
_fields_ = [
("format", ctypes.c_int),
("alphaMode", ctypes.c_int),
]
class D2D1_BITMAP_PROPERTIES1(ctypes.Structure):
_fields_ = [
("pixelFormat", D2D1_PIXEL_FORMAT),
("dpiX", ctypes.c_float),
("dpiY", ctypes.c_float),
("bitmapOptions", ctypes.c_int),
("colorContext", ctypes.c_void_p),
]#[repr(C)]
pub struct D2D1_PIXEL_FORMAT {
pub format: i32,
pub alphaMode: i32,
}
#[repr(C)]
pub struct D2D1_BITMAP_PROPERTIES1 {
pub pixelFormat: D2D1_PIXEL_FORMAT,
pub dpiX: f32,
pub dpiY: f32,
pub bitmapOptions: i32,
pub colorContext: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type D2D1_PIXEL_FORMAT struct {
format int32
alphaMode int32
}
type D2D1_BITMAP_PROPERTIES1 struct {
pixelFormat D2D1_PIXEL_FORMAT
dpiX float32
dpiY float32
bitmapOptions int32
colorContext uintptr
}type
D2D1_PIXEL_FORMAT = record
format: Integer;
alphaMode: Integer;
end;
D2D1_BITMAP_PROPERTIES1 = record
pixelFormat: D2D1_PIXEL_FORMAT;
dpiX: Single;
dpiY: Single;
bitmapOptions: Integer;
colorContext: Pointer;
end;const D2D1_PIXEL_FORMAT = extern struct {
format: i32,
alphaMode: i32,
};
const D2D1_BITMAP_PROPERTIES1 = extern struct {
pixelFormat: D2D1_PIXEL_FORMAT,
dpiX: f32,
dpiY: f32,
bitmapOptions: i32,
colorContext: ?*anyopaque,
};type
D2D1_PIXEL_FORMAT {.bycopy.} = object
format: int32
alphaMode: int32
D2D1_BITMAP_PROPERTIES1 {.bycopy.} = object
pixelFormat: D2D1_PIXEL_FORMAT
dpiX: float32
dpiY: float32
bitmapOptions: int32
colorContext: pointerstruct D2D1_PIXEL_FORMAT
{
int format;
int alphaMode;
}
struct D2D1_BITMAP_PROPERTIES1
{
D2D1_PIXEL_FORMAT pixelFormat;
float dpiX;
float dpiY;
int bitmapOptions;
void* colorContext;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; D2D1_BITMAP_PROPERTIES1 サイズ: 24 バイト(x86)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; pixelFormat : D2D1_PIXEL_FORMAT (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; dpiX : FLOAT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dpiY : FLOAT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; bitmapOptions : D2D1_BITMAP_OPTIONS (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; colorContext : ID2D1ColorContext* (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D2D1_BITMAP_PROPERTIES1 サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; pixelFormat : D2D1_PIXEL_FORMAT (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; dpiX : FLOAT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dpiY : FLOAT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; bitmapOptions : D2D1_BITMAP_OPTIONS (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; colorContext : ID2D1ColorContext* (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global D2D1_PIXEL_FORMAT
#field int format
#field int alphaMode
#endstruct
#defstruct global D2D1_BITMAP_PROPERTIES1
#field D2D1_PIXEL_FORMAT pixelFormat
#field float dpiX
#field float dpiY
#field int bitmapOptions
#field intptr colorContext
#endstruct
stdim st, D2D1_BITMAP_PROPERTIES1 ; NSTRUCT 変数を確保
st->dpiX = 100
mes "dpiX=" + st->dpiX