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

AlphaBlend

関数
アルファ値を用いて2つのビットマップを半透明合成する。
DLLMSIMG32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL AlphaBlend(
    HDC hdcDest,
    INT xoriginDest,
    INT yoriginDest,
    INT wDest,
    INT hDest,
    HDC hdcSrc,
    INT xoriginSrc,
    INT yoriginSrc,
    INT wSrc,
    INT hSrc,
    BLENDFUNCTION ftn
);

パラメーター

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

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL AlphaBlend(
    HDC hdcDest,
    INT xoriginDest,
    INT yoriginDest,
    INT wDest,
    INT hDest,
    HDC hdcSrc,
    INT xoriginSrc,
    INT yoriginSrc,
    INT wSrc,
    INT hSrc,
    BLENDFUNCTION ftn
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSIMG32.dll", ExactSpelling = true)]
static extern bool AlphaBlend(
    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
    BLENDFUNCTION ftn   // BLENDFUNCTION
);
<DllImport("MSIMG32.dll", ExactSpelling:=True)>
Public Shared Function AlphaBlend(
    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
    ftn As BLENDFUNCTION   ' BLENDFUNCTION
) As Boolean
End Function
' hdcDest : HDC
' xoriginDest : INT
' yoriginDest : INT
' wDest : INT
' hDest : INT
' hdcSrc : HDC
' xoriginSrc : INT
' yoriginSrc : INT
' wSrc : INT
' hSrc : INT
' ftn : BLENDFUNCTION
Declare PtrSafe Function AlphaBlend 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 ftn As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AlphaBlend = ctypes.windll.msimg32.AlphaBlend
AlphaBlend.restype = wintypes.BOOL
AlphaBlend.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
    BLENDFUNCTION,  # ftn : BLENDFUNCTION
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MSIMG32.dll')
AlphaBlend = Fiddle::Function.new(
  lib['AlphaBlend'],
  [
    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_VOIDP,  # ftn : BLENDFUNCTION
  ],
  Fiddle::TYPE_INT)
#[link(name = "msimg32")]
extern "system" {
    fn AlphaBlend(
        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
        ftn: BLENDFUNCTION  // BLENDFUNCTION
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSIMG32.dll")]
public static extern bool AlphaBlend(IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, BLENDFUNCTION ftn);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSIMG32_AlphaBlend' -Namespace Win32 -PassThru
# $api::AlphaBlend(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn)
#uselib "MSIMG32.dll"
#func global AlphaBlend "AlphaBlend" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; AlphaBlend hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn   ; 戻り値は 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"
; ftn : BLENDFUNCTION -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MSIMG32.dll"
#cfunc global AlphaBlend "AlphaBlend" sptr, int, int, int, int, sptr, int, int, int, int, int
; res = AlphaBlend(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn)
; 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"
; ftn : BLENDFUNCTION -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; BOOL AlphaBlend(HDC hdcDest, INT xoriginDest, INT yoriginDest, INT wDest, INT hDest, HDC hdcSrc, INT xoriginSrc, INT yoriginSrc, INT wSrc, INT hSrc, BLENDFUNCTION ftn)
#uselib "MSIMG32.dll"
#cfunc global AlphaBlend "AlphaBlend" intptr, int, int, int, int, intptr, int, int, int, int, int
; res = AlphaBlend(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn)
; 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"
; ftn : BLENDFUNCTION -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msimg32 = windows.NewLazySystemDLL("MSIMG32.dll")
	procAlphaBlend = msimg32.NewProc("AlphaBlend")
)

// hdcDest (HDC), xoriginDest (INT), yoriginDest (INT), wDest (INT), hDest (INT), hdcSrc (HDC), xoriginSrc (INT), yoriginSrc (INT), wSrc (INT), hSrc (INT), ftn (BLENDFUNCTION)
r1, _, err := procAlphaBlend.Call(
	uintptr(hdcDest),
	uintptr(xoriginDest),
	uintptr(yoriginDest),
	uintptr(wDest),
	uintptr(hDest),
	uintptr(hdcSrc),
	uintptr(xoriginSrc),
	uintptr(yoriginSrc),
	uintptr(wSrc),
	uintptr(hSrc),
	uintptr(ftn),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function AlphaBlend(
  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
  ftn: BLENDFUNCTION   // BLENDFUNCTION
): BOOL; stdcall;
  external 'MSIMG32.dll' name 'AlphaBlend';
result := DllCall("MSIMG32\AlphaBlend"
    , "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
    , "Ptr", ftn   ; BLENDFUNCTION
    , "Int")   ; return: BOOL
●AlphaBlend(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn) = DLL("MSIMG32.dll", "bool AlphaBlend(void*, int, int, int, int, void*, int, int, int, int, void*)")
# 呼び出し: AlphaBlend(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn)
# 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"
# ftn : BLENDFUNCTION -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。