Win32 API 日本語リファレンス
ホームUI.ColorSystem › CheckColorsInGamut

CheckColorsInGamut

関数
指定色がデバイスの色域内にあるか確認する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll
#include <windows.h>

BOOL CheckColorsInGamut(
    HDC hdc,
    RGBTRIPLE* lpRGBTriple,
    void* dlpBuffer,
    DWORD nCount
);

パラメーター

名前方向
hdcHDCin
lpRGBTripleRGBTRIPLE*in
dlpBuffervoid*out
nCountDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// GDI32.dll
#include <windows.h>

BOOL CheckColorsInGamut(
    HDC hdc,
    RGBTRIPLE* lpRGBTriple,
    void* dlpBuffer,
    DWORD nCount
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool CheckColorsInGamut(
    IntPtr hdc,   // HDC
    IntPtr lpRGBTriple,   // RGBTRIPLE*
    IntPtr dlpBuffer,   // void* out
    uint nCount   // DWORD
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function CheckColorsInGamut(
    hdc As IntPtr,   ' HDC
    lpRGBTriple As IntPtr,   ' RGBTRIPLE*
    dlpBuffer As IntPtr,   ' void* out
    nCount As UInteger   ' DWORD
) As Boolean
End Function
' hdc : HDC
' lpRGBTriple : RGBTRIPLE*
' dlpBuffer : void* out
' nCount : DWORD
Declare PtrSafe Function CheckColorsInGamut Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal lpRGBTriple As LongPtr, _
    ByVal dlpBuffer As LongPtr, _
    ByVal nCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CheckColorsInGamut = ctypes.windll.gdi32.CheckColorsInGamut
CheckColorsInGamut.restype = wintypes.BOOL
CheckColorsInGamut.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_void_p,  # lpRGBTriple : RGBTRIPLE*
    ctypes.POINTER(None),  # dlpBuffer : void* out
    wintypes.DWORD,  # nCount : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
CheckColorsInGamut = Fiddle::Function.new(
  lib['CheckColorsInGamut'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_VOIDP,  # lpRGBTriple : RGBTRIPLE*
    Fiddle::TYPE_VOIDP,  # dlpBuffer : void* out
    -Fiddle::TYPE_INT,  # nCount : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn CheckColorsInGamut(
        hdc: *mut core::ffi::c_void,  // HDC
        lpRGBTriple: *mut RGBTRIPLE,  // RGBTRIPLE*
        dlpBuffer: *mut (),  // void* out
        nCount: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool CheckColorsInGamut(IntPtr hdc, IntPtr lpRGBTriple, IntPtr dlpBuffer, uint nCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CheckColorsInGamut' -Namespace Win32 -PassThru
# $api::CheckColorsInGamut(hdc, lpRGBTriple, dlpBuffer, nCount)
#uselib "GDI32.dll"
#func global CheckColorsInGamut "CheckColorsInGamut" sptr, sptr, sptr, sptr
; CheckColorsInGamut hdc, varptr(lpRGBTriple), dlpBuffer, nCount   ; 戻り値は stat
; hdc : HDC -> "sptr"
; lpRGBTriple : RGBTRIPLE* -> "sptr"
; dlpBuffer : void* out -> "sptr"
; nCount : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global CheckColorsInGamut "CheckColorsInGamut" sptr, var, sptr, int
; res = CheckColorsInGamut(hdc, lpRGBTriple, dlpBuffer, nCount)
; hdc : HDC -> "sptr"
; lpRGBTriple : RGBTRIPLE* -> "var"
; dlpBuffer : void* out -> "sptr"
; nCount : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL CheckColorsInGamut(HDC hdc, RGBTRIPLE* lpRGBTriple, void* dlpBuffer, DWORD nCount)
#uselib "GDI32.dll"
#cfunc global CheckColorsInGamut "CheckColorsInGamut" intptr, var, intptr, int
; res = CheckColorsInGamut(hdc, lpRGBTriple, dlpBuffer, nCount)
; hdc : HDC -> "intptr"
; lpRGBTriple : RGBTRIPLE* -> "var"
; dlpBuffer : void* out -> "intptr"
; nCount : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCheckColorsInGamut = gdi32.NewProc("CheckColorsInGamut")
)

// hdc (HDC), lpRGBTriple (RGBTRIPLE*), dlpBuffer (void* out), nCount (DWORD)
r1, _, err := procCheckColorsInGamut.Call(
	uintptr(hdc),
	uintptr(lpRGBTriple),
	uintptr(dlpBuffer),
	uintptr(nCount),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CheckColorsInGamut(
  hdc: THandle;   // HDC
  lpRGBTriple: Pointer;   // RGBTRIPLE*
  dlpBuffer: Pointer;   // void* out
  nCount: DWORD   // DWORD
): BOOL; stdcall;
  external 'GDI32.dll' name 'CheckColorsInGamut';
result := DllCall("GDI32\CheckColorsInGamut"
    , "Ptr", hdc   ; HDC
    , "Ptr", lpRGBTriple   ; RGBTRIPLE*
    , "Ptr", dlpBuffer   ; void* out
    , "UInt", nCount   ; DWORD
    , "Int")   ; return: BOOL
●CheckColorsInGamut(hdc, lpRGBTriple, dlpBuffer, nCount) = DLL("GDI32.dll", "bool CheckColorsInGamut(void*, void*, void*, dword)")
# 呼び出し: CheckColorsInGamut(hdc, lpRGBTriple, dlpBuffer, nCount)
# hdc : HDC -> "void*"
# lpRGBTriple : RGBTRIPLE* -> "void*"
# dlpBuffer : void* out -> "void*"
# nCount : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。