TransparentBlt
関数シグネチャ
// MSIMG32.dll
#include <windows.h>
BOOL TransparentBlt(
HDC hdcDest,
INT xoriginDest,
INT yoriginDest,
INT wDest,
INT hDest,
HDC hdcSrc,
INT xoriginSrc,
INT yoriginSrc,
INT wSrc,
INT hSrc,
DWORD crTransparent
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdcDest | HDC | in | コピー先デバイスコンテキストへのハンドル。 |
| xoriginDest | INT | in | コピー先矩形の左上隅の x 座標(論理単位)。 |
| yoriginDest | INT | in | コピー先矩形の左上隅の y 座標(論理単位)。 |
| wDest | INT | in | コピー先矩形の幅(論理単位)。 |
| hDest | INT | in | コピー先矩形の高さ(論理単位)。 |
| hdcSrc | HDC | in | ソースデバイスコンテキストへのハンドル。 |
| xoriginSrc | INT | in | ソース矩形の x 座標(論理単位)。 |
| yoriginSrc | INT | in | ソース矩形の y 座標(論理単位)。 |
| wSrc | INT | in | ソース矩形の幅(論理単位)。 |
| hSrc | INT | in | ソース矩形の高さ(論理単位)。 |
| crTransparent | DWORD | in | ソースビットマップ内で透明として扱う RGB 色。 |
戻り値の型: BOOL
公式ドキュメント
TransparentBlt 関数は、指定したソースデバイスコンテキストから、ピクセルの矩形に対応する色データのビットブロック転送を、コピー先デバイスコンテキストへ実行します。
戻り値
関数が成功した場合、戻り値は TRUE です。
関数が失敗した場合、戻り値は FALSE です。
解説(Remarks)
TransparentBlt 関数は、互換ビットマップ(DDB)を扱います。
TransparentBlt 関数は、すべての形式のソースビットマップをサポートします。ただし、32 bpp のビットマップの場合は、アルファ値をそのままコピーするだけです。透明度を持つ 32 ビット/ピクセルのビットマップを指定するには、AlphaBlend を使用してください。
ソース矩形とコピー先矩形のサイズが異なる場合、ソースビットマップはコピー先矩形に合わせて拡大されます。SetStretchBltMode 関数が使用されている場合、iStretchMode モードの BLACKONWHITE および WHITEONBLACK は、TransparentBlt 関数に対して COLORONCOLOR に変換されます。
コピー先デバイスコンテキストは、コピー先座標の変換タイプを指定します。ソースデバイスコンテキストは、ソース座標の変換タイプを指定します。
TransparentBlt は、ソースまたはコピー先のいずれかの幅または高さが負の場合でも、ビットマップを反転しません。
マルチモニターシステムで使用する場合、hdcSrc と hdcDest は同じデバイスを参照している必要があり、そうでない場合は関数が失敗します。異なるデバイスの DC 間でデータを転送するには、GetDIBits を呼び出してメモリビットマップを DIB に変換します。その DIB を 2 番目のデバイスに表示するには、SetDIBits または StretchDIBits を呼び出します。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MSIMG32.dll
#include <windows.h>
BOOL TransparentBlt(
HDC hdcDest,
INT xoriginDest,
INT yoriginDest,
INT wDest,
INT hDest,
HDC hdcSrc,
INT xoriginSrc,
INT yoriginSrc,
INT wSrc,
INT hSrc,
DWORD crTransparent
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSIMG32.dll", ExactSpelling = true)]
static extern bool TransparentBlt(
IntPtr hdcDest, // HDC
int xoriginDest, // INT
int yoriginDest, // INT
int wDest, // INT
int hDest, // INT
IntPtr hdcSrc, // HDC
int xoriginSrc, // INT
int yoriginSrc, // INT
int wSrc, // INT
int hSrc, // INT
uint crTransparent // DWORD
);<DllImport("MSIMG32.dll", ExactSpelling:=True)>
Public Shared Function TransparentBlt(
hdcDest As IntPtr, ' HDC
xoriginDest As Integer, ' INT
yoriginDest As Integer, ' INT
wDest As Integer, ' INT
hDest As Integer, ' INT
hdcSrc As IntPtr, ' HDC
xoriginSrc As Integer, ' INT
yoriginSrc As Integer, ' INT
wSrc As Integer, ' INT
hSrc As Integer, ' INT
crTransparent As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hdcDest : HDC
' xoriginDest : INT
' yoriginDest : INT
' wDest : INT
' hDest : INT
' hdcSrc : HDC
' xoriginSrc : INT
' yoriginSrc : INT
' wSrc : INT
' hSrc : INT
' crTransparent : DWORD
Declare PtrSafe Function TransparentBlt Lib "msimg32" ( _
ByVal hdcDest As LongPtr, _
ByVal xoriginDest As Long, _
ByVal yoriginDest As Long, _
ByVal wDest As Long, _
ByVal hDest As Long, _
ByVal hdcSrc As LongPtr, _
ByVal xoriginSrc As Long, _
ByVal yoriginSrc As Long, _
ByVal wSrc As Long, _
ByVal hSrc As Long, _
ByVal crTransparent As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TransparentBlt = ctypes.windll.msimg32.TransparentBlt
TransparentBlt.restype = wintypes.BOOL
TransparentBlt.argtypes = [
wintypes.HANDLE, # hdcDest : HDC
ctypes.c_int, # xoriginDest : INT
ctypes.c_int, # yoriginDest : INT
ctypes.c_int, # wDest : INT
ctypes.c_int, # hDest : INT
wintypes.HANDLE, # hdcSrc : HDC
ctypes.c_int, # xoriginSrc : INT
ctypes.c_int, # yoriginSrc : INT
ctypes.c_int, # wSrc : INT
ctypes.c_int, # hSrc : INT
wintypes.DWORD, # crTransparent : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSIMG32.dll')
TransparentBlt = Fiddle::Function.new(
lib['TransparentBlt'],
[
Fiddle::TYPE_VOIDP, # hdcDest : HDC
Fiddle::TYPE_INT, # xoriginDest : INT
Fiddle::TYPE_INT, # yoriginDest : INT
Fiddle::TYPE_INT, # wDest : INT
Fiddle::TYPE_INT, # hDest : INT
Fiddle::TYPE_VOIDP, # hdcSrc : HDC
Fiddle::TYPE_INT, # xoriginSrc : INT
Fiddle::TYPE_INT, # yoriginSrc : INT
Fiddle::TYPE_INT, # wSrc : INT
Fiddle::TYPE_INT, # hSrc : INT
-Fiddle::TYPE_INT, # crTransparent : DWORD
],
Fiddle::TYPE_INT)#[link(name = "msimg32")]
extern "system" {
fn TransparentBlt(
hdcDest: *mut core::ffi::c_void, // HDC
xoriginDest: i32, // INT
yoriginDest: i32, // INT
wDest: i32, // INT
hDest: i32, // INT
hdcSrc: *mut core::ffi::c_void, // HDC
xoriginSrc: i32, // INT
yoriginSrc: i32, // INT
wSrc: i32, // INT
hSrc: i32, // INT
crTransparent: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSIMG32.dll")]
public static extern bool TransparentBlt(IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, uint crTransparent);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSIMG32_TransparentBlt' -Namespace Win32 -PassThru
# $api::TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)#uselib "MSIMG32.dll"
#func global TransparentBlt "TransparentBlt" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; TransparentBlt hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent ; 戻り値は stat
; hdcDest : HDC -> "sptr"
; xoriginDest : INT -> "sptr"
; yoriginDest : INT -> "sptr"
; wDest : INT -> "sptr"
; hDest : INT -> "sptr"
; hdcSrc : HDC -> "sptr"
; xoriginSrc : INT -> "sptr"
; yoriginSrc : INT -> "sptr"
; wSrc : INT -> "sptr"
; hSrc : INT -> "sptr"
; crTransparent : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MSIMG32.dll"
#cfunc global TransparentBlt "TransparentBlt" sptr, int, int, int, int, sptr, int, int, int, int, int
; res = TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)
; hdcDest : HDC -> "sptr"
; xoriginDest : INT -> "int"
; yoriginDest : INT -> "int"
; wDest : INT -> "int"
; hDest : INT -> "int"
; hdcSrc : HDC -> "sptr"
; xoriginSrc : INT -> "int"
; yoriginSrc : INT -> "int"
; wSrc : INT -> "int"
; hSrc : INT -> "int"
; crTransparent : DWORD -> "int"; BOOL TransparentBlt(HDC hdcDest, INT xoriginDest, INT yoriginDest, INT wDest, INT hDest, HDC hdcSrc, INT xoriginSrc, INT yoriginSrc, INT wSrc, INT hSrc, DWORD crTransparent)
#uselib "MSIMG32.dll"
#cfunc global TransparentBlt "TransparentBlt" intptr, int, int, int, int, intptr, int, int, int, int, int
; res = TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)
; hdcDest : HDC -> "intptr"
; xoriginDest : INT -> "int"
; yoriginDest : INT -> "int"
; wDest : INT -> "int"
; hDest : INT -> "int"
; hdcSrc : HDC -> "intptr"
; xoriginSrc : INT -> "int"
; yoriginSrc : INT -> "int"
; wSrc : INT -> "int"
; hSrc : INT -> "int"
; crTransparent : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msimg32 = windows.NewLazySystemDLL("MSIMG32.dll")
procTransparentBlt = msimg32.NewProc("TransparentBlt")
)
// hdcDest (HDC), xoriginDest (INT), yoriginDest (INT), wDest (INT), hDest (INT), hdcSrc (HDC), xoriginSrc (INT), yoriginSrc (INT), wSrc (INT), hSrc (INT), crTransparent (DWORD)
r1, _, err := procTransparentBlt.Call(
uintptr(hdcDest),
uintptr(xoriginDest),
uintptr(yoriginDest),
uintptr(wDest),
uintptr(hDest),
uintptr(hdcSrc),
uintptr(xoriginSrc),
uintptr(yoriginSrc),
uintptr(wSrc),
uintptr(hSrc),
uintptr(crTransparent),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction TransparentBlt(
hdcDest: THandle; // HDC
xoriginDest: Integer; // INT
yoriginDest: Integer; // INT
wDest: Integer; // INT
hDest: Integer; // INT
hdcSrc: THandle; // HDC
xoriginSrc: Integer; // INT
yoriginSrc: Integer; // INT
wSrc: Integer; // INT
hSrc: Integer; // INT
crTransparent: DWORD // DWORD
): BOOL; stdcall;
external 'MSIMG32.dll' name 'TransparentBlt';result := DllCall("MSIMG32\TransparentBlt"
, "Ptr", hdcDest ; HDC
, "Int", xoriginDest ; INT
, "Int", yoriginDest ; INT
, "Int", wDest ; INT
, "Int", hDest ; INT
, "Ptr", hdcSrc ; HDC
, "Int", xoriginSrc ; INT
, "Int", yoriginSrc ; INT
, "Int", wSrc ; INT
, "Int", hSrc ; INT
, "UInt", crTransparent ; DWORD
, "Int") ; return: BOOL●TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent) = DLL("MSIMG32.dll", "bool TransparentBlt(void*, int, int, int, int, void*, int, int, int, int, dword)")
# 呼び出し: TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)
# hdcDest : HDC -> "void*"
# xoriginDest : INT -> "int"
# yoriginDest : INT -> "int"
# wDest : INT -> "int"
# hDest : INT -> "int"
# hdcSrc : HDC -> "void*"
# xoriginSrc : INT -> "int"
# yoriginSrc : INT -> "int"
# wSrc : INT -> "int"
# hSrc : INT -> "int"
# crTransparent : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msimg32" fn TransparentBlt(
hdcDest: ?*anyopaque, // HDC
xoriginDest: i32, // INT
yoriginDest: i32, // INT
wDest: i32, // INT
hDest: i32, // INT
hdcSrc: ?*anyopaque, // HDC
xoriginSrc: i32, // INT
yoriginSrc: i32, // INT
wSrc: i32, // INT
hSrc: i32, // INT
crTransparent: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc TransparentBlt(
hdcDest: pointer, # HDC
xoriginDest: int32, # INT
yoriginDest: int32, # INT
wDest: int32, # INT
hDest: int32, # INT
hdcSrc: pointer, # HDC
xoriginSrc: int32, # INT
yoriginSrc: int32, # INT
wSrc: int32, # INT
hSrc: int32, # INT
crTransparent: uint32 # DWORD
): int32 {.importc: "TransparentBlt", stdcall, dynlib: "MSIMG32.dll".}pragma(lib, "msimg32");
extern(Windows)
int TransparentBlt(
void* hdcDest, // HDC
int xoriginDest, // INT
int yoriginDest, // INT
int wDest, // INT
int hDest, // INT
void* hdcSrc, // HDC
int xoriginSrc, // INT
int yoriginSrc, // INT
int wSrc, // INT
int hSrc, // INT
uint crTransparent // DWORD
);ccall((:TransparentBlt, "MSIMG32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Int32, Int32, Int32, Ptr{Cvoid}, Int32, Int32, Int32, Int32, UInt32),
hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)
# hdcDest : HDC -> Ptr{Cvoid}
# xoriginDest : INT -> Int32
# yoriginDest : INT -> Int32
# wDest : INT -> Int32
# hDest : INT -> Int32
# hdcSrc : HDC -> Ptr{Cvoid}
# xoriginSrc : INT -> Int32
# yoriginSrc : INT -> Int32
# wSrc : INT -> Int32
# hSrc : INT -> Int32
# crTransparent : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t TransparentBlt(
void* hdcDest,
int32_t xoriginDest,
int32_t yoriginDest,
int32_t wDest,
int32_t hDest,
void* hdcSrc,
int32_t xoriginSrc,
int32_t yoriginSrc,
int32_t wSrc,
int32_t hSrc,
uint32_t crTransparent);
]]
local msimg32 = ffi.load("msimg32")
-- msimg32.TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)
-- hdcDest : HDC
-- xoriginDest : INT
-- yoriginDest : INT
-- wDest : INT
-- hDest : INT
-- hdcSrc : HDC
-- xoriginSrc : INT
-- yoriginSrc : INT
-- wSrc : INT
-- hSrc : INT
-- crTransparent : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MSIMG32.dll');
const TransparentBlt = lib.func('__stdcall', 'TransparentBlt', 'int32_t', ['void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'uint32_t']);
// TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)
// hdcDest : HDC -> 'void *'
// xoriginDest : INT -> 'int32_t'
// yoriginDest : INT -> 'int32_t'
// wDest : INT -> 'int32_t'
// hDest : INT -> 'int32_t'
// hdcSrc : HDC -> 'void *'
// xoriginSrc : INT -> 'int32_t'
// yoriginSrc : INT -> 'int32_t'
// wSrc : INT -> 'int32_t'
// hSrc : INT -> 'int32_t'
// crTransparent : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSIMG32.dll", {
TransparentBlt: { parameters: ["pointer", "i32", "i32", "i32", "i32", "pointer", "i32", "i32", "i32", "i32", "u32"], result: "i32" },
});
// lib.symbols.TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)
// hdcDest : HDC -> "pointer"
// xoriginDest : INT -> "i32"
// yoriginDest : INT -> "i32"
// wDest : INT -> "i32"
// hDest : INT -> "i32"
// hdcSrc : HDC -> "pointer"
// xoriginSrc : INT -> "i32"
// yoriginSrc : INT -> "i32"
// wSrc : INT -> "i32"
// hSrc : INT -> "i32"
// crTransparent : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t TransparentBlt(
void* hdcDest,
int32_t xoriginDest,
int32_t yoriginDest,
int32_t wDest,
int32_t hDest,
void* hdcSrc,
int32_t xoriginSrc,
int32_t yoriginSrc,
int32_t wSrc,
int32_t hSrc,
uint32_t crTransparent);
C, "MSIMG32.dll");
// $ffi->TransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent);
// hdcDest : HDC
// xoriginDest : INT
// yoriginDest : INT
// wDest : INT
// hDest : INT
// hdcSrc : HDC
// xoriginSrc : INT
// yoriginSrc : INT
// wSrc : INT
// hSrc : INT
// crTransparent : DWORD
// 構造体/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 Msimg32 extends StdCallLibrary {
Msimg32 INSTANCE = Native.load("msimg32", Msimg32.class);
boolean TransparentBlt(
Pointer hdcDest, // HDC
int xoriginDest, // INT
int yoriginDest, // INT
int wDest, // INT
int hDest, // INT
Pointer hdcSrc, // HDC
int xoriginSrc, // INT
int yoriginSrc, // INT
int wSrc, // INT
int hSrc, // INT
int crTransparent // DWORD
);
}@[Link("msimg32")]
lib LibMSIMG32
fun TransparentBlt = TransparentBlt(
hdcDest : Void*, # HDC
xoriginDest : Int32, # INT
yoriginDest : Int32, # INT
wDest : Int32, # INT
hDest : Int32, # INT
hdcSrc : Void*, # HDC
xoriginSrc : Int32, # INT
yoriginSrc : Int32, # INT
wSrc : Int32, # INT
hSrc : Int32, # INT
crTransparent : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef TransparentBltNative = Int32 Function(Pointer<Void>, Int32, Int32, Int32, Int32, Pointer<Void>, Int32, Int32, Int32, Int32, Uint32);
typedef TransparentBltDart = int Function(Pointer<Void>, int, int, int, int, Pointer<Void>, int, int, int, int, int);
final TransparentBlt = DynamicLibrary.open('MSIMG32.dll')
.lookupFunction<TransparentBltNative, TransparentBltDart>('TransparentBlt');
// hdcDest : HDC -> Pointer<Void>
// xoriginDest : INT -> Int32
// yoriginDest : INT -> Int32
// wDest : INT -> Int32
// hDest : INT -> Int32
// hdcSrc : HDC -> Pointer<Void>
// xoriginSrc : INT -> Int32
// yoriginSrc : INT -> Int32
// wSrc : INT -> Int32
// hSrc : INT -> Int32
// crTransparent : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function TransparentBlt(
hdcDest: THandle; // HDC
xoriginDest: Integer; // INT
yoriginDest: Integer; // INT
wDest: Integer; // INT
hDest: Integer; // INT
hdcSrc: THandle; // HDC
xoriginSrc: Integer; // INT
yoriginSrc: Integer; // INT
wSrc: Integer; // INT
hSrc: Integer; // INT
crTransparent: DWORD // DWORD
): BOOL; stdcall;
external 'MSIMG32.dll' name 'TransparentBlt';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "TransparentBlt"
c_TransparentBlt :: Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Word32 -> IO CInt
-- hdcDest : HDC -> Ptr ()
-- xoriginDest : INT -> Int32
-- yoriginDest : INT -> Int32
-- wDest : INT -> Int32
-- hDest : INT -> Int32
-- hdcSrc : HDC -> Ptr ()
-- xoriginSrc : INT -> Int32
-- yoriginSrc : INT -> Int32
-- wSrc : INT -> Int32
-- hSrc : INT -> Int32
-- crTransparent : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let transparentblt =
foreign "TransparentBlt"
((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) *)
(* xoriginDest : INT -> int32_t *)
(* yoriginDest : INT -> int32_t *)
(* wDest : INT -> int32_t *)
(* hDest : INT -> int32_t *)
(* hdcSrc : HDC -> (ptr void) *)
(* xoriginSrc : INT -> int32_t *)
(* yoriginSrc : INT -> int32_t *)
(* wSrc : INT -> int32_t *)
(* hSrc : INT -> int32_t *)
(* crTransparent : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msimg32 (t "MSIMG32.dll"))
(cffi:use-foreign-library msimg32)
(cffi:defcfun ("TransparentBlt" transparent-blt :convention :stdcall) :int32
(hdc-dest :pointer) ; HDC
(xorigin-dest :int32) ; INT
(yorigin-dest :int32) ; INT
(w-dest :int32) ; INT
(h-dest :int32) ; INT
(hdc-src :pointer) ; HDC
(xorigin-src :int32) ; INT
(yorigin-src :int32) ; INT
(w-src :int32) ; INT
(h-src :int32) ; INT
(cr-transparent :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $TransparentBlt = Win32::API::More->new('MSIMG32',
'BOOL TransparentBlt(HANDLE hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, HANDLE hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, DWORD crTransparent)');
# my $ret = $TransparentBlt->Call($hdcDest, $xoriginDest, $yoriginDest, $wDest, $hDest, $hdcSrc, $xoriginSrc, $yoriginSrc, $wSrc, $hSrc, $crTransparent);
# hdcDest : HDC -> HANDLE
# xoriginDest : INT -> int
# yoriginDest : INT -> int
# wDest : INT -> int
# hDest : INT -> int
# hdcSrc : HDC -> HANDLE
# xoriginSrc : INT -> int
# yoriginSrc : INT -> int
# wSrc : INT -> int
# hSrc : INT -> int
# crTransparent : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f AlphaBlend — アルファ値を用いて2つのビットマップを半透明合成する。
- f GetDIBits — ビットマップのビットをDIB形式で取得する。
- f SetDIBits — DIBのビットでビットマップのピクセルを設定する。
- f SetStretchBltMode — ビットマップ伸縮時のラスタ補間モードを設定する。
- f StretchDIBits — DIBのピクセルを伸縮して転送先矩形へ転送する。