Skip to content

Commit

Permalink
use float instead of double in rgb to hsv conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Oct 12, 2024
1 parent 6b8a97a commit 48681cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libImaging/Convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ rgb2hsv_row(UINT8 *out, const UINT8 *in) {
us = 0;
} else {
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) {
h = (g - b) / cr;
} else if (g == maxc) {
Expand All @@ -344,7 +344,7 @@ rgb2hsv_row(UINT8 *out, const UINT8 *in) {
// https://stackoverflow.com/a/3883019/3878168
// "h = (h/6.0) % 1.0" in Python can be computed as:
h = h / 6.0;
h = h - floor(h);
h = h - floorf(h);

uh = (UINT8)(255.0 * h);
us = 255 * color_range / maxc;
Expand Down

0 comments on commit 48681cd

Please sign in to comment.