[gdk-pixbuf] ico: Fix uninitialised alpha values



commit 97529aaad997dc397d69fbd0aed2605c9cf7ba5a
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Dec 29 14:36:45 2016 +0100

    ico: Fix uninitialised alpha values
    
    As we always create a GdkPixbuf with alpha, even if the original file
    doesn't have an alpha channel, or a mask, make sure to set the alpha
    pixel value in all cases, if only to have it overridden if there is a
    mask present.
    
    This makes it possible to use the reference test without having
    differing alpha values.

 gdk-pixbuf/io-ico.c                            |    7 ++++++-
 tests/test-images/reftests/squares.ico         |  Bin 0 -> 6926 bytes
 tests/test-images/reftests/squares.ico.ref.png |  Bin 0 -> 259 bytes
 3 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index e6c1299..9448619 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -659,6 +659,7 @@ static void OneLine24(struct ico_progressive_state *context)
                Pixels[X * 4 + 0] = context->LineBuf[X * 3 + 2];
                Pixels[X * 4 + 1] = context->LineBuf[X * 3 + 1];
                Pixels[X * 4 + 2] = context->LineBuf[X * 3 + 0];
+               Pixels[X * 4 + 3] = 0xff;
                X++;
        }
 
@@ -699,7 +700,7 @@ OneLine16 (struct ico_progressive_state *context)
                 *pixels++ = (r << 3) | (r >> 2);
                 *pixels++ = (g << 3) | (g >> 2);
                 *pixels++ = (b << 3) | (b >> 2);
-                pixels++; /* skip alpha channel */
+                *pixels++ = 0xff;
         }
 }
 
@@ -726,6 +727,7 @@ static void OneLine8(struct ico_progressive_state *context)
                    context->HeaderBuf[4 * context->LineBuf[X] + INFOHEADER_SIZE + 1 +context->DIBoffset];
                Pixels[X * 4 + 2] =
                    context->HeaderBuf[4 * context->LineBuf[X] + INFOHEADER_SIZE +context->DIBoffset];
+               Pixels[X * 4 + 3] = 0xff;
                X++;
        }
 }
@@ -755,6 +757,7 @@ static void OneLine4(struct ico_progressive_state *context)
                    context->HeaderBuf[4 * (Pix>>4) + INFOHEADER_SIZE + 1 +context->DIBoffset];
                Pixels[X * 4 + 2] =
                    context->HeaderBuf[4 * (Pix>>4) + INFOHEADER_SIZE + context->DIBoffset];
+               Pixels[X * 4 + 3] = 0xff;
                X++;
                if (X<context->Header.width) { 
                        /* Handle the other 4 bit pixel only when there is one */
@@ -764,6 +767,7 @@ static void OneLine4(struct ico_progressive_state *context)
                            context->HeaderBuf[4 * (Pix&15) + INFOHEADER_SIZE + 1 + context->DIBoffset];
                        Pixels[X * 4 + 2] =
                            context->HeaderBuf[4 * (Pix&15) + INFOHEADER_SIZE + context->DIBoffset];
+                       Pixels[X * 4 + 3] = 0xff;
                        X++;
                }
        }
@@ -793,6 +797,7 @@ static void OneLine1(struct ico_progressive_state *context)
                Pixels[X * 4 + 0] = Bit*255;
                Pixels[X * 4 + 1] = Bit*255;
                Pixels[X * 4 + 2] = Bit*255;
+               Pixels[X * 4 + 3] = 0xff;
                X++;
        }
 }
diff --git a/tests/test-images/reftests/squares.ico b/tests/test-images/reftests/squares.ico
new file mode 100644
index 0000000..6bda81b
Binary files /dev/null and b/tests/test-images/reftests/squares.ico differ
diff --git a/tests/test-images/reftests/squares.ico.ref.png b/tests/test-images/reftests/squares.ico.ref.png
new file mode 100644
index 0000000..c0f603c
Binary files /dev/null and b/tests/test-images/reftests/squares.ico.ref.png differ


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