I am listening to Photoshop’s
set event for the Eye Dropper Tool. When using it with a Mask, it returns an object with the color mode
grayscale and a value called
gray. I need to convert this value to an RGB or Hex value.
For example, in the Color Panel, it says I have picked the gray color 50% which has an RGB value of ((149, 149, 149) and a Hex value of #959595.
I am unable to get the RGB & Hex values correctly. The formula I’m currently using is
let gray = parseInt(255-(255*obj.gray/100));
Using the above 50% example,
gray is 49.8 and does not returning the correct result.
It works out as this…
gray = 255-(255*49.8/100) gray = 255-(255*0.498) gray = 255-126.99 gray = 128.01
128 is pretty far off from the RGB value of 149 shown in the Photoshop picker (that would be the correct value if the mode was HSB & B was 50%).
How can I convert the Photoshop eye dropper
gray value to the same RGB/Hex Photoshop’s picker is showing?