StretchBlt
関数シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdcDest | HDC | in | 移動先デバイスコンテキストへのハンドル。 |
| xDest | INT | in | 移動先矩形の左上隅の x 座標(論理単位)。 |
| yDest | INT | in | 移動先矩形の左上隅の y 座標(論理単位)。 |
| wDest | INT | in | 移動先矩形の幅(論理単位)。 |
| hDest | INT | in | 移動先矩形の高さ(論理単位)。 |
| hdcSrc | HDC | inoptional | ソースデバイスコンテキストへのハンドル。 |
| xSrc | INT | in | ソース矩形の左上隅の x 座標(論理単位)。 |
| ySrc | INT | in | ソース矩形の左上隅の y 座標(論理単位)。 |
| wSrc | INT | in | ソース矩形の幅(論理単位)。 |
| hSrc | INT | in | ソース矩形の高さ(論理単位)。 |
| rop | ROP_CODE | in | 実行するラスタオペレーション。ラスタオペレーションコードは、ブラシ、ソースビットマップ、移動先ビットマップを伴う出力操作において、システムが色をどのように合成するかを定義します。 一般的なラスタオペレーションコード(ROP)の一覧については、BitBlt を参照してください。なお、CAPTUREBLT ROP は通常、印刷用デバイスコンテキストには使用できません。 |
戻り値の型: BOOL
公式ドキュメント
StretchBlt 関数は、ソース矩形からビットマップをコピーして移動先矩形に転送します。必要に応じて、移動先矩形の寸法に合わせてビットマップを拡大または圧縮します。
戻り値
関数が成功した場合、戻り値は 0 以外の値です。
関数が失敗した場合、戻り値は 0 です。
解説(Remarks)
StretchBlt は、メモリ内でソースビットマップを拡大または圧縮し、その結果を移動先矩形にコピーします。このビットマップは、互換ビットマップ(DDB)または CreateDIBSection の出力のいずれかです。パターンピクセルまたは移動先ピクセルの色データは、拡大または圧縮の後にマージされます。
拡張メタファイルの記録中に、ソースデバイスコンテキストが拡張メタファイルデバイスコンテキストを示している場合、エラーが発生します(関数は FALSE を返します)。
指定されたラスタオペレーションがブラシを必要とする場合、システムは移動先デバイスコンテキストに現在選択されているブラシを使用します。
移動先座標は移動先デバイスコンテキストに現在指定されている変換を使用して変換され、ソース座標はソースデバイスコンテキストに現在指定されている変換を使用して変換されます。
ソースの変換に回転またはせん断が含まれている場合、エラーが発生します。
移動先ビットマップ、ソースビットマップ、パターンビットマップが同じ色形式でない場合、StretchBlt はソースビットマップとパターンビットマップを移動先ビットマップに合わせて変換します。
StretchBlt がモノクロビットマップをカラービットマップに変換する必要がある場合、白のビット(1)を背景色に、黒のビット(0)を前景色に設定します。カラービットマップをモノクロビットマップに変換する場合は、背景色に一致するピクセルを白(1)に、その他のすべてのピクセルを黒(0)に設定します。色付きデバイスコンテキストの前景色と背景色が使用されます。
StretchBlt は、nWidthSrc と nWidthDest パラメーターの符号、または nHeightSrc と nHeightDest パラメーターの符号が異なる場合に、ビットマップの鏡像を作成します。nWidthSrc と nWidthDest の符号が異なる場合、関数は x 軸に沿ってビットマップの鏡像を作成します。nHeightSrc と nHeightDest の符号が異なる場合、関数は y 軸に沿ってビットマップの鏡像を作成します。
すべてのデバイスが StretchBlt 関数をサポートしているわけではありません。詳細については、GetDeviceCaps を参照してください。
ICM: ブリット操作の際に色管理は行われません。
マルチモニターシステムで使用する場合、hdcSrc と hdcDest は同じデバイスを参照する必要があり、そうでない場合、関数は失敗します。異なるデバイスの DC 間でデータを転送するには、GetDIBits を呼び出してメモリビットマップを DIB に変換します。DIB を 2 番目のデバイスに表示するには、SetDIBits または StretchDIBits を呼び出します。
例
例については、Scaling an Image を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "gdi32" fn StretchBlt(
hdcDest: ?*anyopaque, // HDC
xDest: i32, // INT
yDest: i32, // INT
wDest: i32, // INT
hDest: i32, // INT
hdcSrc: ?*anyopaque, // HDC optional
xSrc: i32, // INT
ySrc: i32, // INT
wSrc: i32, // INT
hSrc: i32, // INT
rop: u32 // ROP_CODE
) callconv(std.os.windows.WINAPI) i32;proc StretchBlt(
hdcDest: pointer, # HDC
xDest: int32, # INT
yDest: int32, # INT
wDest: int32, # INT
hDest: int32, # INT
hdcSrc: pointer, # HDC optional
xSrc: int32, # INT
ySrc: int32, # INT
wSrc: int32, # INT
hSrc: int32, # INT
rop: uint32 # ROP_CODE
): int32 {.importc: "StretchBlt", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
int StretchBlt(
void* hdcDest, // HDC
int xDest, // INT
int yDest, // INT
int wDest, // INT
int hDest, // INT
void* hdcSrc, // HDC optional
int xSrc, // INT
int ySrc, // INT
int wSrc, // INT
int hSrc, // INT
uint rop // ROP_CODE
);ccall((:StretchBlt, "GDI32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Int32, Int32, Int32, Ptr{Cvoid}, Int32, Int32, Int32, Int32, UInt32),
hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop)
# hdcDest : HDC -> Ptr{Cvoid}
# xDest : INT -> Int32
# yDest : INT -> Int32
# wDest : INT -> Int32
# hDest : INT -> Int32
# hdcSrc : HDC optional -> Ptr{Cvoid}
# xSrc : INT -> Int32
# ySrc : INT -> Int32
# wSrc : INT -> Int32
# hSrc : INT -> Int32
# rop : ROP_CODE -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t StretchBlt(
void* hdcDest,
int32_t xDest,
int32_t yDest,
int32_t wDest,
int32_t hDest,
void* hdcSrc,
int32_t xSrc,
int32_t ySrc,
int32_t wSrc,
int32_t hSrc,
uint32_t rop);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop)
-- hdcDest : HDC
-- xDest : INT
-- yDest : INT
-- wDest : INT
-- hDest : INT
-- hdcSrc : HDC optional
-- xSrc : INT
-- ySrc : INT
-- wSrc : INT
-- hSrc : INT
-- rop : ROP_CODE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const StretchBlt = lib.func('__stdcall', 'StretchBlt', 'int32_t', ['void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'uint32_t']);
// StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop)
// hdcDest : HDC -> 'void *'
// xDest : INT -> 'int32_t'
// yDest : INT -> 'int32_t'
// wDest : INT -> 'int32_t'
// hDest : INT -> 'int32_t'
// hdcSrc : HDC optional -> 'void *'
// xSrc : INT -> 'int32_t'
// ySrc : INT -> 'int32_t'
// wSrc : INT -> 'int32_t'
// hSrc : INT -> 'int32_t'
// rop : ROP_CODE -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GDI32.dll", {
StretchBlt: { parameters: ["pointer", "i32", "i32", "i32", "i32", "pointer", "i32", "i32", "i32", "i32", "u32"], result: "i32" },
});
// lib.symbols.StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop)
// hdcDest : HDC -> "pointer"
// xDest : INT -> "i32"
// yDest : INT -> "i32"
// wDest : INT -> "i32"
// hDest : INT -> "i32"
// hdcSrc : HDC optional -> "pointer"
// xSrc : INT -> "i32"
// ySrc : INT -> "i32"
// wSrc : INT -> "i32"
// hSrc : INT -> "i32"
// rop : ROP_CODE -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t StretchBlt(
void* hdcDest,
int32_t xDest,
int32_t yDest,
int32_t wDest,
int32_t hDest,
void* hdcSrc,
int32_t xSrc,
int32_t ySrc,
int32_t wSrc,
int32_t hSrc,
uint32_t rop);
C, "GDI32.dll");
// $ffi->StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop);
// hdcDest : HDC
// xDest : INT
// yDest : INT
// wDest : INT
// hDest : INT
// hdcSrc : HDC optional
// xSrc : INT
// ySrc : INT
// wSrc : INT
// hSrc : INT
// rop : ROP_CODE
// 構造体/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 Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
boolean StretchBlt(
Pointer hdcDest, // HDC
int xDest, // INT
int yDest, // INT
int wDest, // INT
int hDest, // INT
Pointer hdcSrc, // HDC optional
int xSrc, // INT
int ySrc, // INT
int wSrc, // INT
int hSrc, // INT
int rop // ROP_CODE
);
}@[Link("gdi32")]
lib LibGDI32
fun StretchBlt = StretchBlt(
hdcDest : Void*, # HDC
xDest : Int32, # INT
yDest : Int32, # INT
wDest : Int32, # INT
hDest : Int32, # INT
hdcSrc : Void*, # HDC optional
xSrc : Int32, # INT
ySrc : Int32, # INT
wSrc : Int32, # INT
hSrc : Int32, # INT
rop : UInt32 # ROP_CODE
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef StretchBltNative = Int32 Function(Pointer<Void>, Int32, Int32, Int32, Int32, Pointer<Void>, Int32, Int32, Int32, Int32, Uint32);
typedef StretchBltDart = int Function(Pointer<Void>, int, int, int, int, Pointer<Void>, int, int, int, int, int);
final StretchBlt = DynamicLibrary.open('GDI32.dll')
.lookupFunction<StretchBltNative, StretchBltDart>('StretchBlt');
// hdcDest : HDC -> Pointer<Void>
// xDest : INT -> Int32
// yDest : INT -> Int32
// wDest : INT -> Int32
// hDest : INT -> Int32
// hdcSrc : HDC optional -> Pointer<Void>
// xSrc : INT -> Int32
// ySrc : INT -> Int32
// wSrc : INT -> Int32
// hSrc : INT -> Int32
// rop : ROP_CODE -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "StretchBlt"
c_StretchBlt :: Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Word32 -> IO CInt
-- hdcDest : HDC -> Ptr ()
-- xDest : INT -> Int32
-- yDest : INT -> Int32
-- wDest : INT -> Int32
-- hDest : INT -> Int32
-- hdcSrc : HDC optional -> Ptr ()
-- xSrc : INT -> Int32
-- ySrc : INT -> Int32
-- wSrc : INT -> Int32
-- hSrc : INT -> Int32
-- rop : ROP_CODE -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let stretchblt =
foreign "StretchBlt"
((ptr void) @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> uint32_t @-> returning int32_t)
(* hdcDest : HDC -> (ptr void) *)
(* xDest : INT -> int32_t *)
(* yDest : INT -> int32_t *)
(* wDest : INT -> int32_t *)
(* hDest : INT -> int32_t *)
(* hdcSrc : HDC optional -> (ptr void) *)
(* xSrc : INT -> int32_t *)
(* ySrc : INT -> int32_t *)
(* wSrc : INT -> int32_t *)
(* hSrc : INT -> int32_t *)
(* rop : ROP_CODE -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("StretchBlt" stretch-blt :convention :stdcall) :int32
(hdc-dest :pointer) ; HDC
(x-dest :int32) ; INT
(y-dest :int32) ; INT
(w-dest :int32) ; INT
(h-dest :int32) ; INT
(hdc-src :pointer) ; HDC optional
(x-src :int32) ; INT
(y-src :int32) ; INT
(w-src :int32) ; INT
(h-src :int32) ; INT
(rop :uint32)) ; ROP_CODE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $StretchBlt = Win32::API::More->new('GDI32',
'BOOL StretchBlt(HANDLE hdcDest, int xDest, int yDest, int wDest, int hDest, HANDLE hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop)');
# my $ret = $StretchBlt->Call($hdcDest, $xDest, $yDest, $wDest, $hDest, $hdcSrc, $xSrc, $ySrc, $wSrc, $hSrc, $rop);
# hdcDest : HDC -> HANDLE
# xDest : INT -> int
# yDest : INT -> int
# wDest : INT -> int
# hDest : INT -> int
# hdcSrc : HDC optional -> HANDLE
# xSrc : INT -> int
# ySrc : INT -> int
# wSrc : INT -> int
# hSrc : INT -> int
# rop : ROP_CODE -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f BitBlt — デバイスコンテキスト間でビットマップのブロック転送を行う。
- f CreateDIBSection — アプリが直接アクセス可能なメモリを持つDIBセクションを作成する。
- f GetDIBits — ビットマップのビットをDIB形式で取得する。
- f GetDeviceCaps — デバイスの能力や属性情報を取得する。
- f MaskBlt — マスクを用いてビットマップを合成転送する。
- f PlgBlt — 平行四辺形領域へビットマップを転送する。
- f SetDIBits — DIBのビットでビットマップのピクセルを設定する。
- f SetStretchBltMode — ビットマップ伸縮時のラスタ補間モードを設定する。
- f StretchDIBits — DIBのピクセルを伸縮して転送先矩形へ転送する。