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