ホーム › Graphics.GdiPlus › GdipDrawImageRectRect
GdipDrawImageRectRect
関数画像の元矩形を変換先矩形に属性付きで描画する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipDrawImageRectRect(
GpGraphics* graphics,
GpImage* image,
FLOAT dstx,
FLOAT dsty,
FLOAT dstwidth,
FLOAT dstheight,
FLOAT srcx,
FLOAT srcy,
FLOAT srcwidth,
FLOAT srcheight,
Unit srcUnit,
const GpImageAttributes* imageAttributes,
INT_PTR callback,
void* callbackData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| graphics | GpGraphics* | inout | 描画先のGDI+グラフィックスオブジェクトへのポインタ。 |
| image | GpImage* | inout | 描画する画像オブジェクトへのポインタ。 |
| dstx | FLOAT | in | 描画先矩形左上隅のX座標(浮動小数)。 |
| dsty | FLOAT | in | 描画先矩形左上隅のY座標(浮動小数)。 |
| dstwidth | FLOAT | in | 描画先矩形の幅(浮動小数)。 |
| dstheight | FLOAT | in | 描画先矩形の高さ(浮動小数)。 |
| srcx | FLOAT | in | 元画像内の切り出し開始X座標(浮動小数)。 |
| srcy | FLOAT | in | 元画像内の切り出し開始Y座標(浮動小数)。 |
| srcwidth | FLOAT | in | 元画像から切り出す幅(浮動小数)。 |
| srcheight | FLOAT | in | 元画像から切り出す高さ(浮動小数)。 |
| srcUnit | Unit | in | 元矩形の座標単位を示すUnit列挙値。 |
| imageAttributes | GpImageAttributes* | in | 色調整など描画属性を指定するImageAttributesへのポインタ。NULL可。 |
| callback | INT_PTR | in | 描画中断判定用コールバック関数へのアドレス。不要なら0(NULL)。 |
| callbackData | void* | inout | コールバックへ渡す任意データへのポインタ。NULL可。 |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipDrawImageRectRect(
GpGraphics* graphics,
GpImage* image,
FLOAT dstx,
FLOAT dsty,
FLOAT dstwidth,
FLOAT dstheight,
FLOAT srcx,
FLOAT srcy,
FLOAT srcwidth,
FLOAT srcheight,
Unit srcUnit,
const GpImageAttributes* imageAttributes,
INT_PTR callback,
void* callbackData
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipDrawImageRectRect(
IntPtr graphics, // GpGraphics* in/out
IntPtr image, // GpImage* in/out
float dstx, // FLOAT
float dsty, // FLOAT
float dstwidth, // FLOAT
float dstheight, // FLOAT
float srcx, // FLOAT
float srcy, // FLOAT
float srcwidth, // FLOAT
float srcheight, // FLOAT
int srcUnit, // Unit
IntPtr imageAttributes, // GpImageAttributes*
IntPtr callback, // INT_PTR
IntPtr callbackData // void* in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipDrawImageRectRect(
graphics As IntPtr, ' GpGraphics* in/out
image As IntPtr, ' GpImage* in/out
dstx As Single, ' FLOAT
dsty As Single, ' FLOAT
dstwidth As Single, ' FLOAT
dstheight As Single, ' FLOAT
srcx As Single, ' FLOAT
srcy As Single, ' FLOAT
srcwidth As Single, ' FLOAT
srcheight As Single, ' FLOAT
srcUnit As Integer, ' Unit
imageAttributes As IntPtr, ' GpImageAttributes*
callback As IntPtr, ' INT_PTR
callbackData As IntPtr ' void* in/out
) As Integer
End Function' graphics : GpGraphics* in/out
' image : GpImage* in/out
' dstx : FLOAT
' dsty : FLOAT
' dstwidth : FLOAT
' dstheight : FLOAT
' srcx : FLOAT
' srcy : FLOAT
' srcwidth : FLOAT
' srcheight : FLOAT
' srcUnit : Unit
' imageAttributes : GpImageAttributes*
' callback : INT_PTR
' callbackData : void* in/out
Declare PtrSafe Function GdipDrawImageRectRect Lib "gdiplus" ( _
ByVal graphics As LongPtr, _
ByVal image As LongPtr, _
ByVal dstx As Single, _
ByVal dsty As Single, _
ByVal dstwidth As Single, _
ByVal dstheight As Single, _
ByVal srcx As Single, _
ByVal srcy As Single, _
ByVal srcwidth As Single, _
ByVal srcheight As Single, _
ByVal srcUnit As Long, _
ByVal imageAttributes As LongPtr, _
ByVal callback As LongPtr, _
ByVal callbackData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipDrawImageRectRect = ctypes.windll.gdiplus.GdipDrawImageRectRect
GdipDrawImageRectRect.restype = ctypes.c_int
GdipDrawImageRectRect.argtypes = [
ctypes.c_void_p, # graphics : GpGraphics* in/out
ctypes.c_void_p, # image : GpImage* in/out
ctypes.c_float, # dstx : FLOAT
ctypes.c_float, # dsty : FLOAT
ctypes.c_float, # dstwidth : FLOAT
ctypes.c_float, # dstheight : FLOAT
ctypes.c_float, # srcx : FLOAT
ctypes.c_float, # srcy : FLOAT
ctypes.c_float, # srcwidth : FLOAT
ctypes.c_float, # srcheight : FLOAT
ctypes.c_int, # srcUnit : Unit
ctypes.c_void_p, # imageAttributes : GpImageAttributes*
ctypes.c_ssize_t, # callback : INT_PTR
ctypes.POINTER(None), # callbackData : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipDrawImageRectRect = Fiddle::Function.new(
lib['GdipDrawImageRectRect'],
[
Fiddle::TYPE_VOIDP, # graphics : GpGraphics* in/out
Fiddle::TYPE_VOIDP, # image : GpImage* in/out
Fiddle::TYPE_FLOAT, # dstx : FLOAT
Fiddle::TYPE_FLOAT, # dsty : FLOAT
Fiddle::TYPE_FLOAT, # dstwidth : FLOAT
Fiddle::TYPE_FLOAT, # dstheight : FLOAT
Fiddle::TYPE_FLOAT, # srcx : FLOAT
Fiddle::TYPE_FLOAT, # srcy : FLOAT
Fiddle::TYPE_FLOAT, # srcwidth : FLOAT
Fiddle::TYPE_FLOAT, # srcheight : FLOAT
Fiddle::TYPE_INT, # srcUnit : Unit
Fiddle::TYPE_VOIDP, # imageAttributes : GpImageAttributes*
Fiddle::TYPE_INTPTR_T, # callback : INT_PTR
Fiddle::TYPE_VOIDP, # callbackData : void* in/out
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipDrawImageRectRect(
graphics: *mut GpGraphics, // GpGraphics* in/out
image: *mut GpImage, // GpImage* in/out
dstx: f32, // FLOAT
dsty: f32, // FLOAT
dstwidth: f32, // FLOAT
dstheight: f32, // FLOAT
srcx: f32, // FLOAT
srcy: f32, // FLOAT
srcwidth: f32, // FLOAT
srcheight: f32, // FLOAT
srcUnit: i32, // Unit
imageAttributes: *const GpImageAttributes, // GpImageAttributes*
callback: isize, // INT_PTR
callbackData: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipDrawImageRectRect(IntPtr graphics, IntPtr image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, int srcUnit, IntPtr imageAttributes, IntPtr callback, IntPtr callbackData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipDrawImageRectRect' -Namespace Win32 -PassThru
# $api::GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)#uselib "gdiplus.dll"
#func global GdipDrawImageRectRect "GdipDrawImageRectRect" sptr, sptr, float, float, float, float, float, float, float, float, sptr, sptr, sptr, sptr
; GdipDrawImageRectRect varptr(graphics), varptr(image), dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, varptr(imageAttributes), callback, callbackData ; 戻り値は stat
; graphics : GpGraphics* in/out -> "sptr"
; image : GpImage* in/out -> "sptr"
; dstx : FLOAT -> "float"
; dsty : FLOAT -> "float"
; dstwidth : FLOAT -> "float"
; dstheight : FLOAT -> "float"
; srcx : FLOAT -> "float"
; srcy : FLOAT -> "float"
; srcwidth : FLOAT -> "float"
; srcheight : FLOAT -> "float"
; srcUnit : Unit -> "sptr"
; imageAttributes : GpImageAttributes* -> "sptr"
; callback : INT_PTR -> "sptr"
; callbackData : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipDrawImageRectRect "GdipDrawImageRectRect" var, var, float, float, float, float, float, float, float, float, int, var, sptr, sptr ; res = GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData) ; graphics : GpGraphics* in/out -> "var" ; image : GpImage* in/out -> "var" ; dstx : FLOAT -> "float" ; dsty : FLOAT -> "float" ; dstwidth : FLOAT -> "float" ; dstheight : FLOAT -> "float" ; srcx : FLOAT -> "float" ; srcy : FLOAT -> "float" ; srcwidth : FLOAT -> "float" ; srcheight : FLOAT -> "float" ; srcUnit : Unit -> "int" ; imageAttributes : GpImageAttributes* -> "var" ; callback : INT_PTR -> "sptr" ; callbackData : void* in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipDrawImageRectRect "GdipDrawImageRectRect" sptr, sptr, float, float, float, float, float, float, float, float, int, sptr, sptr, sptr ; res = GdipDrawImageRectRect(varptr(graphics), varptr(image), dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, varptr(imageAttributes), callback, callbackData) ; graphics : GpGraphics* in/out -> "sptr" ; image : GpImage* in/out -> "sptr" ; dstx : FLOAT -> "float" ; dsty : FLOAT -> "float" ; dstwidth : FLOAT -> "float" ; dstheight : FLOAT -> "float" ; srcx : FLOAT -> "float" ; srcy : FLOAT -> "float" ; srcwidth : FLOAT -> "float" ; srcheight : FLOAT -> "float" ; srcUnit : Unit -> "int" ; imageAttributes : GpImageAttributes* -> "sptr" ; callback : INT_PTR -> "sptr" ; callbackData : void* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipDrawImageRectRect(GpGraphics* graphics, GpImage* image, FLOAT dstx, FLOAT dsty, FLOAT dstwidth, FLOAT dstheight, FLOAT srcx, FLOAT srcy, FLOAT srcwidth, FLOAT srcheight, Unit srcUnit, GpImageAttributes* imageAttributes, INT_PTR callback, void* callbackData) #uselib "gdiplus.dll" #cfunc global GdipDrawImageRectRect "GdipDrawImageRectRect" var, var, float, float, float, float, float, float, float, float, int, var, intptr, intptr ; res = GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData) ; graphics : GpGraphics* in/out -> "var" ; image : GpImage* in/out -> "var" ; dstx : FLOAT -> "float" ; dsty : FLOAT -> "float" ; dstwidth : FLOAT -> "float" ; dstheight : FLOAT -> "float" ; srcx : FLOAT -> "float" ; srcy : FLOAT -> "float" ; srcwidth : FLOAT -> "float" ; srcheight : FLOAT -> "float" ; srcUnit : Unit -> "int" ; imageAttributes : GpImageAttributes* -> "var" ; callback : INT_PTR -> "intptr" ; callbackData : void* in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipDrawImageRectRect(GpGraphics* graphics, GpImage* image, FLOAT dstx, FLOAT dsty, FLOAT dstwidth, FLOAT dstheight, FLOAT srcx, FLOAT srcy, FLOAT srcwidth, FLOAT srcheight, Unit srcUnit, GpImageAttributes* imageAttributes, INT_PTR callback, void* callbackData) #uselib "gdiplus.dll" #cfunc global GdipDrawImageRectRect "GdipDrawImageRectRect" intptr, intptr, float, float, float, float, float, float, float, float, int, intptr, intptr, intptr ; res = GdipDrawImageRectRect(varptr(graphics), varptr(image), dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, varptr(imageAttributes), callback, callbackData) ; graphics : GpGraphics* in/out -> "intptr" ; image : GpImage* in/out -> "intptr" ; dstx : FLOAT -> "float" ; dsty : FLOAT -> "float" ; dstwidth : FLOAT -> "float" ; dstheight : FLOAT -> "float" ; srcx : FLOAT -> "float" ; srcy : FLOAT -> "float" ; srcwidth : FLOAT -> "float" ; srcheight : FLOAT -> "float" ; srcUnit : Unit -> "int" ; imageAttributes : GpImageAttributes* -> "intptr" ; callback : INT_PTR -> "intptr" ; callbackData : void* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipDrawImageRectRect = gdiplus.NewProc("GdipDrawImageRectRect")
)
// graphics (GpGraphics* in/out), image (GpImage* in/out), dstx (FLOAT), dsty (FLOAT), dstwidth (FLOAT), dstheight (FLOAT), srcx (FLOAT), srcy (FLOAT), srcwidth (FLOAT), srcheight (FLOAT), srcUnit (Unit), imageAttributes (GpImageAttributes*), callback (INT_PTR), callbackData (void* in/out)
r1, _, err := procGdipDrawImageRectRect.Call(
uintptr(graphics),
uintptr(image),
uintptr(math.Float32bits(dstx)),
uintptr(math.Float32bits(dsty)),
uintptr(math.Float32bits(dstwidth)),
uintptr(math.Float32bits(dstheight)),
uintptr(math.Float32bits(srcx)),
uintptr(math.Float32bits(srcy)),
uintptr(math.Float32bits(srcwidth)),
uintptr(math.Float32bits(srcheight)),
uintptr(srcUnit),
uintptr(imageAttributes),
uintptr(callback),
uintptr(callbackData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Status
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。function GdipDrawImageRectRect(
graphics: Pointer; // GpGraphics* in/out
image: Pointer; // GpImage* in/out
dstx: Single; // FLOAT
dsty: Single; // FLOAT
dstwidth: Single; // FLOAT
dstheight: Single; // FLOAT
srcx: Single; // FLOAT
srcy: Single; // FLOAT
srcwidth: Single; // FLOAT
srcheight: Single; // FLOAT
srcUnit: Integer; // Unit
imageAttributes: Pointer; // GpImageAttributes*
callback: NativeInt; // INT_PTR
callbackData: Pointer // void* in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipDrawImageRectRect';result := DllCall("gdiplus\GdipDrawImageRectRect"
, "Ptr", graphics ; GpGraphics* in/out
, "Ptr", image ; GpImage* in/out
, "Float", dstx ; FLOAT
, "Float", dsty ; FLOAT
, "Float", dstwidth ; FLOAT
, "Float", dstheight ; FLOAT
, "Float", srcx ; FLOAT
, "Float", srcy ; FLOAT
, "Float", srcwidth ; FLOAT
, "Float", srcheight ; FLOAT
, "Int", srcUnit ; Unit
, "Ptr", imageAttributes ; GpImageAttributes*
, "Ptr", callback ; INT_PTR
, "Ptr", callbackData ; void* in/out
, "Int") ; return: Status●GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData) = DLL("gdiplus.dll", "int GdipDrawImageRectRect(void*, void*, float, float, float, float, float, float, float, float, int, void*, int, void*)")
# 呼び出し: GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)
# graphics : GpGraphics* in/out -> "void*"
# image : GpImage* in/out -> "void*"
# dstx : FLOAT -> "float"
# dsty : FLOAT -> "float"
# dstwidth : FLOAT -> "float"
# dstheight : FLOAT -> "float"
# srcx : FLOAT -> "float"
# srcy : FLOAT -> "float"
# srcwidth : FLOAT -> "float"
# srcheight : FLOAT -> "float"
# srcUnit : Unit -> "int"
# imageAttributes : GpImageAttributes* -> "void*"
# callback : INT_PTR -> "int"
# callbackData : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdiplus" fn GdipDrawImageRectRect(
graphics: [*c]GpGraphics, // GpGraphics* in/out
image: [*c]GpImage, // GpImage* in/out
dstx: f32, // FLOAT
dsty: f32, // FLOAT
dstwidth: f32, // FLOAT
dstheight: f32, // FLOAT
srcx: f32, // FLOAT
srcy: f32, // FLOAT
srcwidth: f32, // FLOAT
srcheight: f32, // FLOAT
srcUnit: i32, // Unit
imageAttributes: [*c]GpImageAttributes, // GpImageAttributes*
callback: isize, // INT_PTR
callbackData: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;proc GdipDrawImageRectRect(
graphics: ptr GpGraphics, # GpGraphics* in/out
image: ptr GpImage, # GpImage* in/out
dstx: float32, # FLOAT
dsty: float32, # FLOAT
dstwidth: float32, # FLOAT
dstheight: float32, # FLOAT
srcx: float32, # FLOAT
srcy: float32, # FLOAT
srcwidth: float32, # FLOAT
srcheight: float32, # FLOAT
srcUnit: int32, # Unit
imageAttributes: ptr GpImageAttributes, # GpImageAttributes*
callback: int, # INT_PTR
callbackData: pointer # void* in/out
): int32 {.importc: "GdipDrawImageRectRect", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipDrawImageRectRect(
GpGraphics* graphics, // GpGraphics* in/out
GpImage* image, // GpImage* in/out
float dstx, // FLOAT
float dsty, // FLOAT
float dstwidth, // FLOAT
float dstheight, // FLOAT
float srcx, // FLOAT
float srcy, // FLOAT
float srcwidth, // FLOAT
float srcheight, // FLOAT
int srcUnit, // Unit
GpImageAttributes* imageAttributes, // GpImageAttributes*
ptrdiff_t callback, // INT_PTR
void* callbackData // void* in/out
);ccall((:GdipDrawImageRectRect, "gdiplus.dll"), stdcall, Int32,
(Ptr{GpGraphics}, Ptr{GpImage}, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32, Int32, Ptr{GpImageAttributes}, Int, Ptr{Cvoid}),
graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)
# graphics : GpGraphics* in/out -> Ptr{GpGraphics}
# image : GpImage* in/out -> Ptr{GpImage}
# dstx : FLOAT -> Float32
# dsty : FLOAT -> Float32
# dstwidth : FLOAT -> Float32
# dstheight : FLOAT -> Float32
# srcx : FLOAT -> Float32
# srcy : FLOAT -> Float32
# srcwidth : FLOAT -> Float32
# srcheight : FLOAT -> Float32
# srcUnit : Unit -> Int32
# imageAttributes : GpImageAttributes* -> Ptr{GpImageAttributes}
# callback : INT_PTR -> Int
# callbackData : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipDrawImageRectRect(
void* graphics,
void* image,
float dstx,
float dsty,
float dstwidth,
float dstheight,
float srcx,
float srcy,
float srcwidth,
float srcheight,
int32_t srcUnit,
void* imageAttributes,
intptr_t callback,
void* callbackData);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)
-- graphics : GpGraphics* in/out
-- image : GpImage* in/out
-- dstx : FLOAT
-- dsty : FLOAT
-- dstwidth : FLOAT
-- dstheight : FLOAT
-- srcx : FLOAT
-- srcy : FLOAT
-- srcwidth : FLOAT
-- srcheight : FLOAT
-- srcUnit : Unit
-- imageAttributes : GpImageAttributes*
-- callback : INT_PTR
-- callbackData : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipDrawImageRectRect = lib.func('__stdcall', 'GdipDrawImageRectRect', 'int32_t', ['void *', 'void *', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'float', 'int32_t', 'void *', 'intptr_t', 'void *']);
// GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)
// graphics : GpGraphics* in/out -> 'void *'
// image : GpImage* in/out -> 'void *'
// dstx : FLOAT -> 'float'
// dsty : FLOAT -> 'float'
// dstwidth : FLOAT -> 'float'
// dstheight : FLOAT -> 'float'
// srcx : FLOAT -> 'float'
// srcy : FLOAT -> 'float'
// srcwidth : FLOAT -> 'float'
// srcheight : FLOAT -> 'float'
// srcUnit : Unit -> 'int32_t'
// imageAttributes : GpImageAttributes* -> 'void *'
// callback : INT_PTR -> 'intptr_t'
// callbackData : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipDrawImageRectRect: { parameters: ["pointer", "pointer", "f32", "f32", "f32", "f32", "f32", "f32", "f32", "f32", "i32", "pointer", "isize", "pointer"], result: "i32" },
});
// lib.symbols.GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)
// graphics : GpGraphics* in/out -> "pointer"
// image : GpImage* in/out -> "pointer"
// dstx : FLOAT -> "f32"
// dsty : FLOAT -> "f32"
// dstwidth : FLOAT -> "f32"
// dstheight : FLOAT -> "f32"
// srcx : FLOAT -> "f32"
// srcy : FLOAT -> "f32"
// srcwidth : FLOAT -> "f32"
// srcheight : FLOAT -> "f32"
// srcUnit : Unit -> "i32"
// imageAttributes : GpImageAttributes* -> "pointer"
// callback : INT_PTR -> "isize"
// callbackData : void* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipDrawImageRectRect(
void* graphics,
void* image,
float dstx,
float dsty,
float dstwidth,
float dstheight,
float srcx,
float srcy,
float srcwidth,
float srcheight,
int32_t srcUnit,
void* imageAttributes,
intptr_t callback,
void* callbackData);
C, "gdiplus.dll");
// $ffi->GdipDrawImageRectRect(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData);
// graphics : GpGraphics* in/out
// image : GpImage* in/out
// dstx : FLOAT
// dsty : FLOAT
// dstwidth : FLOAT
// dstheight : FLOAT
// srcx : FLOAT
// srcy : FLOAT
// srcwidth : FLOAT
// srcheight : FLOAT
// srcUnit : Unit
// imageAttributes : GpImageAttributes*
// callback : INT_PTR
// callbackData : void* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Gdiplus extends StdCallLibrary {
Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class);
int GdipDrawImageRectRect(
Pointer graphics, // GpGraphics* in/out
Pointer image, // GpImage* in/out
float dstx, // FLOAT
float dsty, // FLOAT
float dstwidth, // FLOAT
float dstheight, // FLOAT
float srcx, // FLOAT
float srcy, // FLOAT
float srcwidth, // FLOAT
float srcheight, // FLOAT
int srcUnit, // Unit
Pointer imageAttributes, // GpImageAttributes*
long callback, // INT_PTR
Pointer callbackData // void* in/out
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipDrawImageRectRect = GdipDrawImageRectRect(
graphics : GpGraphics*, # GpGraphics* in/out
image : GpImage*, # GpImage* in/out
dstx : Float32, # FLOAT
dsty : Float32, # FLOAT
dstwidth : Float32, # FLOAT
dstheight : Float32, # FLOAT
srcx : Float32, # FLOAT
srcy : Float32, # FLOAT
srcwidth : Float32, # FLOAT
srcheight : Float32, # FLOAT
srcUnit : Int32, # Unit
imageAttributes : GpImageAttributes*, # GpImageAttributes*
callback : LibC::SSizeT, # INT_PTR
callbackData : Void* # void* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipDrawImageRectRectNative = Int32 Function(Pointer<Void>, Pointer<Void>, Float, Float, Float, Float, Float, Float, Float, Float, Int32, Pointer<Void>, IntPtr, Pointer<Void>);
typedef GdipDrawImageRectRectDart = int Function(Pointer<Void>, Pointer<Void>, double, double, double, double, double, double, double, double, int, Pointer<Void>, int, Pointer<Void>);
final GdipDrawImageRectRect = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipDrawImageRectRectNative, GdipDrawImageRectRectDart>('GdipDrawImageRectRect');
// graphics : GpGraphics* in/out -> Pointer<Void>
// image : GpImage* in/out -> Pointer<Void>
// dstx : FLOAT -> Float
// dsty : FLOAT -> Float
// dstwidth : FLOAT -> Float
// dstheight : FLOAT -> Float
// srcx : FLOAT -> Float
// srcy : FLOAT -> Float
// srcwidth : FLOAT -> Float
// srcheight : FLOAT -> Float
// srcUnit : Unit -> Int32
// imageAttributes : GpImageAttributes* -> Pointer<Void>
// callback : INT_PTR -> IntPtr
// callbackData : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipDrawImageRectRect(
graphics: Pointer; // GpGraphics* in/out
image: Pointer; // GpImage* in/out
dstx: Single; // FLOAT
dsty: Single; // FLOAT
dstwidth: Single; // FLOAT
dstheight: Single; // FLOAT
srcx: Single; // FLOAT
srcy: Single; // FLOAT
srcwidth: Single; // FLOAT
srcheight: Single; // FLOAT
srcUnit: Integer; // Unit
imageAttributes: Pointer; // GpImageAttributes*
callback: NativeInt; // INT_PTR
callbackData: Pointer // void* in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipDrawImageRectRect';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipDrawImageRectRect"
c_GdipDrawImageRectRect :: Ptr () -> Ptr () -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> Int32 -> Ptr () -> CIntPtr -> Ptr () -> IO Int32
-- graphics : GpGraphics* in/out -> Ptr ()
-- image : GpImage* in/out -> Ptr ()
-- dstx : FLOAT -> CFloat
-- dsty : FLOAT -> CFloat
-- dstwidth : FLOAT -> CFloat
-- dstheight : FLOAT -> CFloat
-- srcx : FLOAT -> CFloat
-- srcy : FLOAT -> CFloat
-- srcwidth : FLOAT -> CFloat
-- srcheight : FLOAT -> CFloat
-- srcUnit : Unit -> Int32
-- imageAttributes : GpImageAttributes* -> Ptr ()
-- callback : INT_PTR -> CIntPtr
-- callbackData : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipdrawimagerectrect =
foreign "GdipDrawImageRectRect"
((ptr void) @-> (ptr void) @-> float @-> float @-> float @-> float @-> float @-> float @-> float @-> float @-> int32_t @-> (ptr void) @-> intptr_t @-> (ptr void) @-> returning int32_t)
(* graphics : GpGraphics* in/out -> (ptr void) *)
(* image : GpImage* in/out -> (ptr void) *)
(* dstx : FLOAT -> float *)
(* dsty : FLOAT -> float *)
(* dstwidth : FLOAT -> float *)
(* dstheight : FLOAT -> float *)
(* srcx : FLOAT -> float *)
(* srcy : FLOAT -> float *)
(* srcwidth : FLOAT -> float *)
(* srcheight : FLOAT -> float *)
(* srcUnit : Unit -> int32_t *)
(* imageAttributes : GpImageAttributes* -> (ptr void) *)
(* callback : INT_PTR -> intptr_t *)
(* callbackData : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipDrawImageRectRect" gdip-draw-image-rect-rect :convention :stdcall) :int32
(graphics :pointer) ; GpGraphics* in/out
(image :pointer) ; GpImage* in/out
(dstx :float) ; FLOAT
(dsty :float) ; FLOAT
(dstwidth :float) ; FLOAT
(dstheight :float) ; FLOAT
(srcx :float) ; FLOAT
(srcy :float) ; FLOAT
(srcwidth :float) ; FLOAT
(srcheight :float) ; FLOAT
(src-unit :int32) ; Unit
(image-attributes :pointer) ; GpImageAttributes*
(callback :int64) ; INT_PTR
(callback-data :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipDrawImageRectRect = Win32::API::More->new('gdiplus',
'int GdipDrawImageRectRect(LPVOID graphics, LPVOID image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, int srcUnit, LPVOID imageAttributes, LPARAM callback, LPVOID callbackData)');
# my $ret = $GdipDrawImageRectRect->Call($graphics, $image, $dstx, $dsty, $dstwidth, $dstheight, $srcx, $srcy, $srcwidth, $srcheight, $srcUnit, $imageAttributes, $callback, $callbackData);
# graphics : GpGraphics* in/out -> LPVOID
# image : GpImage* in/out -> LPVOID
# dstx : FLOAT -> float
# dsty : FLOAT -> float
# dstwidth : FLOAT -> float
# dstheight : FLOAT -> float
# srcx : FLOAT -> float
# srcy : FLOAT -> float
# srcwidth : FLOAT -> float
# srcheight : FLOAT -> float
# srcUnit : Unit -> int
# imageAttributes : GpImageAttributes* -> LPVOID
# callback : INT_PTR -> LPARAM
# callbackData : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。