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