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