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

StretchBlt

関数
ソース矩形を伸縮しながら転送先矩形へビット転送する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll
#include <windows.h>

BOOL StretchBlt(
    HDC hdcDest,
    INT xDest,
    INT yDest,
    INT wDest,
    INT hDest,
    HDC hdcSrc,   // optional
    INT xSrc,
    INT ySrc,
    INT wSrc,
    INT hSrc,
    ROP_CODE rop
);

パラメーター

名前方向
hdcDestHDCin
xDestINTin
yDestINTin
wDestINTin
hDestINTin
hdcSrcHDCinoptional
xSrcINTin
ySrcINTin
wSrcINTin
hSrcINTin
ropROP_CODEin

戻り値の型: BOOL

各言語での呼び出し定義

// GDI32.dll
#include <windows.h>

BOOL StretchBlt(
    HDC hdcDest,
    INT xDest,
    INT yDest,
    INT wDest,
    INT hDest,
    HDC hdcSrc,   // optional
    INT xSrc,
    INT ySrc,
    INT wSrc,
    INT hSrc,
    ROP_CODE rop
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool StretchBlt(
    IntPtr hdcDest,   // HDC
    int xDest,   // INT
    int yDest,   // INT
    int wDest,   // INT
    int hDest,   // INT
    IntPtr hdcSrc,   // HDC optional
    int xSrc,   // INT
    int ySrc,   // INT
    int wSrc,   // INT
    int hSrc,   // INT
    uint rop   // ROP_CODE
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function StretchBlt(
    hdcDest As IntPtr,   ' HDC
    xDest As Integer,   ' INT
    yDest As Integer,   ' INT
    wDest As Integer,   ' INT
    hDest As Integer,   ' INT
    hdcSrc As IntPtr,   ' HDC optional
    xSrc As Integer,   ' INT
    ySrc As Integer,   ' INT
    wSrc As Integer,   ' INT
    hSrc As Integer,   ' INT
    rop As UInteger   ' ROP_CODE
) As Boolean
End Function
' hdcDest : HDC
' xDest : INT
' yDest : INT
' wDest : INT
' hDest : INT
' hdcSrc : HDC optional
' xSrc : INT
' ySrc : INT
' wSrc : INT
' hSrc : INT
' rop : ROP_CODE
Declare PtrSafe Function StretchBlt Lib "gdi32" ( _
    ByVal hdcDest As LongPtr, _
    ByVal xDest As Long, _
    ByVal yDest As Long, _
    ByVal wDest As Long, _
    ByVal hDest As Long, _
    ByVal hdcSrc As LongPtr, _
    ByVal xSrc As Long, _
    ByVal ySrc As Long, _
    ByVal wSrc As Long, _
    ByVal hSrc As Long, _
    ByVal rop As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

StretchBlt = ctypes.windll.gdi32.StretchBlt
StretchBlt.restype = wintypes.BOOL
StretchBlt.argtypes = [
    wintypes.HANDLE,  # hdcDest : HDC
    ctypes.c_int,  # xDest : INT
    ctypes.c_int,  # yDest : INT
    ctypes.c_int,  # wDest : INT
    ctypes.c_int,  # hDest : INT
    wintypes.HANDLE,  # hdcSrc : HDC optional
    ctypes.c_int,  # xSrc : INT
    ctypes.c_int,  # ySrc : INT
    ctypes.c_int,  # wSrc : INT
    ctypes.c_int,  # hSrc : INT
    wintypes.DWORD,  # rop : ROP_CODE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
StretchBlt = Fiddle::Function.new(
  lib['StretchBlt'],
  [
    Fiddle::TYPE_VOIDP,  # hdcDest : HDC
    Fiddle::TYPE_INT,  # xDest : INT
    Fiddle::TYPE_INT,  # yDest : INT
    Fiddle::TYPE_INT,  # wDest : INT
    Fiddle::TYPE_INT,  # hDest : INT
    Fiddle::TYPE_VOIDP,  # hdcSrc : HDC optional
    Fiddle::TYPE_INT,  # xSrc : INT
    Fiddle::TYPE_INT,  # ySrc : INT
    Fiddle::TYPE_INT,  # wSrc : INT
    Fiddle::TYPE_INT,  # hSrc : INT
    -Fiddle::TYPE_INT,  # rop : ROP_CODE
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn StretchBlt(
        hdcDest: *mut core::ffi::c_void,  // HDC
        xDest: i32,  // INT
        yDest: i32,  // INT
        wDest: i32,  // INT
        hDest: i32,  // INT
        hdcSrc: *mut core::ffi::c_void,  // HDC optional
        xSrc: i32,  // INT
        ySrc: i32,  // INT
        wSrc: i32,  // INT
        hSrc: i32,  // INT
        rop: u32  // ROP_CODE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool StretchBlt(IntPtr hdcDest, int xDest, int yDest, int wDest, int hDest, IntPtr hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, uint rop);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_StretchBlt' -Namespace Win32 -PassThru
# $api::StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop)
#uselib "GDI32.dll"
#func global StretchBlt "StretchBlt" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; StretchBlt hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop   ; 戻り値は stat
; hdcDest : HDC -> "sptr"
; xDest : INT -> "sptr"
; yDest : INT -> "sptr"
; wDest : INT -> "sptr"
; hDest : INT -> "sptr"
; hdcSrc : HDC optional -> "sptr"
; xSrc : INT -> "sptr"
; ySrc : INT -> "sptr"
; wSrc : INT -> "sptr"
; hSrc : INT -> "sptr"
; rop : ROP_CODE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global StretchBlt "StretchBlt" sptr, int, int, int, int, sptr, int, int, int, int, int
; res = StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop)
; hdcDest : HDC -> "sptr"
; xDest : INT -> "int"
; yDest : INT -> "int"
; wDest : INT -> "int"
; hDest : INT -> "int"
; hdcSrc : HDC optional -> "sptr"
; xSrc : INT -> "int"
; ySrc : INT -> "int"
; wSrc : INT -> "int"
; hSrc : INT -> "int"
; rop : ROP_CODE -> "int"
; BOOL StretchBlt(HDC hdcDest, INT xDest, INT yDest, INT wDest, INT hDest, HDC hdcSrc, INT xSrc, INT ySrc, INT wSrc, INT hSrc, ROP_CODE rop)
#uselib "GDI32.dll"
#cfunc global StretchBlt "StretchBlt" intptr, int, int, int, int, intptr, int, int, int, int, int
; res = StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop)
; hdcDest : HDC -> "intptr"
; xDest : INT -> "int"
; yDest : INT -> "int"
; wDest : INT -> "int"
; hDest : INT -> "int"
; hdcSrc : HDC optional -> "intptr"
; xSrc : INT -> "int"
; ySrc : INT -> "int"
; wSrc : INT -> "int"
; hSrc : INT -> "int"
; rop : ROP_CODE -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procStretchBlt = gdi32.NewProc("StretchBlt")
)

// hdcDest (HDC), xDest (INT), yDest (INT), wDest (INT), hDest (INT), hdcSrc (HDC optional), xSrc (INT), ySrc (INT), wSrc (INT), hSrc (INT), rop (ROP_CODE)
r1, _, err := procStretchBlt.Call(
	uintptr(hdcDest),
	uintptr(xDest),
	uintptr(yDest),
	uintptr(wDest),
	uintptr(hDest),
	uintptr(hdcSrc),
	uintptr(xSrc),
	uintptr(ySrc),
	uintptr(wSrc),
	uintptr(hSrc),
	uintptr(rop),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function StretchBlt(
  hdcDest: THandle;   // HDC
  xDest: Integer;   // INT
  yDest: Integer;   // INT
  wDest: Integer;   // INT
  hDest: Integer;   // INT
  hdcSrc: THandle;   // HDC optional
  xSrc: Integer;   // INT
  ySrc: Integer;   // INT
  wSrc: Integer;   // INT
  hSrc: Integer;   // INT
  rop: DWORD   // ROP_CODE
): BOOL; stdcall;
  external 'GDI32.dll' name 'StretchBlt';
result := DllCall("GDI32\StretchBlt"
    , "Ptr", hdcDest   ; HDC
    , "Int", xDest   ; INT
    , "Int", yDest   ; INT
    , "Int", wDest   ; INT
    , "Int", hDest   ; INT
    , "Ptr", hdcSrc   ; HDC optional
    , "Int", xSrc   ; INT
    , "Int", ySrc   ; INT
    , "Int", wSrc   ; INT
    , "Int", hSrc   ; INT
    , "UInt", rop   ; ROP_CODE
    , "Int")   ; return: BOOL
●StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop) = DLL("GDI32.dll", "bool StretchBlt(void*, int, int, int, int, void*, int, int, int, int, dword)")
# 呼び出し: StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop)
# hdcDest : HDC -> "void*"
# xDest : INT -> "int"
# yDest : INT -> "int"
# wDest : INT -> "int"
# hDest : INT -> "int"
# hdcSrc : HDC optional -> "void*"
# xSrc : INT -> "int"
# ySrc : INT -> "int"
# wSrc : INT -> "int"
# hSrc : INT -> "int"
# rop : ROP_CODE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。