Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

ColorRGBToHLS (shlwapi)
 
.
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!

In VB .NET you can get the H< H< and B values from then color structure:

DIM red as Color = Color.FromArbg(255,255,0,0)

DIM H, S, B As Single

H = red.GetHue

S = red.GetSaturation

B = red.GetBrightness

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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions