Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / DBPro RGB to/from HSL ( Hue , Saturation , Lightness )

Author
Message
DeepBlue
21
Years of Service
User Offline
Joined: 17th May 2003
Location: A little box in the UK
Posted: 3rd Jul 2004 20:45
Function library to convert RGB to/from HSL including demonstration code.



Please note that the demonstration code is relatively slow as it uses pixel by pixel manipulation of the image to show function usage.

I would not not recommend running the example code with an image not much larger than 200x100 pixels due to the above.

An image 'image1.bmp' is required to run the code. A sample image along with the above demo code and a seperate file containing only the functions can be downloaded here (77Kb)

http://deepblue.ipuk.net/downloads/hsl.zip

DeepBlue

The coder formerly known as Twynklet.
kenmo
22
Years of Service
User Offline
Joined: 7th Sep 2002
Location:
Posted: 4th Jul 2004 08:38 Edited at: 27th Jun 2012 06:19
Thats awesome man. I cant believe you posted this today, after I just finished some RGB/HSL functions a couple days ago. Took me like a month to get them working completely right.

Did you use a reference site for these functions? Because I couldn't find any really good ones, although I used this easy to understand one: http://130.113.54.154/~monger/hsl-rgb.html
DeepBlue
21
Years of Service
User Offline
Joined: 17th May 2003
Location: A little box in the UK
Posted: 4th Jul 2004 08:50
Yeah not easy is it. Started work on it about two weeks ago, done half a day & decided to drop it. Started on it again this morning when somebody was talking about wanting it on the forums and finished it in about 2 hrs.

Not handy the way Db refuses to return real values some of the time if you use literal numbers in your calculations (hence several abs statements to force it).

Used this as my reference site

http://www.easyrgb.com/math.html

Spent the rest of the time adding the helper functions ie. HSL, HSLh etc & formating all the functions to conform to the same structure as the existing Db RGB ones.

Don't think I'll ever use it but was a very nice challenge.

The coder formerly known as Twynklet.
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 4th Jul 2004 09:01
hmm... ya know i made 2 very small functions for this about 2years ago right?
even DB Standard compatible, but good work all the same.

DeepBlue
21
Years of Service
User Offline
Joined: 17th May 2003
Location: A little box in the UK
Posted: 4th Jul 2004 09:07
Nope how would I know that? And several people have requested them on the forumns in the last month, so I decided to help out (Anthing not to actually have to code a game ).

Can ya post em or throw em in the codebase for us please Raven (nothing listed except mine at moment either under HSL or Hue ).

Thanks

Deepblue

ps. I really should read the conference thread & decide if I'm going.

The coder formerly known as Twynklet.
MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 5th Jul 2004 15:12
Very nice. I'm working on an image editing program myself, and this could come in handy.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)

Login to post a reply

Server time is: 2024-11-23 19:59:33
Your offset time is: 2024-11-23 19:59:33