ColorRGBToHLS (shlwapi)
Last changed: french.software.company@gmail.com-165.225.76.101

.
Summary
Converts colors from RGB to hue-luminance-saturation (HLS) format.

C# Signature:

[DllImport("shlwapi.dll")]
static extern void ColorRGBToHLS(int RGB, ref int H, ref int L, ref int S);

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

  using System;
  using System.Drawing;
  using System.Runtime.InteropServices;
  sealed class Win32
  {
    [DllImport("shlwapi.dll")]
    static extern void ColorRGBToHLS(int RGB, ref int H, ref int L, ref int S);

    //
    //Convert System.Drawing.Color structure to HLS.
    //
    static public void ColorToHLS(System.Drawing.Color C,ref int H,ref int L,ref int S)
    {
      //
      //Use ColorTranslator.ToWin32 rather than Color.ToArgb because we need 0x00BBGGRR,
      //which is returned by ToWin32, rather than 0x00RRGGBB, which is returned by ToArgb.
      //
      ColorRGBToHLS(ColorTranslator.ToWin32(C), ref H, ref L, ref S);
    }
  }

Documentation