[gtk+/gtk-2-24] testcombo: Fix generation of coloured pixbufs



commit a10a2ebf19a8ecfe005d46c894ae7137b57f5e06
Author: Daniel Boles <dboles src gnome org>
Date:   Wed Oct 4 23:39:05 2017 +0100

    testcombo: Fix generation of coloured pixbufs
    
    We need floating-point division… Otherwise, only fully-on inputs can
    produce any output. This fixes some of the colours wrongly being black.
    
    While here, remove the unused rowstride variable, to shush a warning.

 tests/testcombo.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/tests/testcombo.c b/tests/testcombo.c
index fd6835d..5bfdc8e 100644
--- a/tests/testcombo.c
+++ b/tests/testcombo.c
@@ -35,7 +35,6 @@ create_color_pixbuf (const char *color)
 
         int x;
         int num;
-        int rowstride;
         guchar *pixels, *p;
 
         if (!gdk_color_parse (color, &col))
@@ -45,16 +44,15 @@ create_color_pixbuf (const char *color)
                                  FALSE, 8,
                                  16, 16);
 
-        rowstride = gdk_pixbuf_get_rowstride (pixbuf);
         p = pixels = gdk_pixbuf_get_pixels (pixbuf);
 
         num = gdk_pixbuf_get_width (pixbuf) *
                 gdk_pixbuf_get_height (pixbuf);
 
         for (x = 0; x < num; x++) {
-                p[0] = col.red / 65535 * 255;
-                p[1] = col.green / 65535 * 255;
-                p[2] = col.blue / 65535 * 255;
+                p[0] = col.red / 65535.0 * 255;
+                p[1] = col.green / 65535.0 * 255;
+                p[2] = col.blue / 65535.0 * 255;
                 p += 3;
         }
 


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