ホーム › Graphics.GdiPlus › GdipCreateBitmapFromResource
GdipCreateBitmapFromResource
関数リソースからビットマップオブジェクトを作成する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipCreateBitmapFromResource(
HINSTANCE hInstance,
LPCWSTR lpBitmapName,
GpBitmap** bitmap
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hInstance | HINSTANCE | in | リソースを含むモジュールのインスタンスハンドル(HINSTANCE)。 |
| lpBitmapName | LPCWSTR | in | ビットマップリソースの名前を示すワイド文字列。MAKEINTRESOURCEのID指定も可。 |
| bitmap | GpBitmap** | inout | 生成されたGpBitmapオブジェクトを受け取る出力先ポインタのアドレス。 |
戻り値の型: 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)。const std = @import("std");
extern "gdiplus" fn GdipCreateBitmapFromResource(
hInstance: ?*anyopaque, // HINSTANCE
lpBitmapName: [*c]const u16, // LPCWSTR
bitmap: [*c][*c]GpBitmap // GpBitmap** in/out
) callconv(std.os.windows.WINAPI) i32;proc GdipCreateBitmapFromResource(
hInstance: pointer, # HINSTANCE
lpBitmapName: WideCString, # LPCWSTR
bitmap: ptr GpBitmap # GpBitmap** in/out
): int32 {.importc: "GdipCreateBitmapFromResource", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipCreateBitmapFromResource(
void* hInstance, // HINSTANCE
const(wchar)* lpBitmapName, // LPCWSTR
GpBitmap** bitmap // GpBitmap** in/out
);ccall((:GdipCreateBitmapFromResource, "gdiplus.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Ptr{GpBitmap}),
hInstance, lpBitmapName, bitmap)
# hInstance : HINSTANCE -> Ptr{Cvoid}
# lpBitmapName : LPCWSTR -> Cwstring
# bitmap : GpBitmap** in/out -> Ptr{GpBitmap}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipCreateBitmapFromResource(
void* hInstance,
const uint16_t* lpBitmapName,
void* bitmap);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap)
-- hInstance : HINSTANCE
-- lpBitmapName : LPCWSTR
-- bitmap : GpBitmap** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipCreateBitmapFromResource = lib.func('__stdcall', 'GdipCreateBitmapFromResource', 'int32_t', ['void *', 'str16', 'void *']);
// GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap)
// hInstance : HINSTANCE -> 'void *'
// lpBitmapName : LPCWSTR -> 'str16'
// bitmap : GpBitmap** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipCreateBitmapFromResource: { parameters: ["pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap)
// hInstance : HINSTANCE -> "pointer"
// lpBitmapName : LPCWSTR -> "buffer"
// bitmap : GpBitmap** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipCreateBitmapFromResource(
void* hInstance,
const uint16_t* lpBitmapName,
void* bitmap);
C, "gdiplus.dll");
// $ffi->GdipCreateBitmapFromResource(hInstance, lpBitmapName, bitmap);
// hInstance : HINSTANCE
// lpBitmapName : LPCWSTR
// bitmap : GpBitmap** in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Gdiplus extends StdCallLibrary {
Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class);
int GdipCreateBitmapFromResource(
Pointer hInstance, // HINSTANCE
WString lpBitmapName, // LPCWSTR
Pointer bitmap // GpBitmap** in/out
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipCreateBitmapFromResource = GdipCreateBitmapFromResource(
hInstance : Void*, # HINSTANCE
lpBitmapName : UInt16*, # LPCWSTR
bitmap : GpBitmap** # GpBitmap** in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipCreateBitmapFromResourceNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
typedef GdipCreateBitmapFromResourceDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
final GdipCreateBitmapFromResource = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipCreateBitmapFromResourceNative, GdipCreateBitmapFromResourceDart>('GdipCreateBitmapFromResource');
// hInstance : HINSTANCE -> Pointer<Void>
// lpBitmapName : LPCWSTR -> Pointer<Utf16>
// bitmap : GpBitmap** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipCreateBitmapFromResource(
hInstance: THandle; // HINSTANCE
lpBitmapName: PWideChar; // LPCWSTR
bitmap: Pointer // GpBitmap** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreateBitmapFromResource';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipCreateBitmapFromResource"
c_GdipCreateBitmapFromResource :: Ptr () -> CWString -> Ptr () -> IO Int32
-- hInstance : HINSTANCE -> Ptr ()
-- lpBitmapName : LPCWSTR -> CWString
-- bitmap : GpBitmap** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipcreatebitmapfromresource =
foreign "GdipCreateBitmapFromResource"
((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* hInstance : HINSTANCE -> (ptr void) *)
(* lpBitmapName : LPCWSTR -> (ptr uint16_t) *)
(* bitmap : GpBitmap** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipCreateBitmapFromResource" gdip-create-bitmap-from-resource :convention :stdcall) :int32
(h-instance :pointer) ; HINSTANCE
(lp-bitmap-name (:string :encoding :utf-16le)) ; LPCWSTR
(bitmap :pointer)) ; GpBitmap** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipCreateBitmapFromResource = Win32::API::More->new('gdiplus',
'int GdipCreateBitmapFromResource(HANDLE hInstance, LPCWSTR lpBitmapName, LPVOID bitmap)');
# my $ret = $GdipCreateBitmapFromResource->Call($hInstance, $lpBitmapName, $bitmap);
# hInstance : HINSTANCE -> HANDLE
# lpBitmapName : LPCWSTR -> LPCWSTR
# bitmap : GpBitmap** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型