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

ColorAdjustLuma

関数
RGB色の輝度を増減して調整する。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

COLORREF ColorAdjustLuma(
    COLORREF clrRGB,
    INT n,
    BOOL fScale
);

パラメーター

名前方向
clrRGBCOLORREFin
nINTin
fScaleBOOLin

戻り値の型: COLORREF

各言語での呼び出し定義

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

COLORREF ColorAdjustLuma(
    COLORREF clrRGB,
    INT n,
    BOOL fScale
);
[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern uint ColorAdjustLuma(
    uint clrRGB,   // COLORREF
    int n,   // INT
    bool fScale   // BOOL
);
<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function ColorAdjustLuma(
    clrRGB As UInteger,   ' COLORREF
    n As Integer,   ' INT
    fScale As Boolean   ' BOOL
) As UInteger
End Function
' clrRGB : COLORREF
' n : INT
' fScale : BOOL
Declare PtrSafe Function ColorAdjustLuma Lib "shlwapi" ( _
    ByVal clrRGB As Long, _
    ByVal n As Long, _
    ByVal fScale As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ColorAdjustLuma = ctypes.windll.shlwapi.ColorAdjustLuma
ColorAdjustLuma.restype = wintypes.DWORD
ColorAdjustLuma.argtypes = [
    wintypes.DWORD,  # clrRGB : COLORREF
    ctypes.c_int,  # n : INT
    wintypes.BOOL,  # fScale : BOOL
]
require 'fiddle'
require 'fiddle/import'

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

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procColorAdjustLuma = shlwapi.NewProc("ColorAdjustLuma")
)

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