ホーム › Graphics.GdiPlus › GdipDrawImageRectRectI
GdipDrawImageRectRectI
関数画像の元矩形を整数の変換先矩形に属性付きで描画する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipDrawImageRectRectI(
GpGraphics* graphics,
GpImage* image,
INT dstx,
INT dsty,
INT dstwidth,
INT dstheight,
INT srcx,
INT srcy,
INT srcwidth,
INT srcheight,
Unit srcUnit,
const GpImageAttributes* imageAttributes,
INT_PTR callback,
void* callbackData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| graphics | GpGraphics* | inout | 描画先のGDI+グラフィックスオブジェクトへのポインタ。 |
| image | GpImage* | inout | 描画する画像オブジェクトへのポインタ。 |
| dstx | INT | in | 描画先矩形左上隅のX座標(整数)。 |
| dsty | INT | in | 描画先矩形左上隅のY座標(整数)。 |
| dstwidth | INT | in | 描画先矩形の幅(整数)。 |
| dstheight | INT | in | 描画先矩形の高さ(整数)。 |
| srcx | INT | in | 元画像内の切り出し開始X座標(整数)。 |
| srcy | INT | in | 元画像内の切り出し開始Y座標(整数)。 |
| srcwidth | INT | in | 元画像から切り出す幅(整数)。 |
| srcheight | INT | 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 GdipDrawImageRectRectI(
GpGraphics* graphics,
GpImage* image,
INT dstx,
INT dsty,
INT dstwidth,
INT dstheight,
INT srcx,
INT srcy,
INT srcwidth,
INT srcheight,
Unit srcUnit,
const GpImageAttributes* imageAttributes,
INT_PTR callback,
void* callbackData
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipDrawImageRectRectI(
IntPtr graphics, // GpGraphics* in/out
IntPtr image, // GpImage* in/out
int dstx, // INT
int dsty, // INT
int dstwidth, // INT
int dstheight, // INT
int srcx, // INT
int srcy, // INT
int srcwidth, // INT
int srcheight, // INT
int srcUnit, // Unit
IntPtr imageAttributes, // GpImageAttributes*
IntPtr callback, // INT_PTR
IntPtr callbackData // void* in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipDrawImageRectRectI(
graphics As IntPtr, ' GpGraphics* in/out
image As IntPtr, ' GpImage* in/out
dstx As Integer, ' INT
dsty As Integer, ' INT
dstwidth As Integer, ' INT
dstheight As Integer, ' INT
srcx As Integer, ' INT
srcy As Integer, ' INT
srcwidth As Integer, ' INT
srcheight As Integer, ' INT
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 : INT
' dsty : INT
' dstwidth : INT
' dstheight : INT
' srcx : INT
' srcy : INT
' srcwidth : INT
' srcheight : INT
' srcUnit : Unit
' imageAttributes : GpImageAttributes*
' callback : INT_PTR
' callbackData : void* in/out
Declare PtrSafe Function GdipDrawImageRectRectI Lib "gdiplus" ( _
ByVal graphics As LongPtr, _
ByVal image As LongPtr, _
ByVal dstx As Long, _
ByVal dsty As Long, _
ByVal dstwidth As Long, _
ByVal dstheight As Long, _
ByVal srcx As Long, _
ByVal srcy As Long, _
ByVal srcwidth As Long, _
ByVal srcheight As Long, _
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
GdipDrawImageRectRectI = ctypes.windll.gdiplus.GdipDrawImageRectRectI
GdipDrawImageRectRectI.restype = ctypes.c_int
GdipDrawImageRectRectI.argtypes = [
ctypes.c_void_p, # graphics : GpGraphics* in/out
ctypes.c_void_p, # image : GpImage* in/out
ctypes.c_int, # dstx : INT
ctypes.c_int, # dsty : INT
ctypes.c_int, # dstwidth : INT
ctypes.c_int, # dstheight : INT
ctypes.c_int, # srcx : INT
ctypes.c_int, # srcy : INT
ctypes.c_int, # srcwidth : INT
ctypes.c_int, # srcheight : INT
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')
GdipDrawImageRectRectI = Fiddle::Function.new(
lib['GdipDrawImageRectRectI'],
[
Fiddle::TYPE_VOIDP, # graphics : GpGraphics* in/out
Fiddle::TYPE_VOIDP, # image : GpImage* in/out
Fiddle::TYPE_INT, # dstx : INT
Fiddle::TYPE_INT, # dsty : INT
Fiddle::TYPE_INT, # dstwidth : INT
Fiddle::TYPE_INT, # dstheight : INT
Fiddle::TYPE_INT, # srcx : INT
Fiddle::TYPE_INT, # srcy : INT
Fiddle::TYPE_INT, # srcwidth : INT
Fiddle::TYPE_INT, # srcheight : INT
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 GdipDrawImageRectRectI(
graphics: *mut GpGraphics, // GpGraphics* in/out
image: *mut GpImage, // GpImage* in/out
dstx: i32, // INT
dsty: i32, // INT
dstwidth: i32, // INT
dstheight: i32, // INT
srcx: i32, // INT
srcy: i32, // INT
srcwidth: i32, // INT
srcheight: i32, // INT
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 GdipDrawImageRectRectI(IntPtr graphics, IntPtr image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, int srcUnit, IntPtr imageAttributes, IntPtr callback, IntPtr callbackData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipDrawImageRectRectI' -Namespace Win32 -PassThru
# $api::GdipDrawImageRectRectI(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)#uselib "gdiplus.dll"
#func global GdipDrawImageRectRectI "GdipDrawImageRectRectI" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GdipDrawImageRectRectI 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 : INT -> "sptr"
; dsty : INT -> "sptr"
; dstwidth : INT -> "sptr"
; dstheight : INT -> "sptr"
; srcx : INT -> "sptr"
; srcy : INT -> "sptr"
; srcwidth : INT -> "sptr"
; srcheight : INT -> "sptr"
; srcUnit : Unit -> "sptr"
; imageAttributes : GpImageAttributes* -> "sptr"
; callback : INT_PTR -> "sptr"
; callbackData : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipDrawImageRectRectI "GdipDrawImageRectRectI" var, var, int, int, int, int, int, int, int, int, int, var, sptr, sptr ; res = GdipDrawImageRectRectI(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 : INT -> "int" ; dsty : INT -> "int" ; dstwidth : INT -> "int" ; dstheight : INT -> "int" ; srcx : INT -> "int" ; srcy : INT -> "int" ; srcwidth : INT -> "int" ; srcheight : INT -> "int" ; srcUnit : Unit -> "int" ; imageAttributes : GpImageAttributes* -> "var" ; callback : INT_PTR -> "sptr" ; callbackData : void* in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipDrawImageRectRectI "GdipDrawImageRectRectI" sptr, sptr, int, int, int, int, int, int, int, int, int, sptr, sptr, sptr ; res = GdipDrawImageRectRectI(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 : INT -> "int" ; dsty : INT -> "int" ; dstwidth : INT -> "int" ; dstheight : INT -> "int" ; srcx : INT -> "int" ; srcy : INT -> "int" ; srcwidth : INT -> "int" ; srcheight : INT -> "int" ; srcUnit : Unit -> "int" ; imageAttributes : GpImageAttributes* -> "sptr" ; callback : INT_PTR -> "sptr" ; callbackData : void* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipDrawImageRectRectI(GpGraphics* graphics, GpImage* image, INT dstx, INT dsty, INT dstwidth, INT dstheight, INT srcx, INT srcy, INT srcwidth, INT srcheight, Unit srcUnit, GpImageAttributes* imageAttributes, INT_PTR callback, void* callbackData) #uselib "gdiplus.dll" #cfunc global GdipDrawImageRectRectI "GdipDrawImageRectRectI" var, var, int, int, int, int, int, int, int, int, int, var, intptr, intptr ; res = GdipDrawImageRectRectI(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 : INT -> "int" ; dsty : INT -> "int" ; dstwidth : INT -> "int" ; dstheight : INT -> "int" ; srcx : INT -> "int" ; srcy : INT -> "int" ; srcwidth : INT -> "int" ; srcheight : INT -> "int" ; srcUnit : Unit -> "int" ; imageAttributes : GpImageAttributes* -> "var" ; callback : INT_PTR -> "intptr" ; callbackData : void* in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipDrawImageRectRectI(GpGraphics* graphics, GpImage* image, INT dstx, INT dsty, INT dstwidth, INT dstheight, INT srcx, INT srcy, INT srcwidth, INT srcheight, Unit srcUnit, GpImageAttributes* imageAttributes, INT_PTR callback, void* callbackData) #uselib "gdiplus.dll" #cfunc global GdipDrawImageRectRectI "GdipDrawImageRectRectI" intptr, intptr, int, int, int, int, int, int, int, int, int, intptr, intptr, intptr ; res = GdipDrawImageRectRectI(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 : INT -> "int" ; dsty : INT -> "int" ; dstwidth : INT -> "int" ; dstheight : INT -> "int" ; srcx : INT -> "int" ; srcy : INT -> "int" ; srcwidth : INT -> "int" ; srcheight : INT -> "int" ; srcUnit : Unit -> "int" ; imageAttributes : GpImageAttributes* -> "intptr" ; callback : INT_PTR -> "intptr" ; callbackData : void* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipDrawImageRectRectI = gdiplus.NewProc("GdipDrawImageRectRectI")
)
// graphics (GpGraphics* in/out), image (GpImage* in/out), dstx (INT), dsty (INT), dstwidth (INT), dstheight (INT), srcx (INT), srcy (INT), srcwidth (INT), srcheight (INT), srcUnit (Unit), imageAttributes (GpImageAttributes*), callback (INT_PTR), callbackData (void* in/out)
r1, _, err := procGdipDrawImageRectRectI.Call(
uintptr(graphics),
uintptr(image),
uintptr(dstx),
uintptr(dsty),
uintptr(dstwidth),
uintptr(dstheight),
uintptr(srcx),
uintptr(srcy),
uintptr(srcwidth),
uintptr(srcheight),
uintptr(srcUnit),
uintptr(imageAttributes),
uintptr(callback),
uintptr(callbackData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipDrawImageRectRectI(
graphics: Pointer; // GpGraphics* in/out
image: Pointer; // GpImage* in/out
dstx: Integer; // INT
dsty: Integer; // INT
dstwidth: Integer; // INT
dstheight: Integer; // INT
srcx: Integer; // INT
srcy: Integer; // INT
srcwidth: Integer; // INT
srcheight: Integer; // INT
srcUnit: Integer; // Unit
imageAttributes: Pointer; // GpImageAttributes*
callback: NativeInt; // INT_PTR
callbackData: Pointer // void* in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipDrawImageRectRectI';result := DllCall("gdiplus\GdipDrawImageRectRectI"
, "Ptr", graphics ; GpGraphics* in/out
, "Ptr", image ; GpImage* in/out
, "Int", dstx ; INT
, "Int", dsty ; INT
, "Int", dstwidth ; INT
, "Int", dstheight ; INT
, "Int", srcx ; INT
, "Int", srcy ; INT
, "Int", srcwidth ; INT
, "Int", srcheight ; INT
, "Int", srcUnit ; Unit
, "Ptr", imageAttributes ; GpImageAttributes*
, "Ptr", callback ; INT_PTR
, "Ptr", callbackData ; void* in/out
, "Int") ; return: Status●GdipDrawImageRectRectI(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData) = DLL("gdiplus.dll", "int GdipDrawImageRectRectI(void*, void*, int, int, int, int, int, int, int, int, int, void*, int, void*)")
# 呼び出し: GdipDrawImageRectRectI(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 : INT -> "int"
# dsty : INT -> "int"
# dstwidth : INT -> "int"
# dstheight : INT -> "int"
# srcx : INT -> "int"
# srcy : INT -> "int"
# srcwidth : INT -> "int"
# srcheight : INT -> "int"
# 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 GdipDrawImageRectRectI(
graphics: [*c]GpGraphics, // GpGraphics* in/out
image: [*c]GpImage, // GpImage* in/out
dstx: i32, // INT
dsty: i32, // INT
dstwidth: i32, // INT
dstheight: i32, // INT
srcx: i32, // INT
srcy: i32, // INT
srcwidth: i32, // INT
srcheight: i32, // INT
srcUnit: i32, // Unit
imageAttributes: [*c]GpImageAttributes, // GpImageAttributes*
callback: isize, // INT_PTR
callbackData: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;proc GdipDrawImageRectRectI(
graphics: ptr GpGraphics, # GpGraphics* in/out
image: ptr GpImage, # GpImage* in/out
dstx: int32, # INT
dsty: int32, # INT
dstwidth: int32, # INT
dstheight: int32, # INT
srcx: int32, # INT
srcy: int32, # INT
srcwidth: int32, # INT
srcheight: int32, # INT
srcUnit: int32, # Unit
imageAttributes: ptr GpImageAttributes, # GpImageAttributes*
callback: int, # INT_PTR
callbackData: pointer # void* in/out
): int32 {.importc: "GdipDrawImageRectRectI", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipDrawImageRectRectI(
GpGraphics* graphics, // GpGraphics* in/out
GpImage* image, // GpImage* in/out
int dstx, // INT
int dsty, // INT
int dstwidth, // INT
int dstheight, // INT
int srcx, // INT
int srcy, // INT
int srcwidth, // INT
int srcheight, // INT
int srcUnit, // Unit
GpImageAttributes* imageAttributes, // GpImageAttributes*
ptrdiff_t callback, // INT_PTR
void* callbackData // void* in/out
);ccall((:GdipDrawImageRectRectI, "gdiplus.dll"), stdcall, Int32,
(Ptr{GpGraphics}, Ptr{GpImage}, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, 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 : INT -> Int32
# dsty : INT -> Int32
# dstwidth : INT -> Int32
# dstheight : INT -> Int32
# srcx : INT -> Int32
# srcy : INT -> Int32
# srcwidth : INT -> Int32
# srcheight : INT -> Int32
# 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 GdipDrawImageRectRectI(
void* graphics,
void* image,
int32_t dstx,
int32_t dsty,
int32_t dstwidth,
int32_t dstheight,
int32_t srcx,
int32_t srcy,
int32_t srcwidth,
int32_t srcheight,
int32_t srcUnit,
void* imageAttributes,
intptr_t callback,
void* callbackData);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipDrawImageRectRectI(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)
-- graphics : GpGraphics* in/out
-- image : GpImage* in/out
-- dstx : INT
-- dsty : INT
-- dstwidth : INT
-- dstheight : INT
-- srcx : INT
-- srcy : INT
-- srcwidth : INT
-- srcheight : INT
-- 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 GdipDrawImageRectRectI = lib.func('__stdcall', 'GdipDrawImageRectRectI', 'int32_t', ['void *', 'void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'void *', 'intptr_t', 'void *']);
// GdipDrawImageRectRectI(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 : INT -> 'int32_t'
// dsty : INT -> 'int32_t'
// dstwidth : INT -> 'int32_t'
// dstheight : INT -> 'int32_t'
// srcx : INT -> 'int32_t'
// srcy : INT -> 'int32_t'
// srcwidth : INT -> 'int32_t'
// srcheight : INT -> 'int32_t'
// 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", {
GdipDrawImageRectRectI: { parameters: ["pointer", "pointer", "i32", "i32", "i32", "i32", "i32", "i32", "i32", "i32", "i32", "pointer", "isize", "pointer"], result: "i32" },
});
// lib.symbols.GdipDrawImageRectRectI(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 : INT -> "i32"
// dsty : INT -> "i32"
// dstwidth : INT -> "i32"
// dstheight : INT -> "i32"
// srcx : INT -> "i32"
// srcy : INT -> "i32"
// srcwidth : INT -> "i32"
// srcheight : INT -> "i32"
// 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 GdipDrawImageRectRectI(
void* graphics,
void* image,
int32_t dstx,
int32_t dsty,
int32_t dstwidth,
int32_t dstheight,
int32_t srcx,
int32_t srcy,
int32_t srcwidth,
int32_t srcheight,
int32_t srcUnit,
void* imageAttributes,
intptr_t callback,
void* callbackData);
C, "gdiplus.dll");
// $ffi->GdipDrawImageRectRectI(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData);
// graphics : GpGraphics* in/out
// image : GpImage* in/out
// dstx : INT
// dsty : INT
// dstwidth : INT
// dstheight : INT
// srcx : INT
// srcy : INT
// srcwidth : INT
// srcheight : INT
// 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 GdipDrawImageRectRectI(
Pointer graphics, // GpGraphics* in/out
Pointer image, // GpImage* in/out
int dstx, // INT
int dsty, // INT
int dstwidth, // INT
int dstheight, // INT
int srcx, // INT
int srcy, // INT
int srcwidth, // INT
int srcheight, // INT
int srcUnit, // Unit
Pointer imageAttributes, // GpImageAttributes*
long callback, // INT_PTR
Pointer callbackData // void* in/out
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipDrawImageRectRectI = GdipDrawImageRectRectI(
graphics : GpGraphics*, # GpGraphics* in/out
image : GpImage*, # GpImage* in/out
dstx : Int32, # INT
dsty : Int32, # INT
dstwidth : Int32, # INT
dstheight : Int32, # INT
srcx : Int32, # INT
srcy : Int32, # INT
srcwidth : Int32, # INT
srcheight : Int32, # INT
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 GdipDrawImageRectRectINative = Int32 Function(Pointer<Void>, Pointer<Void>, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Pointer<Void>, IntPtr, Pointer<Void>);
typedef GdipDrawImageRectRectIDart = int Function(Pointer<Void>, Pointer<Void>, int, int, int, int, int, int, int, int, int, Pointer<Void>, int, Pointer<Void>);
final GdipDrawImageRectRectI = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipDrawImageRectRectINative, GdipDrawImageRectRectIDart>('GdipDrawImageRectRectI');
// graphics : GpGraphics* in/out -> Pointer<Void>
// image : GpImage* in/out -> Pointer<Void>
// dstx : INT -> Int32
// dsty : INT -> Int32
// dstwidth : INT -> Int32
// dstheight : INT -> Int32
// srcx : INT -> Int32
// srcy : INT -> Int32
// srcwidth : INT -> Int32
// srcheight : INT -> Int32
// 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 GdipDrawImageRectRectI(
graphics: Pointer; // GpGraphics* in/out
image: Pointer; // GpImage* in/out
dstx: Integer; // INT
dsty: Integer; // INT
dstwidth: Integer; // INT
dstheight: Integer; // INT
srcx: Integer; // INT
srcy: Integer; // INT
srcwidth: Integer; // INT
srcheight: Integer; // INT
srcUnit: Integer; // Unit
imageAttributes: Pointer; // GpImageAttributes*
callback: NativeInt; // INT_PTR
callbackData: Pointer // void* in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipDrawImageRectRectI';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipDrawImageRectRectI"
c_GdipDrawImageRectRectI :: Ptr () -> Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Ptr () -> CIntPtr -> Ptr () -> IO Int32
-- graphics : GpGraphics* in/out -> Ptr ()
-- image : GpImage* in/out -> Ptr ()
-- dstx : INT -> Int32
-- dsty : INT -> Int32
-- dstwidth : INT -> Int32
-- dstheight : INT -> Int32
-- srcx : INT -> Int32
-- srcy : INT -> Int32
-- srcwidth : INT -> Int32
-- srcheight : INT -> Int32
-- 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 gdipdrawimagerectrecti =
foreign "GdipDrawImageRectRectI"
((ptr void) @-> (ptr void) @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> intptr_t @-> (ptr void) @-> returning int32_t)
(* graphics : GpGraphics* in/out -> (ptr void) *)
(* image : GpImage* in/out -> (ptr void) *)
(* dstx : INT -> int32_t *)
(* dsty : INT -> int32_t *)
(* dstwidth : INT -> int32_t *)
(* dstheight : INT -> int32_t *)
(* srcx : INT -> int32_t *)
(* srcy : INT -> int32_t *)
(* srcwidth : INT -> int32_t *)
(* srcheight : INT -> int32_t *)
(* 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 ("GdipDrawImageRectRectI" gdip-draw-image-rect-rect-i :convention :stdcall) :int32
(graphics :pointer) ; GpGraphics* in/out
(image :pointer) ; GpImage* in/out
(dstx :int32) ; INT
(dsty :int32) ; INT
(dstwidth :int32) ; INT
(dstheight :int32) ; INT
(srcx :int32) ; INT
(srcy :int32) ; INT
(srcwidth :int32) ; INT
(srcheight :int32) ; INT
(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 $GdipDrawImageRectRectI = Win32::API::More->new('gdiplus',
'int GdipDrawImageRectRectI(LPVOID graphics, LPVOID image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, int srcUnit, LPVOID imageAttributes, LPARAM callback, LPVOID callbackData)');
# my $ret = $GdipDrawImageRectRectI->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 : INT -> int
# dsty : INT -> int
# dstwidth : INT -> int
# dstheight : INT -> int
# srcx : INT -> int
# srcy : INT -> int
# srcwidth : INT -> int
# srcheight : INT -> int
# srcUnit : Unit -> int
# imageAttributes : GpImageAttributes* -> LPVOID
# callback : INT_PTR -> LPARAM
# callbackData : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。