[babl] babl-palette: fix regression in prefvious commit



commit bbf5dda8b12a8fa01f434a6b9cc362af9a4b9383
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu May 17 16:24:49 2018 +0200

    babl-palette: fix regression in prefvious commit
    
    The 255.5 factor for storing a double represenation is neccesary for
    desired behavior.

 babl/babl-palette.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]