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

GdiTransparentBlt

関数
指定色を透過扱いにしてビットマップを転送するGDI関数。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL GdiTransparentBlt(
    HDC hdcDest,
    INT xoriginDest,
    INT yoriginDest,
    INT wDest,
    INT hDest,
    HDC hdcSrc,
    INT xoriginSrc,
    INT yoriginSrc,
    INT wSrc,
    INT hSrc,
    DWORD crTransparent
);

パラメーター

名前方向
hdcDestHDCin
xoriginDestINTin
yoriginDestINTin
wDestINTin
hDestINTin
hdcSrcHDCin
xoriginSrcINTin
yoriginSrcINTin
wSrcINTin
hSrcINTin
crTransparentDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GdiTransparentBlt(
    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("GDI32.dll", ExactSpelling = true)]
static extern bool GdiTransparentBlt(
    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("GDI32.dll", ExactSpelling:=True)>
Public Shared Function GdiTransparentBlt(
    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 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 GdiTransparentBlt Lib "gdi32" ( _
    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

GdiTransparentBlt = ctypes.windll.gdi32.GdiTransparentBlt
GdiTransparentBlt.restype = wintypes.BOOL
GdiTransparentBlt.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('GDI32.dll')
GdiTransparentBlt = Fiddle::Function.new(
  lib['GdiTransparentBlt'],
  [
    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 = "gdi32")]
extern "system" {
    fn GdiTransparentBlt(
        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("GDI32.dll")]
public static extern bool GdiTransparentBlt(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 'GDI32_GdiTransparentBlt' -Namespace Win32 -PassThru
# $api::GdiTransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent)
#uselib "GDI32.dll"
#func global GdiTransparentBlt "GdiTransparentBlt" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GdiTransparentBlt 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 "GDI32.dll"
#cfunc global GdiTransparentBlt "GdiTransparentBlt" sptr, int, int, int, int, sptr, int, int, int, int, int
; res = GdiTransparentBlt(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 GdiTransparentBlt(HDC hdcDest, INT xoriginDest, INT yoriginDest, INT wDest, INT hDest, HDC hdcSrc, INT xoriginSrc, INT yoriginSrc, INT wSrc, INT hSrc, DWORD crTransparent)
#uselib "GDI32.dll"
#cfunc global GdiTransparentBlt "GdiTransparentBlt" intptr, int, int, int, int, intptr, int, int, int, int, int
; res = GdiTransparentBlt(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 (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGdiTransparentBlt = gdi32.NewProc("GdiTransparentBlt")
)

// hdcDest (HDC), xoriginDest (INT), yoriginDest (INT), wDest (INT), hDest (INT), hdcSrc (HDC), xoriginSrc (INT), yoriginSrc (INT), wSrc (INT), hSrc (INT), crTransparent (DWORD)
r1, _, err := procGdiTransparentBlt.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   // BOOL
function GdiTransparentBlt(
  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 'GDI32.dll' name 'GdiTransparentBlt';
result := DllCall("GDI32\GdiTransparentBlt"
    , "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
●GdiTransparentBlt(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, crTransparent) = DLL("GDI32.dll", "bool GdiTransparentBlt(void*, int, int, int, int, void*, int, int, int, int, dword)")
# 呼び出し: GdiTransparentBlt(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)。