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

ColorHLSToRGB

関数
色相・輝度・彩度のHLS値をRGB色へ変換する。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

COLORREF ColorHLSToRGB(
    WORD wHue,
    WORD wLuminance,
    WORD wSaturation
);

パラメーター

名前方向
wHueWORDin
wLuminanceWORDin
wSaturationWORDin

戻り値の型: COLORREF

各言語での呼び出し定義

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

COLORREF ColorHLSToRGB(
    WORD wHue,
    WORD wLuminance,
    WORD wSaturation
);
[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern uint ColorHLSToRGB(
    ushort wHue,   // WORD
    ushort wLuminance,   // WORD
    ushort wSaturation   // WORD
);
<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function ColorHLSToRGB(
    wHue As UShort,   ' WORD
    wLuminance As UShort,   ' WORD
    wSaturation As UShort   ' WORD
) As UInteger
End Function
' wHue : WORD
' wLuminance : WORD
' wSaturation : WORD
Declare PtrSafe Function ColorHLSToRGB Lib "shlwapi" ( _
    ByVal wHue As Integer, _
    ByVal wLuminance As Integer, _
    ByVal wSaturation As Integer) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ColorHLSToRGB = ctypes.windll.shlwapi.ColorHLSToRGB
ColorHLSToRGB.restype = wintypes.DWORD
ColorHLSToRGB.argtypes = [
    ctypes.c_ushort,  # wHue : WORD
    ctypes.c_ushort,  # wLuminance : WORD
    ctypes.c_ushort,  # wSaturation : WORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
ColorHLSToRGB = Fiddle::Function.new(
  lib['ColorHLSToRGB'],
  [
    -Fiddle::TYPE_SHORT,  # wHue : WORD
    -Fiddle::TYPE_SHORT,  # wLuminance : WORD
    -Fiddle::TYPE_SHORT,  # wSaturation : WORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "shlwapi")]
extern "system" {
    fn ColorHLSToRGB(
        wHue: u16,  // WORD
        wLuminance: u16,  // WORD
        wSaturation: u16  // WORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll")]
public static extern uint ColorHLSToRGB(ushort wHue, ushort wLuminance, ushort wSaturation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_ColorHLSToRGB' -Namespace Win32 -PassThru
# $api::ColorHLSToRGB(wHue, wLuminance, wSaturation)
#uselib "SHLWAPI.dll"
#func global ColorHLSToRGB "ColorHLSToRGB" sptr, sptr, sptr
; ColorHLSToRGB wHue, wLuminance, wSaturation   ; 戻り値は stat
; wHue : WORD -> "sptr"
; wLuminance : WORD -> "sptr"
; wSaturation : WORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHLWAPI.dll"
#cfunc global ColorHLSToRGB "ColorHLSToRGB" int, int, int
; res = ColorHLSToRGB(wHue, wLuminance, wSaturation)
; wHue : WORD -> "int"
; wLuminance : WORD -> "int"
; wSaturation : WORD -> "int"
; COLORREF ColorHLSToRGB(WORD wHue, WORD wLuminance, WORD wSaturation)
#uselib "SHLWAPI.dll"
#cfunc global ColorHLSToRGB "ColorHLSToRGB" int, int, int
; res = ColorHLSToRGB(wHue, wLuminance, wSaturation)
; wHue : WORD -> "int"
; wLuminance : WORD -> "int"
; wSaturation : WORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procColorHLSToRGB = shlwapi.NewProc("ColorHLSToRGB")
)

// wHue (WORD), wLuminance (WORD), wSaturation (WORD)
r1, _, err := procColorHLSToRGB.Call(
	uintptr(wHue),
	uintptr(wLuminance),
	uintptr(wSaturation),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // COLORREF
function ColorHLSToRGB(
  wHue: Word;   // WORD
  wLuminance: Word;   // WORD
  wSaturation: Word   // WORD
): DWORD; stdcall;
  external 'SHLWAPI.dll' name 'ColorHLSToRGB';
result := DllCall("SHLWAPI\ColorHLSToRGB"
    , "UShort", wHue   ; WORD
    , "UShort", wLuminance   ; WORD
    , "UShort", wSaturation   ; WORD
    , "UInt")   ; return: COLORREF
●ColorHLSToRGB(wHue, wLuminance, wSaturation) = DLL("SHLWAPI.dll", "dword ColorHLSToRGB(int, int, int)")
# 呼び出し: ColorHLSToRGB(wHue, wLuminance, wSaturation)
# wHue : WORD -> "int"
# wLuminance : WORD -> "int"
# wSaturation : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。