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

GdipDrawImageRectRect

関数
画像の元矩形を変換先矩形に属性付きで描画する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

// 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
);

パラメーター

名前方向
graphicsGpGraphics*inout
imageGpImage*inout
dstxFLOATin
dstyFLOATin
dstwidthFLOATin
dstheightFLOATin
srcxFLOATin
srcyFLOATin
srcwidthFLOATin
srcheightFLOATin
srcUnitUnitin
imageAttributesGpImageAttributes*in
callbackINT_PTRin
callbackDatavoid*inout

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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)。