1. Computing & Technology

Discuss in my forum

GDI+ Graphics in Visual Basic 2005 .NET

HSL and HSV Color Coding

By , About.com Guide

As if this wasn't enough, there is another "family" of coding to represent colors. One is called HSL (Hue, Saturation, Luminosity) coding. A variation is called HSV where the V is Value instead. Hue is the actual color from red through yellow, green, cyan, blue, and magenta. Saturation is the amount of color compared to white (which has no color). And Luminosity, the balance between white and black. So again, we can represent our colors with three numbers, but a completely different three. It's customary to represent the H, S, and L values from 0 to 255 just like RGB values.

To see the difference, consider pure red. This will have an RGB value of 255, 0, 0. The HSL value, however, is 255, 255, 128. The Hue is pure red. There is no white. And it's evenly balanced between white and black. The illustration shows a color tool from a popular graphics software system with "red" selected in both systems.

--------
Click Here to display the illustration
Click the Back button on your browser to return
--------

HSL (or HSV) colors usually seem more natural for people to work with so they're featured in virtually all graphics software. but RGB colors are more natural for computers to work with. And .NET doesn't even have any methods to work with HSL or HSV color coding! Fortunately, author and all around .NET guru Ken Getz has written a converter for HSV and an article in MSDN magazine about it.

A Primer on Building a Color Picker User Control with GDI+ in Visual Basic .NET or C#

If you need that capability, I recommend Ken's article. In fact, I recommend it anyway.

Part 8 of the tutorial shows how to use images, including bitmap images, thumbnails, and icons. If you have wanted to know how to make an icon from a JPG image, this is where you can learn.

©2012 About.com. All rights reserved.

A part of The New York Times Company.