ホーム › Graphics.Gdi › CreateDIBitmap
CreateDIBitmap
関数DIB情報からデバイス依存ビットマップを作成する。
シグネチャ
// GDI32.dll
#include <windows.h>
HBITMAP CreateDIBitmap(
HDC hdc,
const BITMAPINFOHEADER* pbmih, // optional
DWORD flInit,
const void* pjBits, // optional
const BITMAPINFO* pbmi, // optional
DIB_USAGE iUsage
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| pbmih | BITMAPINFOHEADER* | inoptional |
| flInit | DWORD | in |
| pjBits | void* | inoptional |
| pbmi | BITMAPINFO* | inoptional |
| iUsage | DIB_USAGE | in |
戻り値の型: HBITMAP
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
HBITMAP CreateDIBitmap(
HDC hdc,
const BITMAPINFOHEADER* pbmih, // optional
DWORD flInit,
const void* pjBits, // optional
const BITMAPINFO* pbmi, // optional
DIB_USAGE iUsage
);[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr CreateDIBitmap(
IntPtr hdc, // HDC
IntPtr pbmih, // BITMAPINFOHEADER* optional
uint flInit, // DWORD
IntPtr pjBits, // void* optional
IntPtr pbmi, // BITMAPINFO* optional
uint iUsage // DIB_USAGE
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function CreateDIBitmap(
hdc As IntPtr, ' HDC
pbmih As IntPtr, ' BITMAPINFOHEADER* optional
flInit As UInteger, ' DWORD
pjBits As IntPtr, ' void* optional
pbmi As IntPtr, ' BITMAPINFO* optional
iUsage As UInteger ' DIB_USAGE
) As IntPtr
End Function' hdc : HDC
' pbmih : BITMAPINFOHEADER* optional
' flInit : DWORD
' pjBits : void* optional
' pbmi : BITMAPINFO* optional
' iUsage : DIB_USAGE
Declare PtrSafe Function CreateDIBitmap Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal pbmih As LongPtr, _
ByVal flInit As Long, _
ByVal pjBits As LongPtr, _
ByVal pbmi As LongPtr, _
ByVal iUsage As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateDIBitmap = ctypes.windll.gdi32.CreateDIBitmap
CreateDIBitmap.restype = ctypes.c_void_p
CreateDIBitmap.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # pbmih : BITMAPINFOHEADER* optional
wintypes.DWORD, # flInit : DWORD
ctypes.POINTER(None), # pjBits : void* optional
ctypes.c_void_p, # pbmi : BITMAPINFO* optional
wintypes.DWORD, # iUsage : DIB_USAGE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
CreateDIBitmap = Fiddle::Function.new(
lib['CreateDIBitmap'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # pbmih : BITMAPINFOHEADER* optional
-Fiddle::TYPE_INT, # flInit : DWORD
Fiddle::TYPE_VOIDP, # pjBits : void* optional
Fiddle::TYPE_VOIDP, # pbmi : BITMAPINFO* optional
-Fiddle::TYPE_INT, # iUsage : DIB_USAGE
],
Fiddle::TYPE_VOIDP)#[link(name = "gdi32")]
extern "system" {
fn CreateDIBitmap(
hdc: *mut core::ffi::c_void, // HDC
pbmih: *const BITMAPINFOHEADER, // BITMAPINFOHEADER* optional
flInit: u32, // DWORD
pjBits: *const (), // void* optional
pbmi: *const BITMAPINFO, // BITMAPINFO* optional
iUsage: u32 // DIB_USAGE
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll")]
public static extern IntPtr CreateDIBitmap(IntPtr hdc, IntPtr pbmih, uint flInit, IntPtr pjBits, IntPtr pbmi, uint iUsage);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreateDIBitmap' -Namespace Win32 -PassThru
# $api::CreateDIBitmap(hdc, pbmih, flInit, pjBits, pbmi, iUsage)#uselib "GDI32.dll"
#func global CreateDIBitmap "CreateDIBitmap" sptr, sptr, sptr, sptr, sptr, sptr
; CreateDIBitmap hdc, varptr(pbmih), flInit, pjBits, varptr(pbmi), iUsage ; 戻り値は stat
; hdc : HDC -> "sptr"
; pbmih : BITMAPINFOHEADER* optional -> "sptr"
; flInit : DWORD -> "sptr"
; pjBits : void* optional -> "sptr"
; pbmi : BITMAPINFO* optional -> "sptr"
; iUsage : DIB_USAGE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global CreateDIBitmap "CreateDIBitmap" sptr, var, int, sptr, var, int ; res = CreateDIBitmap(hdc, pbmih, flInit, pjBits, pbmi, iUsage) ; hdc : HDC -> "sptr" ; pbmih : BITMAPINFOHEADER* optional -> "var" ; flInit : DWORD -> "int" ; pjBits : void* optional -> "sptr" ; pbmi : BITMAPINFO* optional -> "var" ; iUsage : DIB_USAGE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global CreateDIBitmap "CreateDIBitmap" sptr, sptr, int, sptr, sptr, int ; res = CreateDIBitmap(hdc, varptr(pbmih), flInit, pjBits, varptr(pbmi), iUsage) ; hdc : HDC -> "sptr" ; pbmih : BITMAPINFOHEADER* optional -> "sptr" ; flInit : DWORD -> "int" ; pjBits : void* optional -> "sptr" ; pbmi : BITMAPINFO* optional -> "sptr" ; iUsage : DIB_USAGE -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HBITMAP CreateDIBitmap(HDC hdc, BITMAPINFOHEADER* pbmih, DWORD flInit, void* pjBits, BITMAPINFO* pbmi, DIB_USAGE iUsage) #uselib "GDI32.dll" #cfunc global CreateDIBitmap "CreateDIBitmap" intptr, var, int, intptr, var, int ; res = CreateDIBitmap(hdc, pbmih, flInit, pjBits, pbmi, iUsage) ; hdc : HDC -> "intptr" ; pbmih : BITMAPINFOHEADER* optional -> "var" ; flInit : DWORD -> "int" ; pjBits : void* optional -> "intptr" ; pbmi : BITMAPINFO* optional -> "var" ; iUsage : DIB_USAGE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HBITMAP CreateDIBitmap(HDC hdc, BITMAPINFOHEADER* pbmih, DWORD flInit, void* pjBits, BITMAPINFO* pbmi, DIB_USAGE iUsage) #uselib "GDI32.dll" #cfunc global CreateDIBitmap "CreateDIBitmap" intptr, intptr, int, intptr, intptr, int ; res = CreateDIBitmap(hdc, varptr(pbmih), flInit, pjBits, varptr(pbmi), iUsage) ; hdc : HDC -> "intptr" ; pbmih : BITMAPINFOHEADER* optional -> "intptr" ; flInit : DWORD -> "int" ; pjBits : void* optional -> "intptr" ; pbmi : BITMAPINFO* optional -> "intptr" ; iUsage : DIB_USAGE -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procCreateDIBitmap = gdi32.NewProc("CreateDIBitmap")
)
// hdc (HDC), pbmih (BITMAPINFOHEADER* optional), flInit (DWORD), pjBits (void* optional), pbmi (BITMAPINFO* optional), iUsage (DIB_USAGE)
r1, _, err := procCreateDIBitmap.Call(
uintptr(hdc),
uintptr(pbmih),
uintptr(flInit),
uintptr(pjBits),
uintptr(pbmi),
uintptr(iUsage),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HBITMAPfunction CreateDIBitmap(
hdc: THandle; // HDC
pbmih: Pointer; // BITMAPINFOHEADER* optional
flInit: DWORD; // DWORD
pjBits: Pointer; // void* optional
pbmi: Pointer; // BITMAPINFO* optional
iUsage: DWORD // DIB_USAGE
): THandle; stdcall;
external 'GDI32.dll' name 'CreateDIBitmap';result := DllCall("GDI32\CreateDIBitmap"
, "Ptr", hdc ; HDC
, "Ptr", pbmih ; BITMAPINFOHEADER* optional
, "UInt", flInit ; DWORD
, "Ptr", pjBits ; void* optional
, "Ptr", pbmi ; BITMAPINFO* optional
, "UInt", iUsage ; DIB_USAGE
, "Ptr") ; return: HBITMAP●CreateDIBitmap(hdc, pbmih, flInit, pjBits, pbmi, iUsage) = DLL("GDI32.dll", "void* CreateDIBitmap(void*, void*, dword, void*, void*, dword)")
# 呼び出し: CreateDIBitmap(hdc, pbmih, flInit, pjBits, pbmi, iUsage)
# hdc : HDC -> "void*"
# pbmih : BITMAPINFOHEADER* optional -> "void*"
# flInit : DWORD -> "dword"
# pjBits : void* optional -> "void*"
# pbmi : BITMAPINFO* optional -> "void*"
# iUsage : DIB_USAGE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。