ホーム › UI.ColorSystem › GetDeviceGammaRamp
GetDeviceGammaRamp
関数ディスプレイデバイスのガンマランプを取得する。
シグネチャ
// GDI32.dll
#include <windows.h>
BOOL GetDeviceGammaRamp(
HDC hdc,
void* lpRamp
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | ガンマランプを取得する対象デバイス(ディスプレイ)のデバイスコンテキストハンドル。 |
| lpRamp | void* | out | 取得したガンマランプを格納するバッファ。RGB各256要素のWORD配列(計3×256)を指す。 |
戻り値の型: BOOL
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
BOOL GetDeviceGammaRamp(
HDC hdc,
void* lpRamp
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool GetDeviceGammaRamp(
IntPtr hdc, // HDC
IntPtr lpRamp // void* out
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function GetDeviceGammaRamp(
hdc As IntPtr, ' HDC
lpRamp As IntPtr ' void* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hdc : HDC
' lpRamp : void* out
Declare PtrSafe Function GetDeviceGammaRamp Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal lpRamp As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetDeviceGammaRamp = ctypes.windll.gdi32.GetDeviceGammaRamp
GetDeviceGammaRamp.restype = wintypes.BOOL
GetDeviceGammaRamp.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.POINTER(None), # lpRamp : void* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
GetDeviceGammaRamp = Fiddle::Function.new(
lib['GetDeviceGammaRamp'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # lpRamp : void* out
],
Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn GetDeviceGammaRamp(
hdc: *mut core::ffi::c_void, // HDC
lpRamp: *mut () // void* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool GetDeviceGammaRamp(IntPtr hdc, IntPtr lpRamp);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetDeviceGammaRamp' -Namespace Win32 -PassThru
# $api::GetDeviceGammaRamp(hdc, lpRamp)#uselib "GDI32.dll"
#func global GetDeviceGammaRamp "GetDeviceGammaRamp" sptr, sptr
; GetDeviceGammaRamp hdc, lpRamp ; 戻り値は stat
; hdc : HDC -> "sptr"
; lpRamp : void* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "GDI32.dll"
#cfunc global GetDeviceGammaRamp "GetDeviceGammaRamp" sptr, sptr
; res = GetDeviceGammaRamp(hdc, lpRamp)
; hdc : HDC -> "sptr"
; lpRamp : void* out -> "sptr"; BOOL GetDeviceGammaRamp(HDC hdc, void* lpRamp)
#uselib "GDI32.dll"
#cfunc global GetDeviceGammaRamp "GetDeviceGammaRamp" intptr, intptr
; res = GetDeviceGammaRamp(hdc, lpRamp)
; hdc : HDC -> "intptr"
; lpRamp : void* out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procGetDeviceGammaRamp = gdi32.NewProc("GetDeviceGammaRamp")
)
// hdc (HDC), lpRamp (void* out)
r1, _, err := procGetDeviceGammaRamp.Call(
uintptr(hdc),
uintptr(lpRamp),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetDeviceGammaRamp(
hdc: THandle; // HDC
lpRamp: Pointer // void* out
): BOOL; stdcall;
external 'GDI32.dll' name 'GetDeviceGammaRamp';result := DllCall("GDI32\GetDeviceGammaRamp"
, "Ptr", hdc ; HDC
, "Ptr", lpRamp ; void* out
, "Int") ; return: BOOL●GetDeviceGammaRamp(hdc, lpRamp) = DLL("GDI32.dll", "bool GetDeviceGammaRamp(void*, void*)")
# 呼び出し: GetDeviceGammaRamp(hdc, lpRamp)
# hdc : HDC -> "void*"
# lpRamp : void* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdi32" fn GetDeviceGammaRamp(
hdc: ?*anyopaque, // HDC
lpRamp: ?*anyopaque // void* out
) callconv(std.os.windows.WINAPI) i32;proc GetDeviceGammaRamp(
hdc: pointer, # HDC
lpRamp: pointer # void* out
): int32 {.importc: "GetDeviceGammaRamp", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
int GetDeviceGammaRamp(
void* hdc, // HDC
void* lpRamp // void* out
);ccall((:GetDeviceGammaRamp, "GDI32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}),
hdc, lpRamp)
# hdc : HDC -> Ptr{Cvoid}
# lpRamp : void* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetDeviceGammaRamp(
void* hdc,
void* lpRamp);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.GetDeviceGammaRamp(hdc, lpRamp)
-- hdc : HDC
-- lpRamp : void* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const GetDeviceGammaRamp = lib.func('__stdcall', 'GetDeviceGammaRamp', 'int32_t', ['void *', 'void *']);
// GetDeviceGammaRamp(hdc, lpRamp)
// hdc : HDC -> 'void *'
// lpRamp : void* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GDI32.dll", {
GetDeviceGammaRamp: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetDeviceGammaRamp(hdc, lpRamp)
// hdc : HDC -> "pointer"
// lpRamp : void* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetDeviceGammaRamp(
void* hdc,
void* lpRamp);
C, "GDI32.dll");
// $ffi->GetDeviceGammaRamp(hdc, lpRamp);
// hdc : HDC
// lpRamp : void* 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 Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
boolean GetDeviceGammaRamp(
Pointer hdc, // HDC
Pointer lpRamp // void* out
);
}@[Link("gdi32")]
lib LibGDI32
fun GetDeviceGammaRamp = GetDeviceGammaRamp(
hdc : Void*, # HDC
lpRamp : Void* # void* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetDeviceGammaRampNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef GetDeviceGammaRampDart = int Function(Pointer<Void>, Pointer<Void>);
final GetDeviceGammaRamp = DynamicLibrary.open('GDI32.dll')
.lookupFunction<GetDeviceGammaRampNative, GetDeviceGammaRampDart>('GetDeviceGammaRamp');
// hdc : HDC -> Pointer<Void>
// lpRamp : void* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetDeviceGammaRamp(
hdc: THandle; // HDC
lpRamp: Pointer // void* out
): BOOL; stdcall;
external 'GDI32.dll' name 'GetDeviceGammaRamp';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetDeviceGammaRamp"
c_GetDeviceGammaRamp :: Ptr () -> Ptr () -> IO CInt
-- hdc : HDC -> Ptr ()
-- lpRamp : void* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getdevicegammaramp =
foreign "GetDeviceGammaRamp"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* lpRamp : void* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("GetDeviceGammaRamp" get-device-gamma-ramp :convention :stdcall) :int32
(hdc :pointer) ; HDC
(lp-ramp :pointer)) ; void* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetDeviceGammaRamp = Win32::API::More->new('GDI32',
'BOOL GetDeviceGammaRamp(HANDLE hdc, LPVOID lpRamp)');
# my $ret = $GetDeviceGammaRamp->Call($hdc, $lpRamp);
# hdc : HDC -> HANDLE
# lpRamp : void* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。