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

PlgBlt

関数
平行四辺形領域へビットマップを転送する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL PlgBlt(
    HDC hdcDest,
    const POINT* lpPoint,
    HDC hdcSrc,
    INT xSrc,
    INT ySrc,
    INT width,
    INT height,
    HBITMAP hbmMask,   // optional
    INT xMask,
    INT yMask
);

パラメーター

名前方向
hdcDestHDCin
lpPointPOINT*in
hdcSrcHDCin
xSrcINTin
ySrcINTin
widthINTin
heightINTin
hbmMaskHBITMAPinoptional
xMaskINTin
yMaskINTin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL PlgBlt(
    HDC hdcDest,
    const POINT* lpPoint,
    HDC hdcSrc,
    INT xSrc,
    INT ySrc,
    INT width,
    INT height,
    HBITMAP hbmMask,   // optional
    INT xMask,
    INT yMask
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool PlgBlt(
    IntPtr hdcDest,   // HDC
    IntPtr lpPoint,   // POINT*
    IntPtr hdcSrc,   // HDC
    int xSrc,   // INT
    int ySrc,   // INT
    int width,   // INT
    int height,   // INT
    IntPtr hbmMask,   // HBITMAP optional
    int xMask,   // INT
    int yMask   // INT
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function PlgBlt(
    hdcDest As IntPtr,   ' HDC
    lpPoint As IntPtr,   ' POINT*
    hdcSrc As IntPtr,   ' HDC
    xSrc As Integer,   ' INT
    ySrc As Integer,   ' INT
    width As Integer,   ' INT
    height As Integer,   ' INT
    hbmMask As IntPtr,   ' HBITMAP optional
    xMask As Integer,   ' INT
    yMask As Integer   ' INT
) As Boolean
End Function
' hdcDest : HDC
' lpPoint : POINT*
' hdcSrc : HDC
' xSrc : INT
' ySrc : INT
' width : INT
' height : INT
' hbmMask : HBITMAP optional
' xMask : INT
' yMask : INT
Declare PtrSafe Function PlgBlt Lib "gdi32" ( _
    ByVal hdcDest As LongPtr, _
    ByVal lpPoint As LongPtr, _
    ByVal hdcSrc As LongPtr, _
    ByVal xSrc As Long, _
    ByVal ySrc As Long, _
    ByVal width As Long, _
    ByVal height As Long, _
    ByVal hbmMask As LongPtr, _
    ByVal xMask As Long, _
    ByVal yMask As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PlgBlt = ctypes.windll.gdi32.PlgBlt
PlgBlt.restype = wintypes.BOOL
PlgBlt.argtypes = [
    wintypes.HANDLE,  # hdcDest : HDC
    ctypes.c_void_p,  # lpPoint : POINT*
    wintypes.HANDLE,  # hdcSrc : HDC
    ctypes.c_int,  # xSrc : INT
    ctypes.c_int,  # ySrc : INT
    ctypes.c_int,  # width : INT
    ctypes.c_int,  # height : INT
    wintypes.HANDLE,  # hbmMask : HBITMAP optional
    ctypes.c_int,  # xMask : INT
    ctypes.c_int,  # yMask : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
PlgBlt = Fiddle::Function.new(
  lib['PlgBlt'],
  [
    Fiddle::TYPE_VOIDP,  # hdcDest : HDC
    Fiddle::TYPE_VOIDP,  # lpPoint : POINT*
    Fiddle::TYPE_VOIDP,  # hdcSrc : HDC
    Fiddle::TYPE_INT,  # xSrc : INT
    Fiddle::TYPE_INT,  # ySrc : INT
    Fiddle::TYPE_INT,  # width : INT
    Fiddle::TYPE_INT,  # height : INT
    Fiddle::TYPE_VOIDP,  # hbmMask : HBITMAP optional
    Fiddle::TYPE_INT,  # xMask : INT
    Fiddle::TYPE_INT,  # yMask : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn PlgBlt(
        hdcDest: *mut core::ffi::c_void,  // HDC
        lpPoint: *const POINT,  // POINT*
        hdcSrc: *mut core::ffi::c_void,  // HDC
        xSrc: i32,  // INT
        ySrc: i32,  // INT
        width: i32,  // INT
        height: i32,  // INT
        hbmMask: *mut core::ffi::c_void,  // HBITMAP optional
        xMask: i32,  // INT
        yMask: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool PlgBlt(IntPtr hdcDest, IntPtr lpPoint, IntPtr hdcSrc, int xSrc, int ySrc, int width, int height, IntPtr hbmMask, int xMask, int yMask);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_PlgBlt' -Namespace Win32 -PassThru
# $api::PlgBlt(hdcDest, lpPoint, hdcSrc, xSrc, ySrc, width, height, hbmMask, xMask, yMask)
#uselib "GDI32.dll"
#func global PlgBlt "PlgBlt" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; PlgBlt hdcDest, varptr(lpPoint), hdcSrc, xSrc, ySrc, width, height, hbmMask, xMask, yMask   ; 戻り値は stat
; hdcDest : HDC -> "sptr"
; lpPoint : POINT* -> "sptr"
; hdcSrc : HDC -> "sptr"
; xSrc : INT -> "sptr"
; ySrc : INT -> "sptr"
; width : INT -> "sptr"
; height : INT -> "sptr"
; hbmMask : HBITMAP optional -> "sptr"
; xMask : INT -> "sptr"
; yMask : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global PlgBlt "PlgBlt" sptr, var, sptr, int, int, int, int, sptr, int, int
; res = PlgBlt(hdcDest, lpPoint, hdcSrc, xSrc, ySrc, width, height, hbmMask, xMask, yMask)
; hdcDest : HDC -> "sptr"
; lpPoint : POINT* -> "var"
; hdcSrc : HDC -> "sptr"
; xSrc : INT -> "int"
; ySrc : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; hbmMask : HBITMAP optional -> "sptr"
; xMask : INT -> "int"
; yMask : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL PlgBlt(HDC hdcDest, POINT* lpPoint, HDC hdcSrc, INT xSrc, INT ySrc, INT width, INT height, HBITMAP hbmMask, INT xMask, INT yMask)
#uselib "GDI32.dll"
#cfunc global PlgBlt "PlgBlt" intptr, var, intptr, int, int, int, int, intptr, int, int
; res = PlgBlt(hdcDest, lpPoint, hdcSrc, xSrc, ySrc, width, height, hbmMask, xMask, yMask)
; hdcDest : HDC -> "intptr"
; lpPoint : POINT* -> "var"
; hdcSrc : HDC -> "intptr"
; xSrc : INT -> "int"
; ySrc : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; hbmMask : HBITMAP optional -> "intptr"
; xMask : INT -> "int"
; yMask : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procPlgBlt = gdi32.NewProc("PlgBlt")
)

// hdcDest (HDC), lpPoint (POINT*), hdcSrc (HDC), xSrc (INT), ySrc (INT), width (INT), height (INT), hbmMask (HBITMAP optional), xMask (INT), yMask (INT)
r1, _, err := procPlgBlt.Call(
	uintptr(hdcDest),
	uintptr(lpPoint),
	uintptr(hdcSrc),
	uintptr(xSrc),
	uintptr(ySrc),
	uintptr(width),
	uintptr(height),
	uintptr(hbmMask),
	uintptr(xMask),
	uintptr(yMask),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function PlgBlt(
  hdcDest: THandle;   // HDC
  lpPoint: Pointer;   // POINT*
  hdcSrc: THandle;   // HDC
  xSrc: Integer;   // INT
  ySrc: Integer;   // INT
  width: Integer;   // INT
  height: Integer;   // INT
  hbmMask: THandle;   // HBITMAP optional
  xMask: Integer;   // INT
  yMask: Integer   // INT
): BOOL; stdcall;
  external 'GDI32.dll' name 'PlgBlt';
result := DllCall("GDI32\PlgBlt"
    , "Ptr", hdcDest   ; HDC
    , "Ptr", lpPoint   ; POINT*
    , "Ptr", hdcSrc   ; HDC
    , "Int", xSrc   ; INT
    , "Int", ySrc   ; INT
    , "Int", width   ; INT
    , "Int", height   ; INT
    , "Ptr", hbmMask   ; HBITMAP optional
    , "Int", xMask   ; INT
    , "Int", yMask   ; INT
    , "Int")   ; return: BOOL
●PlgBlt(hdcDest, lpPoint, hdcSrc, xSrc, ySrc, width, height, hbmMask, xMask, yMask) = DLL("GDI32.dll", "bool PlgBlt(void*, void*, void*, int, int, int, int, void*, int, int)")
# 呼び出し: PlgBlt(hdcDest, lpPoint, hdcSrc, xSrc, ySrc, width, height, hbmMask, xMask, yMask)
# hdcDest : HDC -> "void*"
# lpPoint : POINT* -> "void*"
# hdcSrc : HDC -> "void*"
# xSrc : INT -> "int"
# ySrc : INT -> "int"
# width : INT -> "int"
# height : INT -> "int"
# hbmMask : HBITMAP optional -> "void*"
# xMask : INT -> "int"
# yMask : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。