ホーム › Media.Multimedia › DrawDibDraw
DrawDibDraw
関数DIB画像をデバイスコンテキストに描画する。
シグネチャ
// MSVFW32.dll
#include <windows.h>
BOOL DrawDibDraw(
INT_PTR hdd,
HDC hdc,
INT xDst,
INT yDst,
INT dxDst,
INT dyDst,
BITMAPINFOHEADER* lpbi, // optional
void* lpBits, // optional
INT xSrc,
INT ySrc,
INT dxSrc,
INT dySrc,
DWORD wFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hdd | INT_PTR | in | DrawDib DC へのハンドル。 | ||||||||||||||||||||
| hdc | HDC | in | DC へのハンドル。 | ||||||||||||||||||||
| xDst | INT | in | 転送先矩形の左上隅の x 座標(MM_TEXT クライアント座標)。 | ||||||||||||||||||||
| yDst | INT | in | 転送先矩形の左上隅の y 座標(MM_TEXT クライアント座標)。 | ||||||||||||||||||||
| dxDst | INT | in | 転送先矩形の幅(MM_TEXT クライアント座標)。dxDst が −1 の場合はビットマップの幅が使用されます。 | ||||||||||||||||||||
| dyDst | INT | in | 転送先矩形の高さ(MM_TEXT クライアント座標)。dyDst が −1 の場合はビットマップの高さが使用されます。 | ||||||||||||||||||||
| lpbi | BITMAPINFOHEADER* | inoptional | 画像形式を含む BITMAPINFOHEADER 構造体へのポインター。DIB のカラーテーブルは BITMAPINFOHEADER 内の形式の後に続きます。biHeight メンバーは正の値でなければなりません。DrawDibDraw は上下反転した DIB を描画しません。 | ||||||||||||||||||||
| lpBits | void* | inoptional | ビットマップのビットを含むバッファーへのポインター。 | ||||||||||||||||||||
| xSrc | INT | in | 転送元矩形の左上隅の x 座標(ピクセル単位)。座標 (0,0) はビットマップの左上隅を表します。 | ||||||||||||||||||||
| ySrc | INT | in | 転送元矩形の左上隅の y 座標(ピクセル単位)。座標 (0,0) はビットマップの左上隅を表します。 | ||||||||||||||||||||
| dxSrc | INT | in | 転送元矩形の幅(ピクセル単位)。 | ||||||||||||||||||||
| dySrc | INT | in | 転送元矩形の高さ(ピクセル単位)。 | ||||||||||||||||||||
| wFlags | DWORD | in | 描画に適用するフラグ。次の値が定義されています。
|
戻り値の型: BOOL
公式ドキュメント
DrawDibDraw 関数は DIB を画面に描画します。
戻り値
成功した場合は TRUE を、それ以外の場合は FALSE を返します。
解説(Remarks)
DDF_DONTDRAW を指定すると、DrawDibDraw は画像を展開しますが表示しません。続いて DDF_UPDATE を指定して DrawDibDraw を呼び出すと、画像が表示されます。
DrawDib DC にオフスクリーンバッファーが指定されていない場合、DDF_DONTDRAW を指定するとフレームは直ちに画面に描画されます。続いて DDF_UPDATE を指定して DrawDibDraw を呼び出すと失敗します。
DDF_UPDATE と DDF_DONTDRAW は設定するタイミングが異なりますが、組み合わせて使用することでオフスクリーンで合成画像を作成できます。オフスクリーン画像が完成したら、DrawDibDraw を呼び出して画像を表示できます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MSVFW32.dll
#include <windows.h>
BOOL DrawDibDraw(
INT_PTR hdd,
HDC hdc,
INT xDst,
INT yDst,
INT dxDst,
INT dyDst,
BITMAPINFOHEADER* lpbi, // optional
void* lpBits, // optional
INT xSrc,
INT ySrc,
INT dxSrc,
INT dySrc,
DWORD wFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSVFW32.dll", ExactSpelling = true)]
static extern bool DrawDibDraw(
IntPtr hdd, // INT_PTR
IntPtr hdc, // HDC
int xDst, // INT
int yDst, // INT
int dxDst, // INT
int dyDst, // INT
IntPtr lpbi, // BITMAPINFOHEADER* optional
IntPtr lpBits, // void* optional
int xSrc, // INT
int ySrc, // INT
int dxSrc, // INT
int dySrc, // INT
uint wFlags // DWORD
);<DllImport("MSVFW32.dll", ExactSpelling:=True)>
Public Shared Function DrawDibDraw(
hdd As IntPtr, ' INT_PTR
hdc As IntPtr, ' HDC
xDst As Integer, ' INT
yDst As Integer, ' INT
dxDst As Integer, ' INT
dyDst As Integer, ' INT
lpbi As IntPtr, ' BITMAPINFOHEADER* optional
lpBits As IntPtr, ' void* optional
xSrc As Integer, ' INT
ySrc As Integer, ' INT
dxSrc As Integer, ' INT
dySrc As Integer, ' INT
wFlags As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hdd : INT_PTR
' hdc : HDC
' xDst : INT
' yDst : INT
' dxDst : INT
' dyDst : INT
' lpbi : BITMAPINFOHEADER* optional
' lpBits : void* optional
' xSrc : INT
' ySrc : INT
' dxSrc : INT
' dySrc : INT
' wFlags : DWORD
Declare PtrSafe Function DrawDibDraw Lib "msvfw32" ( _
ByVal hdd As LongPtr, _
ByVal hdc As LongPtr, _
ByVal xDst As Long, _
ByVal yDst As Long, _
ByVal dxDst As Long, _
ByVal dyDst As Long, _
ByVal lpbi As LongPtr, _
ByVal lpBits As LongPtr, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal dxSrc As Long, _
ByVal dySrc As Long, _
ByVal wFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DrawDibDraw = ctypes.windll.msvfw32.DrawDibDraw
DrawDibDraw.restype = wintypes.BOOL
DrawDibDraw.argtypes = [
ctypes.c_ssize_t, # hdd : INT_PTR
wintypes.HANDLE, # hdc : HDC
ctypes.c_int, # xDst : INT
ctypes.c_int, # yDst : INT
ctypes.c_int, # dxDst : INT
ctypes.c_int, # dyDst : INT
ctypes.c_void_p, # lpbi : BITMAPINFOHEADER* optional
ctypes.POINTER(None), # lpBits : void* optional
ctypes.c_int, # xSrc : INT
ctypes.c_int, # ySrc : INT
ctypes.c_int, # dxSrc : INT
ctypes.c_int, # dySrc : INT
wintypes.DWORD, # wFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSVFW32.dll')
DrawDibDraw = Fiddle::Function.new(
lib['DrawDibDraw'],
[
Fiddle::TYPE_INTPTR_T, # hdd : INT_PTR
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_INT, # xDst : INT
Fiddle::TYPE_INT, # yDst : INT
Fiddle::TYPE_INT, # dxDst : INT
Fiddle::TYPE_INT, # dyDst : INT
Fiddle::TYPE_VOIDP, # lpbi : BITMAPINFOHEADER* optional
Fiddle::TYPE_VOIDP, # lpBits : void* optional
Fiddle::TYPE_INT, # xSrc : INT
Fiddle::TYPE_INT, # ySrc : INT
Fiddle::TYPE_INT, # dxSrc : INT
Fiddle::TYPE_INT, # dySrc : INT
-Fiddle::TYPE_INT, # wFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "msvfw32")]
extern "system" {
fn DrawDibDraw(
hdd: isize, // INT_PTR
hdc: *mut core::ffi::c_void, // HDC
xDst: i32, // INT
yDst: i32, // INT
dxDst: i32, // INT
dyDst: i32, // INT
lpbi: *mut BITMAPINFOHEADER, // BITMAPINFOHEADER* optional
lpBits: *mut (), // void* optional
xSrc: i32, // INT
ySrc: i32, // INT
dxSrc: i32, // INT
dySrc: i32, // INT
wFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSVFW32.dll")]
public static extern bool DrawDibDraw(IntPtr hdd, IntPtr hdc, int xDst, int yDst, int dxDst, int dyDst, IntPtr lpbi, IntPtr lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, uint wFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSVFW32_DrawDibDraw' -Namespace Win32 -PassThru
# $api::DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags)#uselib "MSVFW32.dll"
#func global DrawDibDraw "DrawDibDraw" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DrawDibDraw hdd, hdc, xDst, yDst, dxDst, dyDst, varptr(lpbi), lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags ; 戻り値は stat
; hdd : INT_PTR -> "sptr"
; hdc : HDC -> "sptr"
; xDst : INT -> "sptr"
; yDst : INT -> "sptr"
; dxDst : INT -> "sptr"
; dyDst : INT -> "sptr"
; lpbi : BITMAPINFOHEADER* optional -> "sptr"
; lpBits : void* optional -> "sptr"
; xSrc : INT -> "sptr"
; ySrc : INT -> "sptr"
; dxSrc : INT -> "sptr"
; dySrc : INT -> "sptr"
; wFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MSVFW32.dll" #cfunc global DrawDibDraw "DrawDibDraw" sptr, sptr, int, int, int, int, var, sptr, int, int, int, int, int ; res = DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags) ; hdd : INT_PTR -> "sptr" ; hdc : HDC -> "sptr" ; xDst : INT -> "int" ; yDst : INT -> "int" ; dxDst : INT -> "int" ; dyDst : INT -> "int" ; lpbi : BITMAPINFOHEADER* optional -> "var" ; lpBits : void* optional -> "sptr" ; xSrc : INT -> "int" ; ySrc : INT -> "int" ; dxSrc : INT -> "int" ; dySrc : INT -> "int" ; wFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MSVFW32.dll" #cfunc global DrawDibDraw "DrawDibDraw" sptr, sptr, int, int, int, int, sptr, sptr, int, int, int, int, int ; res = DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, varptr(lpbi), lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags) ; hdd : INT_PTR -> "sptr" ; hdc : HDC -> "sptr" ; xDst : INT -> "int" ; yDst : INT -> "int" ; dxDst : INT -> "int" ; dyDst : INT -> "int" ; lpbi : BITMAPINFOHEADER* optional -> "sptr" ; lpBits : void* optional -> "sptr" ; xSrc : INT -> "int" ; ySrc : INT -> "int" ; dxSrc : INT -> "int" ; dySrc : INT -> "int" ; wFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL DrawDibDraw(INT_PTR hdd, HDC hdc, INT xDst, INT yDst, INT dxDst, INT dyDst, BITMAPINFOHEADER* lpbi, void* lpBits, INT xSrc, INT ySrc, INT dxSrc, INT dySrc, DWORD wFlags) #uselib "MSVFW32.dll" #cfunc global DrawDibDraw "DrawDibDraw" intptr, intptr, int, int, int, int, var, intptr, int, int, int, int, int ; res = DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags) ; hdd : INT_PTR -> "intptr" ; hdc : HDC -> "intptr" ; xDst : INT -> "int" ; yDst : INT -> "int" ; dxDst : INT -> "int" ; dyDst : INT -> "int" ; lpbi : BITMAPINFOHEADER* optional -> "var" ; lpBits : void* optional -> "intptr" ; xSrc : INT -> "int" ; ySrc : INT -> "int" ; dxSrc : INT -> "int" ; dySrc : INT -> "int" ; wFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL DrawDibDraw(INT_PTR hdd, HDC hdc, INT xDst, INT yDst, INT dxDst, INT dyDst, BITMAPINFOHEADER* lpbi, void* lpBits, INT xSrc, INT ySrc, INT dxSrc, INT dySrc, DWORD wFlags) #uselib "MSVFW32.dll" #cfunc global DrawDibDraw "DrawDibDraw" intptr, intptr, int, int, int, int, intptr, intptr, int, int, int, int, int ; res = DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, varptr(lpbi), lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags) ; hdd : INT_PTR -> "intptr" ; hdc : HDC -> "intptr" ; xDst : INT -> "int" ; yDst : INT -> "int" ; dxDst : INT -> "int" ; dyDst : INT -> "int" ; lpbi : BITMAPINFOHEADER* optional -> "intptr" ; lpBits : void* optional -> "intptr" ; xSrc : INT -> "int" ; ySrc : INT -> "int" ; dxSrc : INT -> "int" ; dySrc : INT -> "int" ; wFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msvfw32 = windows.NewLazySystemDLL("MSVFW32.dll")
procDrawDibDraw = msvfw32.NewProc("DrawDibDraw")
)
// hdd (INT_PTR), hdc (HDC), xDst (INT), yDst (INT), dxDst (INT), dyDst (INT), lpbi (BITMAPINFOHEADER* optional), lpBits (void* optional), xSrc (INT), ySrc (INT), dxSrc (INT), dySrc (INT), wFlags (DWORD)
r1, _, err := procDrawDibDraw.Call(
uintptr(hdd),
uintptr(hdc),
uintptr(xDst),
uintptr(yDst),
uintptr(dxDst),
uintptr(dyDst),
uintptr(lpbi),
uintptr(lpBits),
uintptr(xSrc),
uintptr(ySrc),
uintptr(dxSrc),
uintptr(dySrc),
uintptr(wFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DrawDibDraw(
hdd: NativeInt; // INT_PTR
hdc: THandle; // HDC
xDst: Integer; // INT
yDst: Integer; // INT
dxDst: Integer; // INT
dyDst: Integer; // INT
lpbi: Pointer; // BITMAPINFOHEADER* optional
lpBits: Pointer; // void* optional
xSrc: Integer; // INT
ySrc: Integer; // INT
dxSrc: Integer; // INT
dySrc: Integer; // INT
wFlags: DWORD // DWORD
): BOOL; stdcall;
external 'MSVFW32.dll' name 'DrawDibDraw';result := DllCall("MSVFW32\DrawDibDraw"
, "Ptr", hdd ; INT_PTR
, "Ptr", hdc ; HDC
, "Int", xDst ; INT
, "Int", yDst ; INT
, "Int", dxDst ; INT
, "Int", dyDst ; INT
, "Ptr", lpbi ; BITMAPINFOHEADER* optional
, "Ptr", lpBits ; void* optional
, "Int", xSrc ; INT
, "Int", ySrc ; INT
, "Int", dxSrc ; INT
, "Int", dySrc ; INT
, "UInt", wFlags ; DWORD
, "Int") ; return: BOOL●DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags) = DLL("MSVFW32.dll", "bool DrawDibDraw(int, void*, int, int, int, int, void*, void*, int, int, int, int, dword)")
# 呼び出し: DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags)
# hdd : INT_PTR -> "int"
# hdc : HDC -> "void*"
# xDst : INT -> "int"
# yDst : INT -> "int"
# dxDst : INT -> "int"
# dyDst : INT -> "int"
# lpbi : BITMAPINFOHEADER* optional -> "void*"
# lpBits : void* optional -> "void*"
# xSrc : INT -> "int"
# ySrc : INT -> "int"
# dxSrc : INT -> "int"
# dySrc : INT -> "int"
# wFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msvfw32" fn DrawDibDraw(
hdd: isize, // INT_PTR
hdc: ?*anyopaque, // HDC
xDst: i32, // INT
yDst: i32, // INT
dxDst: i32, // INT
dyDst: i32, // INT
lpbi: [*c]BITMAPINFOHEADER, // BITMAPINFOHEADER* optional
lpBits: ?*anyopaque, // void* optional
xSrc: i32, // INT
ySrc: i32, // INT
dxSrc: i32, // INT
dySrc: i32, // INT
wFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc DrawDibDraw(
hdd: int, # INT_PTR
hdc: pointer, # HDC
xDst: int32, # INT
yDst: int32, # INT
dxDst: int32, # INT
dyDst: int32, # INT
lpbi: ptr BITMAPINFOHEADER, # BITMAPINFOHEADER* optional
lpBits: pointer, # void* optional
xSrc: int32, # INT
ySrc: int32, # INT
dxSrc: int32, # INT
dySrc: int32, # INT
wFlags: uint32 # DWORD
): int32 {.importc: "DrawDibDraw", stdcall, dynlib: "MSVFW32.dll".}pragma(lib, "msvfw32");
extern(Windows)
int DrawDibDraw(
ptrdiff_t hdd, // INT_PTR
void* hdc, // HDC
int xDst, // INT
int yDst, // INT
int dxDst, // INT
int dyDst, // INT
BITMAPINFOHEADER* lpbi, // BITMAPINFOHEADER* optional
void* lpBits, // void* optional
int xSrc, // INT
int ySrc, // INT
int dxSrc, // INT
int dySrc, // INT
uint wFlags // DWORD
);ccall((:DrawDibDraw, "MSVFW32.dll"), stdcall, Int32,
(Int, Ptr{Cvoid}, Int32, Int32, Int32, Int32, Ptr{BITMAPINFOHEADER}, Ptr{Cvoid}, Int32, Int32, Int32, Int32, UInt32),
hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags)
# hdd : INT_PTR -> Int
# hdc : HDC -> Ptr{Cvoid}
# xDst : INT -> Int32
# yDst : INT -> Int32
# dxDst : INT -> Int32
# dyDst : INT -> Int32
# lpbi : BITMAPINFOHEADER* optional -> Ptr{BITMAPINFOHEADER}
# lpBits : void* optional -> Ptr{Cvoid}
# xSrc : INT -> Int32
# ySrc : INT -> Int32
# dxSrc : INT -> Int32
# dySrc : INT -> Int32
# wFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DrawDibDraw(
intptr_t hdd,
void* hdc,
int32_t xDst,
int32_t yDst,
int32_t dxDst,
int32_t dyDst,
void* lpbi,
void* lpBits,
int32_t xSrc,
int32_t ySrc,
int32_t dxSrc,
int32_t dySrc,
uint32_t wFlags);
]]
local msvfw32 = ffi.load("msvfw32")
-- msvfw32.DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags)
-- hdd : INT_PTR
-- hdc : HDC
-- xDst : INT
-- yDst : INT
-- dxDst : INT
-- dyDst : INT
-- lpbi : BITMAPINFOHEADER* optional
-- lpBits : void* optional
-- xSrc : INT
-- ySrc : INT
-- dxSrc : INT
-- dySrc : INT
-- wFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MSVFW32.dll');
const DrawDibDraw = lib.func('__stdcall', 'DrawDibDraw', 'int32_t', ['intptr_t', 'void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'void *', 'void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'uint32_t']);
// DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags)
// hdd : INT_PTR -> 'intptr_t'
// hdc : HDC -> 'void *'
// xDst : INT -> 'int32_t'
// yDst : INT -> 'int32_t'
// dxDst : INT -> 'int32_t'
// dyDst : INT -> 'int32_t'
// lpbi : BITMAPINFOHEADER* optional -> 'void *'
// lpBits : void* optional -> 'void *'
// xSrc : INT -> 'int32_t'
// ySrc : INT -> 'int32_t'
// dxSrc : INT -> 'int32_t'
// dySrc : INT -> 'int32_t'
// wFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSVFW32.dll", {
DrawDibDraw: { parameters: ["isize", "pointer", "i32", "i32", "i32", "i32", "pointer", "pointer", "i32", "i32", "i32", "i32", "u32"], result: "i32" },
});
// lib.symbols.DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags)
// hdd : INT_PTR -> "isize"
// hdc : HDC -> "pointer"
// xDst : INT -> "i32"
// yDst : INT -> "i32"
// dxDst : INT -> "i32"
// dyDst : INT -> "i32"
// lpbi : BITMAPINFOHEADER* optional -> "pointer"
// lpBits : void* optional -> "pointer"
// xSrc : INT -> "i32"
// ySrc : INT -> "i32"
// dxSrc : INT -> "i32"
// dySrc : INT -> "i32"
// wFlags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DrawDibDraw(
intptr_t hdd,
void* hdc,
int32_t xDst,
int32_t yDst,
int32_t dxDst,
int32_t dyDst,
void* lpbi,
void* lpBits,
int32_t xSrc,
int32_t ySrc,
int32_t dxSrc,
int32_t dySrc,
uint32_t wFlags);
C, "MSVFW32.dll");
// $ffi->DrawDibDraw(hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags);
// hdd : INT_PTR
// hdc : HDC
// xDst : INT
// yDst : INT
// dxDst : INT
// dyDst : INT
// lpbi : BITMAPINFOHEADER* optional
// lpBits : void* optional
// xSrc : INT
// ySrc : INT
// dxSrc : INT
// dySrc : INT
// wFlags : 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 Msvfw32 extends StdCallLibrary {
Msvfw32 INSTANCE = Native.load("msvfw32", Msvfw32.class);
boolean DrawDibDraw(
long hdd, // INT_PTR
Pointer hdc, // HDC
int xDst, // INT
int yDst, // INT
int dxDst, // INT
int dyDst, // INT
Pointer lpbi, // BITMAPINFOHEADER* optional
Pointer lpBits, // void* optional
int xSrc, // INT
int ySrc, // INT
int dxSrc, // INT
int dySrc, // INT
int wFlags // DWORD
);
}@[Link("msvfw32")]
lib LibMSVFW32
fun DrawDibDraw = DrawDibDraw(
hdd : LibC::SSizeT, # INT_PTR
hdc : Void*, # HDC
xDst : Int32, # INT
yDst : Int32, # INT
dxDst : Int32, # INT
dyDst : Int32, # INT
lpbi : BITMAPINFOHEADER*, # BITMAPINFOHEADER* optional
lpBits : Void*, # void* optional
xSrc : Int32, # INT
ySrc : Int32, # INT
dxSrc : Int32, # INT
dySrc : Int32, # INT
wFlags : 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 DrawDibDrawNative = Int32 Function(IntPtr, Pointer<Void>, Int32, Int32, Int32, Int32, Pointer<Void>, Pointer<Void>, Int32, Int32, Int32, Int32, Uint32);
typedef DrawDibDrawDart = int Function(int, Pointer<Void>, int, int, int, int, Pointer<Void>, Pointer<Void>, int, int, int, int, int);
final DrawDibDraw = DynamicLibrary.open('MSVFW32.dll')
.lookupFunction<DrawDibDrawNative, DrawDibDrawDart>('DrawDibDraw');
// hdd : INT_PTR -> IntPtr
// hdc : HDC -> Pointer<Void>
// xDst : INT -> Int32
// yDst : INT -> Int32
// dxDst : INT -> Int32
// dyDst : INT -> Int32
// lpbi : BITMAPINFOHEADER* optional -> Pointer<Void>
// lpBits : void* optional -> Pointer<Void>
// xSrc : INT -> Int32
// ySrc : INT -> Int32
// dxSrc : INT -> Int32
// dySrc : INT -> Int32
// wFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DrawDibDraw(
hdd: NativeInt; // INT_PTR
hdc: THandle; // HDC
xDst: Integer; // INT
yDst: Integer; // INT
dxDst: Integer; // INT
dyDst: Integer; // INT
lpbi: Pointer; // BITMAPINFOHEADER* optional
lpBits: Pointer; // void* optional
xSrc: Integer; // INT
ySrc: Integer; // INT
dxSrc: Integer; // INT
dySrc: Integer; // INT
wFlags: DWORD // DWORD
): BOOL; stdcall;
external 'MSVFW32.dll' name 'DrawDibDraw';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DrawDibDraw"
c_DrawDibDraw :: CIntPtr -> Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Ptr () -> Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Word32 -> IO CInt
-- hdd : INT_PTR -> CIntPtr
-- hdc : HDC -> Ptr ()
-- xDst : INT -> Int32
-- yDst : INT -> Int32
-- dxDst : INT -> Int32
-- dyDst : INT -> Int32
-- lpbi : BITMAPINFOHEADER* optional -> Ptr ()
-- lpBits : void* optional -> Ptr ()
-- xSrc : INT -> Int32
-- ySrc : INT -> Int32
-- dxSrc : INT -> Int32
-- dySrc : INT -> Int32
-- wFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drawdibdraw =
foreign "DrawDibDraw"
(intptr_t @-> (ptr void) @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> (ptr void) @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> uint32_t @-> returning int32_t)
(* hdd : INT_PTR -> intptr_t *)
(* hdc : HDC -> (ptr void) *)
(* xDst : INT -> int32_t *)
(* yDst : INT -> int32_t *)
(* dxDst : INT -> int32_t *)
(* dyDst : INT -> int32_t *)
(* lpbi : BITMAPINFOHEADER* optional -> (ptr void) *)
(* lpBits : void* optional -> (ptr void) *)
(* xSrc : INT -> int32_t *)
(* ySrc : INT -> int32_t *)
(* dxSrc : INT -> int32_t *)
(* dySrc : INT -> int32_t *)
(* wFlags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msvfw32 (t "MSVFW32.dll"))
(cffi:use-foreign-library msvfw32)
(cffi:defcfun ("DrawDibDraw" draw-dib-draw :convention :stdcall) :int32
(hdd :int64) ; INT_PTR
(hdc :pointer) ; HDC
(x-dst :int32) ; INT
(y-dst :int32) ; INT
(dx-dst :int32) ; INT
(dy-dst :int32) ; INT
(lpbi :pointer) ; BITMAPINFOHEADER* optional
(lp-bits :pointer) ; void* optional
(x-src :int32) ; INT
(y-src :int32) ; INT
(dx-src :int32) ; INT
(dy-src :int32) ; INT
(w-flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DrawDibDraw = Win32::API::More->new('MSVFW32',
'BOOL DrawDibDraw(LPARAM hdd, HANDLE hdc, int xDst, int yDst, int dxDst, int dyDst, LPVOID lpbi, LPVOID lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, DWORD wFlags)');
# my $ret = $DrawDibDraw->Call($hdd, $hdc, $xDst, $yDst, $dxDst, $dyDst, $lpbi, $lpBits, $xSrc, $ySrc, $dxSrc, $dySrc, $wFlags);
# hdd : INT_PTR -> LPARAM
# hdc : HDC -> HANDLE
# xDst : INT -> int
# yDst : INT -> int
# dxDst : INT -> int
# dyDst : INT -> int
# lpbi : BITMAPINFOHEADER* optional -> LPVOID
# lpBits : void* optional -> LPVOID
# xSrc : INT -> int
# ySrc : INT -> int
# dxSrc : INT -> int
# dySrc : INT -> int
# wFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型