mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-05 06:00:58 +03:00
use float instead of double in rgb to hsv conversion
This commit is contained in:
parent
6b8a97ab16
commit
48681cd014
|
@ -328,9 +328,9 @@ rgb2hsv_row(UINT8 *out, const UINT8 *in) {
|
||||||
us = 0;
|
us = 0;
|
||||||
} else {
|
} else {
|
||||||
const UINT8 color_range = maxc - minc;
|
const UINT8 color_range = maxc - minc;
|
||||||
double h;
|
float h;
|
||||||
|
|
||||||
const double cr = (double)color_range;
|
const float cr = (float)color_range;
|
||||||
if (r == maxc) {
|
if (r == maxc) {
|
||||||
h = (g - b) / cr;
|
h = (g - b) / cr;
|
||||||
} else if (g == maxc) {
|
} else if (g == maxc) {
|
||||||
|
@ -344,7 +344,7 @@ rgb2hsv_row(UINT8 *out, const UINT8 *in) {
|
||||||
// https://stackoverflow.com/a/3883019/3878168
|
// https://stackoverflow.com/a/3883019/3878168
|
||||||
// "h = (h/6.0) % 1.0" in Python can be computed as:
|
// "h = (h/6.0) % 1.0" in Python can be computed as:
|
||||||
h = h / 6.0;
|
h = h / 6.0;
|
||||||
h = h - floor(h);
|
h = h - floorf(h);
|
||||||
|
|
||||||
uh = (UINT8)(255.0 * h);
|
uh = (UINT8)(255.0 * h);
|
||||||
us = 255 * color_range / maxc;
|
us = 255 * color_range / maxc;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user