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元の HLS の色相値。 0 から 240 の範囲を指定できます。
wLuminanceWORDin元の HLS の輝度値。 0 から 240 の範囲を指定できます。
wSaturationWORDin元の HLS の彩度値。 0 から 240 の範囲を指定できます。

戻り値の型: COLORREF

公式ドキュメント

色相・輝度・彩度 (HLS) 形式の色を RGB 形式に変換します。

戻り値

型: COLORREF

RGB 値を返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// 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)。
const std = @import("std");

extern "shlwapi" fn ColorHLSToRGB(
    wHue: u16, // WORD
    wLuminance: u16, // WORD
    wSaturation: u16 // WORD
) callconv(std.os.windows.WINAPI) u32;
proc ColorHLSToRGB(
    wHue: uint16,  # WORD
    wLuminance: uint16,  # WORD
    wSaturation: uint16  # WORD
): uint32 {.importc: "ColorHLSToRGB", stdcall, dynlib: "SHLWAPI.dll".}
pragma(lib, "shlwapi");
extern(Windows)
uint ColorHLSToRGB(
    ushort wHue,   // WORD
    ushort wLuminance,   // WORD
    ushort wSaturation   // WORD
);
ccall((:ColorHLSToRGB, "SHLWAPI.dll"), stdcall, UInt32,
      (UInt16, UInt16, UInt16),
      wHue, wLuminance, wSaturation)
# wHue : WORD -> UInt16
# wLuminance : WORD -> UInt16
# wSaturation : WORD -> UInt16
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t ColorHLSToRGB(
    uint16_t wHue,
    uint16_t wLuminance,
    uint16_t wSaturation);
]]
local shlwapi = ffi.load("shlwapi")
-- shlwapi.ColorHLSToRGB(wHue, wLuminance, wSaturation)
-- wHue : WORD
-- wLuminance : WORD
-- wSaturation : WORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SHLWAPI.dll');
const ColorHLSToRGB = lib.func('__stdcall', 'ColorHLSToRGB', 'uint32_t', ['uint16_t', 'uint16_t', 'uint16_t']);
// ColorHLSToRGB(wHue, wLuminance, wSaturation)
// wHue : WORD -> 'uint16_t'
// wLuminance : WORD -> 'uint16_t'
// wSaturation : WORD -> 'uint16_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SHLWAPI.dll", {
  ColorHLSToRGB: { parameters: ["u16", "u16", "u16"], result: "u32" },
});
// lib.symbols.ColorHLSToRGB(wHue, wLuminance, wSaturation)
// wHue : WORD -> "u16"
// wLuminance : WORD -> "u16"
// wSaturation : WORD -> "u16"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t ColorHLSToRGB(
    uint16_t wHue,
    uint16_t wLuminance,
    uint16_t wSaturation);
C, "SHLWAPI.dll");
// $ffi->ColorHLSToRGB(wHue, wLuminance, wSaturation);
// wHue : WORD
// wLuminance : WORD
// wSaturation : WORD
// 構造体/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 Shlwapi extends StdCallLibrary {
    Shlwapi INSTANCE = Native.load("shlwapi", Shlwapi.class);
    int ColorHLSToRGB(
        short wHue,   // WORD
        short wLuminance,   // WORD
        short wSaturation   // WORD
    );
}
@[Link("shlwapi")]
lib LibSHLWAPI
  fun ColorHLSToRGB = ColorHLSToRGB(
    wHue : UInt16,   # WORD
    wLuminance : UInt16,   # WORD
    wSaturation : UInt16   # WORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ColorHLSToRGBNative = Uint32 Function(Uint16, Uint16, Uint16);
typedef ColorHLSToRGBDart = int Function(int, int, int);
final ColorHLSToRGB = DynamicLibrary.open('SHLWAPI.dll')
    .lookupFunction<ColorHLSToRGBNative, ColorHLSToRGBDart>('ColorHLSToRGB');
// wHue : WORD -> Uint16
// wLuminance : WORD -> Uint16
// wSaturation : WORD -> Uint16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ColorHLSToRGB(
  wHue: Word;   // WORD
  wLuminance: Word;   // WORD
  wSaturation: Word   // WORD
): DWORD; stdcall;
  external 'SHLWAPI.dll' name 'ColorHLSToRGB';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ColorHLSToRGB"
  c_ColorHLSToRGB :: Word16 -> Word16 -> Word16 -> IO Word32
-- wHue : WORD -> Word16
-- wLuminance : WORD -> Word16
-- wSaturation : WORD -> Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let colorhlstorgb =
  foreign "ColorHLSToRGB"
    (uint16_t @-> uint16_t @-> uint16_t @-> returning uint32_t)
(* wHue : WORD -> uint16_t *)
(* wLuminance : WORD -> uint16_t *)
(* wSaturation : WORD -> uint16_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shlwapi (t "SHLWAPI.dll"))
(cffi:use-foreign-library shlwapi)

(cffi:defcfun ("ColorHLSToRGB" color-hlsto-rgb :convention :stdcall) :uint32
  (w-hue :uint16)   ; WORD
  (w-luminance :uint16)   ; WORD
  (w-saturation :uint16))   ; WORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ColorHLSToRGB = Win32::API::More->new('SHLWAPI',
    'DWORD ColorHLSToRGB(WORD wHue, WORD wLuminance, WORD wSaturation)');
# my $ret = $ColorHLSToRGB->Call($wHue, $wLuminance, $wSaturation);
# wHue : WORD -> WORD
# wLuminance : WORD -> WORD
# wSaturation : WORD -> WORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。