ホーム › Graphics.Imaging › WICCreateBitmapFromSectionEx
WICCreateBitmapFromSectionEx
関数アクセスレベルを指定しセクションからWICビットマップを作成する。
シグネチャ
// WindowsCodecs.dll
#include <windows.h>
HRESULT WICCreateBitmapFromSectionEx(
DWORD width,
DWORD height,
GUID* pixelFormat,
HANDLE hSection,
DWORD stride,
DWORD offset,
WICSectionAccessLevel desiredAccessLevel,
IWICBitmap** ppIBitmap
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| width | DWORD | in |
| height | DWORD | in |
| pixelFormat | GUID* | in |
| hSection | HANDLE | in |
| stride | DWORD | in |
| offset | DWORD | in |
| desiredAccessLevel | WICSectionAccessLevel | in |
| ppIBitmap | IWICBitmap** | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// WindowsCodecs.dll
#include <windows.h>
HRESULT WICCreateBitmapFromSectionEx(
DWORD width,
DWORD height,
GUID* pixelFormat,
HANDLE hSection,
DWORD stride,
DWORD offset,
WICSectionAccessLevel desiredAccessLevel,
IWICBitmap** ppIBitmap
);[DllImport("WindowsCodecs.dll", ExactSpelling = true)]
static extern int WICCreateBitmapFromSectionEx(
uint width, // DWORD
uint height, // DWORD
ref Guid pixelFormat, // GUID*
IntPtr hSection, // HANDLE
uint stride, // DWORD
uint offset, // DWORD
int desiredAccessLevel, // WICSectionAccessLevel
IntPtr ppIBitmap // IWICBitmap** out
);<DllImport("WindowsCodecs.dll", ExactSpelling:=True)>
Public Shared Function WICCreateBitmapFromSectionEx(
width As UInteger, ' DWORD
height As UInteger, ' DWORD
ByRef pixelFormat As Guid, ' GUID*
hSection As IntPtr, ' HANDLE
stride As UInteger, ' DWORD
offset As UInteger, ' DWORD
desiredAccessLevel As Integer, ' WICSectionAccessLevel
ppIBitmap As IntPtr ' IWICBitmap** out
) As Integer
End Function' width : DWORD
' height : DWORD
' pixelFormat : GUID*
' hSection : HANDLE
' stride : DWORD
' offset : DWORD
' desiredAccessLevel : WICSectionAccessLevel
' ppIBitmap : IWICBitmap** out
Declare PtrSafe Function WICCreateBitmapFromSectionEx Lib "windowscodecs" ( _
ByVal width As Long, _
ByVal height As Long, _
ByVal pixelFormat As LongPtr, _
ByVal hSection As LongPtr, _
ByVal stride As Long, _
ByVal offset As Long, _
ByVal desiredAccessLevel As Long, _
ByVal ppIBitmap As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WICCreateBitmapFromSectionEx = ctypes.windll.windowscodecs.WICCreateBitmapFromSectionEx
WICCreateBitmapFromSectionEx.restype = ctypes.c_int
WICCreateBitmapFromSectionEx.argtypes = [
wintypes.DWORD, # width : DWORD
wintypes.DWORD, # height : DWORD
ctypes.c_void_p, # pixelFormat : GUID*
wintypes.HANDLE, # hSection : HANDLE
wintypes.DWORD, # stride : DWORD
wintypes.DWORD, # offset : DWORD
ctypes.c_int, # desiredAccessLevel : WICSectionAccessLevel
ctypes.c_void_p, # ppIBitmap : IWICBitmap** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WindowsCodecs.dll')
WICCreateBitmapFromSectionEx = Fiddle::Function.new(
lib['WICCreateBitmapFromSectionEx'],
[
-Fiddle::TYPE_INT, # width : DWORD
-Fiddle::TYPE_INT, # height : DWORD
Fiddle::TYPE_VOIDP, # pixelFormat : GUID*
Fiddle::TYPE_VOIDP, # hSection : HANDLE
-Fiddle::TYPE_INT, # stride : DWORD
-Fiddle::TYPE_INT, # offset : DWORD
Fiddle::TYPE_INT, # desiredAccessLevel : WICSectionAccessLevel
Fiddle::TYPE_VOIDP, # ppIBitmap : IWICBitmap** out
],
Fiddle::TYPE_INT)#[link(name = "windowscodecs")]
extern "system" {
fn WICCreateBitmapFromSectionEx(
width: u32, // DWORD
height: u32, // DWORD
pixelFormat: *mut GUID, // GUID*
hSection: *mut core::ffi::c_void, // HANDLE
stride: u32, // DWORD
offset: u32, // DWORD
desiredAccessLevel: i32, // WICSectionAccessLevel
ppIBitmap: *mut *mut core::ffi::c_void // IWICBitmap** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WindowsCodecs.dll")]
public static extern int WICCreateBitmapFromSectionEx(uint width, uint height, ref Guid pixelFormat, IntPtr hSection, uint stride, uint offset, int desiredAccessLevel, IntPtr ppIBitmap);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WindowsCodecs_WICCreateBitmapFromSectionEx' -Namespace Win32 -PassThru
# $api::WICCreateBitmapFromSectionEx(width, height, pixelFormat, hSection, stride, offset, desiredAccessLevel, ppIBitmap)#uselib "WindowsCodecs.dll"
#func global WICCreateBitmapFromSectionEx "WICCreateBitmapFromSectionEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WICCreateBitmapFromSectionEx width, height, varptr(pixelFormat), hSection, stride, offset, desiredAccessLevel, ppIBitmap ; 戻り値は stat
; width : DWORD -> "sptr"
; height : DWORD -> "sptr"
; pixelFormat : GUID* -> "sptr"
; hSection : HANDLE -> "sptr"
; stride : DWORD -> "sptr"
; offset : DWORD -> "sptr"
; desiredAccessLevel : WICSectionAccessLevel -> "sptr"
; ppIBitmap : IWICBitmap** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WindowsCodecs.dll" #cfunc global WICCreateBitmapFromSectionEx "WICCreateBitmapFromSectionEx" int, int, var, sptr, int, int, int, sptr ; res = WICCreateBitmapFromSectionEx(width, height, pixelFormat, hSection, stride, offset, desiredAccessLevel, ppIBitmap) ; width : DWORD -> "int" ; height : DWORD -> "int" ; pixelFormat : GUID* -> "var" ; hSection : HANDLE -> "sptr" ; stride : DWORD -> "int" ; offset : DWORD -> "int" ; desiredAccessLevel : WICSectionAccessLevel -> "int" ; ppIBitmap : IWICBitmap** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WindowsCodecs.dll" #cfunc global WICCreateBitmapFromSectionEx "WICCreateBitmapFromSectionEx" int, int, sptr, sptr, int, int, int, sptr ; res = WICCreateBitmapFromSectionEx(width, height, varptr(pixelFormat), hSection, stride, offset, desiredAccessLevel, ppIBitmap) ; width : DWORD -> "int" ; height : DWORD -> "int" ; pixelFormat : GUID* -> "sptr" ; hSection : HANDLE -> "sptr" ; stride : DWORD -> "int" ; offset : DWORD -> "int" ; desiredAccessLevel : WICSectionAccessLevel -> "int" ; ppIBitmap : IWICBitmap** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WICCreateBitmapFromSectionEx(DWORD width, DWORD height, GUID* pixelFormat, HANDLE hSection, DWORD stride, DWORD offset, WICSectionAccessLevel desiredAccessLevel, IWICBitmap** ppIBitmap) #uselib "WindowsCodecs.dll" #cfunc global WICCreateBitmapFromSectionEx "WICCreateBitmapFromSectionEx" int, int, var, intptr, int, int, int, intptr ; res = WICCreateBitmapFromSectionEx(width, height, pixelFormat, hSection, stride, offset, desiredAccessLevel, ppIBitmap) ; width : DWORD -> "int" ; height : DWORD -> "int" ; pixelFormat : GUID* -> "var" ; hSection : HANDLE -> "intptr" ; stride : DWORD -> "int" ; offset : DWORD -> "int" ; desiredAccessLevel : WICSectionAccessLevel -> "int" ; ppIBitmap : IWICBitmap** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WICCreateBitmapFromSectionEx(DWORD width, DWORD height, GUID* pixelFormat, HANDLE hSection, DWORD stride, DWORD offset, WICSectionAccessLevel desiredAccessLevel, IWICBitmap** ppIBitmap) #uselib "WindowsCodecs.dll" #cfunc global WICCreateBitmapFromSectionEx "WICCreateBitmapFromSectionEx" int, int, intptr, intptr, int, int, int, intptr ; res = WICCreateBitmapFromSectionEx(width, height, varptr(pixelFormat), hSection, stride, offset, desiredAccessLevel, ppIBitmap) ; width : DWORD -> "int" ; height : DWORD -> "int" ; pixelFormat : GUID* -> "intptr" ; hSection : HANDLE -> "intptr" ; stride : DWORD -> "int" ; offset : DWORD -> "int" ; desiredAccessLevel : WICSectionAccessLevel -> "int" ; ppIBitmap : IWICBitmap** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
windowscodecs = windows.NewLazySystemDLL("WindowsCodecs.dll")
procWICCreateBitmapFromSectionEx = windowscodecs.NewProc("WICCreateBitmapFromSectionEx")
)
// width (DWORD), height (DWORD), pixelFormat (GUID*), hSection (HANDLE), stride (DWORD), offset (DWORD), desiredAccessLevel (WICSectionAccessLevel), ppIBitmap (IWICBitmap** out)
r1, _, err := procWICCreateBitmapFromSectionEx.Call(
uintptr(width),
uintptr(height),
uintptr(pixelFormat),
uintptr(hSection),
uintptr(stride),
uintptr(offset),
uintptr(desiredAccessLevel),
uintptr(ppIBitmap),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WICCreateBitmapFromSectionEx(
width: DWORD; // DWORD
height: DWORD; // DWORD
pixelFormat: PGUID; // GUID*
hSection: THandle; // HANDLE
stride: DWORD; // DWORD
offset: DWORD; // DWORD
desiredAccessLevel: Integer; // WICSectionAccessLevel
ppIBitmap: Pointer // IWICBitmap** out
): Integer; stdcall;
external 'WindowsCodecs.dll' name 'WICCreateBitmapFromSectionEx';result := DllCall("WindowsCodecs\WICCreateBitmapFromSectionEx"
, "UInt", width ; DWORD
, "UInt", height ; DWORD
, "Ptr", pixelFormat ; GUID*
, "Ptr", hSection ; HANDLE
, "UInt", stride ; DWORD
, "UInt", offset ; DWORD
, "Int", desiredAccessLevel ; WICSectionAccessLevel
, "Ptr", ppIBitmap ; IWICBitmap** out
, "Int") ; return: HRESULT●WICCreateBitmapFromSectionEx(width, height, pixelFormat, hSection, stride, offset, desiredAccessLevel, ppIBitmap) = DLL("WindowsCodecs.dll", "int WICCreateBitmapFromSectionEx(dword, dword, void*, void*, dword, dword, int, void*)")
# 呼び出し: WICCreateBitmapFromSectionEx(width, height, pixelFormat, hSection, stride, offset, desiredAccessLevel, ppIBitmap)
# width : DWORD -> "dword"
# height : DWORD -> "dword"
# pixelFormat : GUID* -> "void*"
# hSection : HANDLE -> "void*"
# stride : DWORD -> "dword"
# offset : DWORD -> "dword"
# desiredAccessLevel : WICSectionAccessLevel -> "int"
# ppIBitmap : IWICBitmap** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。