How to convert redFloat, greenFloat and blueFloat to RGB?
I’ve printed the descriptor of a text layer and it has 2 “textStyleRange”.
In the first one, the color in the “textStyle” is like this
"color": {
"objectType": "RGBColor",
"value": {
"red": 242.96399384737,
"grain": 231.608835160732,
"blue": 124.368603229523
}
}
and in the other it looks like this
"color": {
"objectType": "RGBColor",
"value": {
"redFloat": -0.1768099963665,
"greenFloat": 0.65371006727219,
"blueFloat": 0.70756006240845
}
}
It seems that, if I clamp/clip the values redFloat, greenFloat and blueFloat to the range [0, 1] and then scale them to [0, 255], I get the RGB values I see in the Photoshop UI, but I don’t know if this is the correct and reliable way of converting them to [0, 255]. By clamping, I mean that I set them to zero, if they are less than 0, and set them to 1 if they are greater than 1.
Does anyone know if this documented somewhere and if this is the correct/reliable way of doing it? I need all colors to be in [0, 255].
Also any idea why we have both representations?
My setup:
- Photoshop: 27.4
- Mac OS
