Gitweb links:

...log 
http://git.netsurf-browser.org/libnsbmp.git/shortlog/7ad3603ae4358c131cebe112d85b34639a8d55bc
...commit 
http://git.netsurf-browser.org/libnsbmp.git/commit/7ad3603ae4358c131cebe112d85b34639a8d55bc
...tree 
http://git.netsurf-browser.org/libnsbmp.git/tree/7ad3603ae4358c131cebe112d85b34639a8d55bc

The branch, master has been updated
       via  7ad3603ae4358c131cebe112d85b34639a8d55bc (commit)
      from  911072bc0312a1a0f7eeac01fdf861c02a34a313 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libnsbmp.git/commit/?id=7ad3603ae4358c131cebe112d85b34639a8d55bc
commit 7ad3603ae4358c131cebe112d85b34639a8d55bc
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    ensure icon mask decode sets transparancy correctly

diff --git a/src/libnsbmp.c b/src/libnsbmp.c
index 0e241a1..b9bd8f5 100644
--- a/src/libnsbmp.c
+++ b/src/libnsbmp.c
@@ -818,11 +818,6 @@ static bmp_result bmp_decode_mask(bmp_image *bmp, uint8_t 
*data, int bytes)
         uint32_t x, y, swidth;
         uint32_t cur_byte = 0;
 
-        if (bmp->bpp == 32) {
-                /* should already have proper alpha */
-                return BMP_OK;
-        }
-
         swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * 
bmp->width;
         top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap);
         if (!top)
@@ -840,11 +835,13 @@ static bmp_result bmp_decode_mask(bmp_image *bmp, uint8_t 
*data, int bytes)
                 for (x = 0; x < bmp->width; x++) {
                         if ((x & 7) == 0)
                                 cur_byte = *data++;
+                        scanline[x] = read_uint32((uint8_t *)&scanline[x], 0);
                         if ((cur_byte & 128) == 0) {
-                                scanline[x] = read_uint32((uint8_t 
*)&scanline[x], 0);
                                 scanline[x] |= (0xff << 24);
-                                scanline[x] = read_uint32((uint8_t 
*)&scanline[x], 0);
+                        } else {
+                                scanline[x] &= 0xffffff;
                         }
+                        scanline[x] = read_uint32((uint8_t *)&scanline[x], 0);
                         cur_byte = cur_byte << 1;
                 }
         }
@@ -1295,11 +1292,12 @@ bmp_result bmp_decode(bmp_image *bmp)
                 break;
         }
 
-        if ((!bmp->ico) || (result != BMP_OK))
-                return result;
-
-        bytes = (uintptr_t)bmp->bmp_data + bmp->buffer_size - (uintptr_t)data;
-        return bmp_decode_mask(bmp, data, bytes);
+        /* icons with less than 32bpp have a 1bpp alpha mask */
+        if ((result == BMP_OK) && (bmp->ico) && (bmp->bpp != 32)) {
+                bytes = (uintptr_t)bmp->bmp_data + bmp->buffer_size - 
(uintptr_t)data;
+                result = bmp_decode_mask(bmp, data, bytes);
+        }
+        return result;
 }
 
 


-----------------------------------------------------------------------

Summary of changes:
 src/libnsbmp.c |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/libnsbmp.c b/src/libnsbmp.c
index 0e241a1..b9bd8f5 100644
--- a/src/libnsbmp.c
+++ b/src/libnsbmp.c
@@ -818,11 +818,6 @@ static bmp_result bmp_decode_mask(bmp_image *bmp, uint8_t 
*data, int bytes)
         uint32_t x, y, swidth;
         uint32_t cur_byte = 0;
 
-        if (bmp->bpp == 32) {
-                /* should already have proper alpha */
-                return BMP_OK;
-        }
-
         swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * 
bmp->width;
         top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap);
         if (!top)
@@ -840,11 +835,13 @@ static bmp_result bmp_decode_mask(bmp_image *bmp, uint8_t 
*data, int bytes)
                 for (x = 0; x < bmp->width; x++) {
                         if ((x & 7) == 0)
                                 cur_byte = *data++;
+                        scanline[x] = read_uint32((uint8_t *)&scanline[x], 0);
                         if ((cur_byte & 128) == 0) {
-                                scanline[x] = read_uint32((uint8_t 
*)&scanline[x], 0);
                                 scanline[x] |= (0xff << 24);
-                                scanline[x] = read_uint32((uint8_t 
*)&scanline[x], 0);
+                        } else {
+                                scanline[x] &= 0xffffff;
                         }
+                        scanline[x] = read_uint32((uint8_t *)&scanline[x], 0);
                         cur_byte = cur_byte << 1;
                 }
         }
@@ -1295,11 +1292,12 @@ bmp_result bmp_decode(bmp_image *bmp)
                 break;
         }
 
-        if ((!bmp->ico) || (result != BMP_OK))
-                return result;
-
-        bytes = (uintptr_t)bmp->bmp_data + bmp->buffer_size - (uintptr_t)data;
-        return bmp_decode_mask(bmp, data, bytes);
+        /* icons with less than 32bpp have a 1bpp alpha mask */
+        if ((result == BMP_OK) && (bmp->ico) && (bmp->bpp != 32)) {
+                bytes = (uintptr_t)bmp->bmp_data + bmp->buffer_size - 
(uintptr_t)data;
+                result = bmp_decode_mask(bmp, data, bytes);
+        }
+        return result;
 }
 
 


-- 
NetSurf BMP Decoder

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to