ホーム › Graphics.GdiPlus › GdipCreateBitmapFromResource
GdipCreateBitmapFromResource
関数リソースからビットマップオブジェクトを作成する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipCreateBitmapFromResource(
HINSTANCE hInstance,
LPCWSTR lpBitmapName,
GpBitmap** bitmap
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInstance | HINSTANCE | in |
| lpBitmapName | LPCWSTR | in |
| bitmap | GpBitmap** | inout |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipCreateBitmapFromResource(
HINSTANCE hInstance,
LPCWSTR lpBitmapName,
GpBitmap** bitmap
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipCreateBitmapFromResource(
IntPtr hInstance, // HINSTANCE
[MarshalAs(UnmanagedType.LPWStr)] string lpBitmapName, // LPCWSTR
IntPtr bitmap // GpBitmap** in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipCreateBitmapFromResource(
hInstance As IntPtr, ' HINSTANCE
<MarshalAs(UnmanagedType.LPWStr)> lpBitmapName As String, ' LPCWSTR
bitmap As IntPtr ' GpBitmap** in/out
) As Integer
End Function' hInstance : HINSTANCE
' lpBitmapName : LPCWSTR
' bitmap : GpBitmap** in/out
Declare PtrSafe Function GdipCreateBitmapFromResource Lib "gdiplus" ( _
ByVal hInstance As LongPtr, _
ByVal lpBitmapName 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
GdipCreateBitmapFromResource = ctypes.windll.gdiplus.GdipCreateBitmapFromResource
GdipCreateBitmapFromResource.restype = ctypes.c_int
GdipCreateBitmapFromResource.argtypes = [
wintypes.HANDLE, # hInstance : HINSTANCE
wintypes.LPCWSTR, # lpBitmapName : LPCWSTR
ctypes.c_void_p, # bitmap : GpBitmap** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipCreateBitmapFromResource = Fiddle::Function.new(
lib['GdipCreateBitmapFromResource'],
[
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE
Fiddle::TYPE_VOIDP, # lpBitmapName : LPCWSTR
Fiddle::TYPE_VOIDP, # bitmap : GpBitmap** in/out
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipCreateBitmapFromResource(
hInstance: *mut core::ffi::c_void, // HINSTANCE
lpBitmapName: *const u16, // LPCWSTR
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 GdipCreateBitmapFromResource(IntPtr hInstance, [MarshalAs(UnmanagedType.LPWStr)] string lpBitmapName, IntPtr bitmap);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreateBitmapFromResource' -Namespace Win32 -PassThru
# $api::GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap)#uselib "gdiplus.dll"
#func global GdipCreateBitmapFromResource "GdipCreateBitmapFromResource" sptr, sptr, sptr
; GdipCreateBitmapFromResource hInstance, lpBitmapName, varptr(bitmap) ; 戻り値は stat
; hInstance : HINSTANCE -> "sptr"
; lpBitmapName : LPCWSTR -> "sptr"
; bitmap : GpBitmap** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipCreateBitmapFromResource "GdipCreateBitmapFromResource" sptr, wstr, var ; res = GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap) ; hInstance : HINSTANCE -> "sptr" ; lpBitmapName : LPCWSTR -> "wstr" ; bitmap : GpBitmap** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipCreateBitmapFromResource "GdipCreateBitmapFromResource" sptr, wstr, sptr ; res = GdipCreateBitmapFromResource(hInstance, lpBitmapName, varptr(bitmap)) ; hInstance : HINSTANCE -> "sptr" ; lpBitmapName : LPCWSTR -> "wstr" ; bitmap : GpBitmap** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipCreateBitmapFromResource(HINSTANCE hInstance, LPCWSTR lpBitmapName, GpBitmap** bitmap) #uselib "gdiplus.dll" #cfunc global GdipCreateBitmapFromResource "GdipCreateBitmapFromResource" intptr, wstr, var ; res = GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap) ; hInstance : HINSTANCE -> "intptr" ; lpBitmapName : LPCWSTR -> "wstr" ; bitmap : GpBitmap** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipCreateBitmapFromResource(HINSTANCE hInstance, LPCWSTR lpBitmapName, GpBitmap** bitmap) #uselib "gdiplus.dll" #cfunc global GdipCreateBitmapFromResource "GdipCreateBitmapFromResource" intptr, wstr, intptr ; res = GdipCreateBitmapFromResource(hInstance, lpBitmapName, varptr(bitmap)) ; hInstance : HINSTANCE -> "intptr" ; lpBitmapName : LPCWSTR -> "wstr" ; bitmap : GpBitmap** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipCreateBitmapFromResource = gdiplus.NewProc("GdipCreateBitmapFromResource")
)
// hInstance (HINSTANCE), lpBitmapName (LPCWSTR), bitmap (GpBitmap** in/out)
r1, _, err := procGdipCreateBitmapFromResource.Call(
uintptr(hInstance),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpBitmapName))),
uintptr(bitmap),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipCreateBitmapFromResource(
hInstance: THandle; // HINSTANCE
lpBitmapName: PWideChar; // LPCWSTR
bitmap: Pointer // GpBitmap** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreateBitmapFromResource';result := DllCall("gdiplus\GdipCreateBitmapFromResource"
, "Ptr", hInstance ; HINSTANCE
, "WStr", lpBitmapName ; LPCWSTR
, "Ptr", bitmap ; GpBitmap** in/out
, "Int") ; return: Status●GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap) = DLL("gdiplus.dll", "int GdipCreateBitmapFromResource(void*, char*, void*)")
# 呼び出し: GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap)
# hInstance : HINSTANCE -> "void*"
# lpBitmapName : LPCWSTR -> "char*"
# bitmap : GpBitmap** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。