About Store Forum Documentation Contact



Post Reply 
[SOLVED] RGB to HSB conversion formula
Author Message
Hokan Offline
Member

Post: #1
[SOLVED] RGB to HSB conversion formula
I was trying to make gradient interpolator with base colour and it's brightness modifications - dark-dark blue, dark blue etc., but faced a problem that Esenthel RGB to HSB conversion doesn't match regular conversion.

i.e:
RBG = (26, 23, 57); this is dark-dark blue
regular HSB/HSV = (245, 0.6, 0.22)
regular HSL = (245, 0.43, 0.16)
Esenthel = (0.6, 0.59, 57)

By the way, RGB -> EE -> RGB work correctly.

By using ColorPicker I figured, that it is HSL (albeit it is not, see example above) with [0; 255] HSL constrains.
But RgbToHSB function returns result in ([0; 1], [0; 1], [0; 255]) constraint form.

So I'm curious what is real formula?
(This post was last modified: 07-26-2015 11:04 AM by Hokan.)
07-25-2015 11:35 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: RGB to HSB conversion formula
Hi,

I've just checked and my formulas match Photoshop. (PS uses 0..360 scale for H, and 0..100 for SB, while Esenthel operates on 0..1 float scale and 0..255 byte scale)

Having source license you can browse the source here:
https://github.com/Esenthel/EsenthelEngi.../Color.cpp
07-25-2015 11:23 PM
Find all posts by this user Quote this message in a reply
Hokan Offline
Member

Post: #3
RE: RGB to HSB conversion formula
Thanks for answer, I'm not a source licence owner, but it seems that EE conversion works like:
RGB -> regular HSB/HSV -> (h, s, v)
EE_h = h / 360
EE_s = s
EE_v = v * 255

Consider this question solved
07-26-2015 11:04 AM
Find all posts by this user Quote this message in a reply
Post Reply