From: Øyvind Kolås Date: Thu, 17 May 2018 14:24:49 +0000 (+0200) Subject: babl-palette: fix regression in prefvious commit X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~17^2~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=bbf5dda8b12a8fa01f434a6b9cc362af9a4b9383;p=babl.git babl-palette: fix regression in prefvious commit The 255.5 factor for storing a double represenation is neccesary for desired behavior. --- diff --git a/babl/babl-palette.c b/babl/babl-palette.c index 94d214d..a22ea58 100644 --- a/babl/babl-palette.c +++ b/babl/babl-palette.c @@ -222,7 +222,7 @@ rgba_to_pal (Babl *conversion, } } - ((double *) dst)[0] = best_idx / 255.0; + ((double *) dst)[0] = best_idx / 255.5; src += sizeof (double) * 4; dst += sizeof (double) * 1; @@ -278,7 +278,7 @@ rgba_to_pala (Babl *conversion, } } - ((double *) dst)[0] = best_idx / 255.0; + ((double *) dst)[0] = best_idx / 255.5; ((double *) dst)[1] = alpha; src += sizeof (double) * 4; @@ -298,7 +298,7 @@ pal_to_rgba (Babl *conversion, assert(pal); while (n--) { - int idx = (((double *) src)[0]) * 255.0; + int idx = (((double *) src)[0]) * 255.5; double *palpx; if (idx < 0) idx = 0; @@ -325,7 +325,7 @@ pala_to_rgba (Babl *conversion, assert(pal); while (n--) { - int idx = (((double *) src)[0]) * 255.0; + int idx = (((double *) src)[0]) * 255.5; double alpha = (((double *) src)[1]); double *palpx;