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