ホーム › Media.MediaFoundation › MFCopyImage
MFCopyImage
関数ストライドを考慮して画像データを行単位でコピーする。
シグネチャ
// MFPlat.dll
#include <windows.h>
HRESULT MFCopyImage(
BYTE* pDest,
INT lDestStride,
const BYTE* pSrc,
INT lSrcStride,
DWORD dwWidthInBytes,
DWORD dwLines
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pDest | BYTE* | out |
| lDestStride | INT | in |
| pSrc | BYTE* | in |
| lSrcStride | INT | in |
| dwWidthInBytes | DWORD | in |
| dwLines | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// MFPlat.dll
#include <windows.h>
HRESULT MFCopyImage(
BYTE* pDest,
INT lDestStride,
const BYTE* pSrc,
INT lSrcStride,
DWORD dwWidthInBytes,
DWORD dwLines
);[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFCopyImage(
IntPtr pDest, // BYTE* out
int lDestStride, // INT
IntPtr pSrc, // BYTE*
int lSrcStride, // INT
uint dwWidthInBytes, // DWORD
uint dwLines // DWORD
);<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFCopyImage(
pDest As IntPtr, ' BYTE* out
lDestStride As Integer, ' INT
pSrc As IntPtr, ' BYTE*
lSrcStride As Integer, ' INT
dwWidthInBytes As UInteger, ' DWORD
dwLines As UInteger ' DWORD
) As Integer
End Function' pDest : BYTE* out
' lDestStride : INT
' pSrc : BYTE*
' lSrcStride : INT
' dwWidthInBytes : DWORD
' dwLines : DWORD
Declare PtrSafe Function MFCopyImage Lib "mfplat" ( _
ByVal pDest As LongPtr, _
ByVal lDestStride As Long, _
ByVal pSrc As LongPtr, _
ByVal lSrcStride As Long, _
ByVal dwWidthInBytes As Long, _
ByVal dwLines As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFCopyImage = ctypes.windll.mfplat.MFCopyImage
MFCopyImage.restype = ctypes.c_int
MFCopyImage.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # pDest : BYTE* out
ctypes.c_int, # lDestStride : INT
ctypes.POINTER(ctypes.c_ubyte), # pSrc : BYTE*
ctypes.c_int, # lSrcStride : INT
wintypes.DWORD, # dwWidthInBytes : DWORD
wintypes.DWORD, # dwLines : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MFPlat.dll')
MFCopyImage = Fiddle::Function.new(
lib['MFCopyImage'],
[
Fiddle::TYPE_VOIDP, # pDest : BYTE* out
Fiddle::TYPE_INT, # lDestStride : INT
Fiddle::TYPE_VOIDP, # pSrc : BYTE*
Fiddle::TYPE_INT, # lSrcStride : INT
-Fiddle::TYPE_INT, # dwWidthInBytes : DWORD
-Fiddle::TYPE_INT, # dwLines : DWORD
],
Fiddle::TYPE_INT)#[link(name = "mfplat")]
extern "system" {
fn MFCopyImage(
pDest: *mut u8, // BYTE* out
lDestStride: i32, // INT
pSrc: *const u8, // BYTE*
lSrcStride: i32, // INT
dwWidthInBytes: u32, // DWORD
dwLines: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MFPlat.dll")]
public static extern int MFCopyImage(IntPtr pDest, int lDestStride, IntPtr pSrc, int lSrcStride, uint dwWidthInBytes, uint dwLines);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFPlat_MFCopyImage' -Namespace Win32 -PassThru
# $api::MFCopyImage(pDest, lDestStride, pSrc, lSrcStride, dwWidthInBytes, dwLines)#uselib "MFPlat.dll"
#func global MFCopyImage "MFCopyImage" sptr, sptr, sptr, sptr, sptr, sptr
; MFCopyImage varptr(pDest), lDestStride, varptr(pSrc), lSrcStride, dwWidthInBytes, dwLines ; 戻り値は stat
; pDest : BYTE* out -> "sptr"
; lDestStride : INT -> "sptr"
; pSrc : BYTE* -> "sptr"
; lSrcStride : INT -> "sptr"
; dwWidthInBytes : DWORD -> "sptr"
; dwLines : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MFPlat.dll" #cfunc global MFCopyImage "MFCopyImage" var, int, var, int, int, int ; res = MFCopyImage(pDest, lDestStride, pSrc, lSrcStride, dwWidthInBytes, dwLines) ; pDest : BYTE* out -> "var" ; lDestStride : INT -> "int" ; pSrc : BYTE* -> "var" ; lSrcStride : INT -> "int" ; dwWidthInBytes : DWORD -> "int" ; dwLines : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MFPlat.dll" #cfunc global MFCopyImage "MFCopyImage" sptr, int, sptr, int, int, int ; res = MFCopyImage(varptr(pDest), lDestStride, varptr(pSrc), lSrcStride, dwWidthInBytes, dwLines) ; pDest : BYTE* out -> "sptr" ; lDestStride : INT -> "int" ; pSrc : BYTE* -> "sptr" ; lSrcStride : INT -> "int" ; dwWidthInBytes : DWORD -> "int" ; dwLines : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT MFCopyImage(BYTE* pDest, INT lDestStride, BYTE* pSrc, INT lSrcStride, DWORD dwWidthInBytes, DWORD dwLines) #uselib "MFPlat.dll" #cfunc global MFCopyImage "MFCopyImage" var, int, var, int, int, int ; res = MFCopyImage(pDest, lDestStride, pSrc, lSrcStride, dwWidthInBytes, dwLines) ; pDest : BYTE* out -> "var" ; lDestStride : INT -> "int" ; pSrc : BYTE* -> "var" ; lSrcStride : INT -> "int" ; dwWidthInBytes : DWORD -> "int" ; dwLines : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT MFCopyImage(BYTE* pDest, INT lDestStride, BYTE* pSrc, INT lSrcStride, DWORD dwWidthInBytes, DWORD dwLines) #uselib "MFPlat.dll" #cfunc global MFCopyImage "MFCopyImage" intptr, int, intptr, int, int, int ; res = MFCopyImage(varptr(pDest), lDestStride, varptr(pSrc), lSrcStride, dwWidthInBytes, dwLines) ; pDest : BYTE* out -> "intptr" ; lDestStride : INT -> "int" ; pSrc : BYTE* -> "intptr" ; lSrcStride : INT -> "int" ; dwWidthInBytes : DWORD -> "int" ; dwLines : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mfplat = windows.NewLazySystemDLL("MFPlat.dll")
procMFCopyImage = mfplat.NewProc("MFCopyImage")
)
// pDest (BYTE* out), lDestStride (INT), pSrc (BYTE*), lSrcStride (INT), dwWidthInBytes (DWORD), dwLines (DWORD)
r1, _, err := procMFCopyImage.Call(
uintptr(pDest),
uintptr(lDestStride),
uintptr(pSrc),
uintptr(lSrcStride),
uintptr(dwWidthInBytes),
uintptr(dwLines),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFCopyImage(
pDest: Pointer; // BYTE* out
lDestStride: Integer; // INT
pSrc: Pointer; // BYTE*
lSrcStride: Integer; // INT
dwWidthInBytes: DWORD; // DWORD
dwLines: DWORD // DWORD
): Integer; stdcall;
external 'MFPlat.dll' name 'MFCopyImage';result := DllCall("MFPlat\MFCopyImage"
, "Ptr", pDest ; BYTE* out
, "Int", lDestStride ; INT
, "Ptr", pSrc ; BYTE*
, "Int", lSrcStride ; INT
, "UInt", dwWidthInBytes ; DWORD
, "UInt", dwLines ; DWORD
, "Int") ; return: HRESULT●MFCopyImage(pDest, lDestStride, pSrc, lSrcStride, dwWidthInBytes, dwLines) = DLL("MFPlat.dll", "int MFCopyImage(void*, int, void*, int, dword, dword)")
# 呼び出し: MFCopyImage(pDest, lDestStride, pSrc, lSrcStride, dwWidthInBytes, dwLines)
# pDest : BYTE* out -> "void*"
# lDestStride : INT -> "int"
# pSrc : BYTE* -> "void*"
# lSrcStride : INT -> "int"
# dwWidthInBytes : DWORD -> "dword"
# dwLines : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。