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