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

WICImageParameters

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

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

フィールド

フィールドサイズx64x86説明
PixelFormatD2D1_PIXEL_FORMAT8+0+0出力画像のピクセル形式とアルファモードを示すD2D1_PIXEL_FORMAT。
DpiXFLOAT4+8+8画像の水平方向の解像度(DPI)。
DpiYFLOAT4+12+12画像の垂直方向の解像度(DPI)。
TopFLOAT4+16+16描画対象矩形の上端座標(DIP単位)。
LeftFLOAT4+20+20描画対象矩形の左端座標(DIP単位)。
PixelWidthDWORD4+24+24出力画像の幅(ピクセル単位)。
PixelHeightDWORD4+28+28出力画像の高さ(ピクセル単位)。

各言語での定義

#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;

// WICImageParameters  (x64 32 / x86 32 バイト)
typedef struct WICImageParameters {
    D2D1_PIXEL_FORMAT PixelFormat;
    FLOAT DpiX;
    FLOAT DpiY;
    FLOAT Top;
    FLOAT Left;
    DWORD PixelWidth;
    DWORD PixelHeight;
} WICImageParameters;
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 WICImageParameters
{
    public D2D1_PIXEL_FORMAT PixelFormat;
    public float DpiX;
    public float DpiY;
    public float Top;
    public float Left;
    public uint PixelWidth;
    public uint PixelHeight;
}
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 WICImageParameters
    Public PixelFormat As D2D1_PIXEL_FORMAT
    Public DpiX As Single
    Public DpiY As Single
    Public Top As Single
    Public Left As Single
    Public PixelWidth As UInteger
    Public PixelHeight As UInteger
End Structure
import ctypes
from ctypes import wintypes

class D2D1_PIXEL_FORMAT(ctypes.Structure):
    _fields_ = [
        ("format", ctypes.c_int),
        ("alphaMode", ctypes.c_int),
    ]

class WICImageParameters(ctypes.Structure):
    _fields_ = [
        ("PixelFormat", D2D1_PIXEL_FORMAT),
        ("DpiX", ctypes.c_float),
        ("DpiY", ctypes.c_float),
        ("Top", ctypes.c_float),
        ("Left", ctypes.c_float),
        ("PixelWidth", wintypes.DWORD),
        ("PixelHeight", wintypes.DWORD),
    ]
#[repr(C)]
pub struct D2D1_PIXEL_FORMAT {
    pub format: i32,
    pub alphaMode: i32,
}

#[repr(C)]
pub struct WICImageParameters {
    pub PixelFormat: D2D1_PIXEL_FORMAT,
    pub DpiX: f32,
    pub DpiY: f32,
    pub Top: f32,
    pub Left: f32,
    pub PixelWidth: u32,
    pub PixelHeight: u32,
}
import "golang.org/x/sys/windows"

type D2D1_PIXEL_FORMAT struct {
	format int32
	alphaMode int32
}

type WICImageParameters struct {
	PixelFormat D2D1_PIXEL_FORMAT
	DpiX float32
	DpiY float32
	Top float32
	Left float32
	PixelWidth uint32
	PixelHeight uint32
}
type
  D2D1_PIXEL_FORMAT = record
    format: Integer;
    alphaMode: Integer;
  end;

  WICImageParameters = record
    PixelFormat: D2D1_PIXEL_FORMAT;
    DpiX: Single;
    DpiY: Single;
    Top: Single;
    Left: Single;
    PixelWidth: DWORD;
    PixelHeight: DWORD;
  end;
const D2D1_PIXEL_FORMAT = extern struct {
    format: i32,
    alphaMode: i32,
};

const WICImageParameters = extern struct {
    PixelFormat: D2D1_PIXEL_FORMAT,
    DpiX: f32,
    DpiY: f32,
    Top: f32,
    Left: f32,
    PixelWidth: u32,
    PixelHeight: u32,
};
type
  D2D1_PIXEL_FORMAT {.bycopy.} = object
    format: int32
    alphaMode: int32

  WICImageParameters {.bycopy.} = object
    PixelFormat: D2D1_PIXEL_FORMAT
    DpiX: float32
    DpiY: float32
    Top: float32
    Left: float32
    PixelWidth: uint32
    PixelHeight: uint32
struct D2D1_PIXEL_FORMAT
{
    int format;
    int alphaMode;
}

struct WICImageParameters
{
    D2D1_PIXEL_FORMAT PixelFormat;
    float DpiX;
    float DpiY;
    float Top;
    float Left;
    uint PixelWidth;
    uint PixelHeight;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WICImageParameters サイズ: 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 も可)
; Top : FLOAT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; Left : FLOAT (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; PixelWidth : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; PixelHeight : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※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 WICImageParameters
    #field D2D1_PIXEL_FORMAT PixelFormat
    #field float DpiX
    #field float DpiY
    #field float Top
    #field float Left
    #field int PixelWidth
    #field int PixelHeight
#endstruct

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