Bug 700930 - BMP ICOs <= 8BPP can have bad color tables when processed partially. r=joe
authorBrian R. Bondy <netzen@gmail.com>
Sun, 27 Nov 2011 15:18:17 -0500
changeset 80857 0f74e9a5ea15d65a6d830dfe71bc0e2eac0ec284
parent 80856 3b60e1052a694b10259578501e0ce7066a0251ec
child 80858 65da7394934591648e076189516b13d6cfa50aa7
push id3607
push userbbondy@mozilla.com
push dateSun, 27 Nov 2011 20:19:00 +0000
treeherdermozilla-inbound@0f74e9a5ea15 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs700930
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 700930 - BMP ICOs <= 8BPP can have bad color tables when processed partially. r=joe
image/decoders/nsBMPDecoder.cpp
--- a/image/decoders/nsBMPDecoder.cpp
+++ b/image/decoders/nsBMPDecoder.cpp
@@ -394,20 +394,25 @@ nsBMPDecoder::WriteInternal(const char* 
                 case 0:
                     mColors[colorNum].blue = *aBuffer;
                     break;
                 case 1:
                     mColors[colorNum].green = *aBuffer;
                     break;
                 case 2:
                     mColors[colorNum].red = *aBuffer;
-                    colorNum++;
+                    // If there is no padding byte, increment the color index
+                    // since we're done with the current color.
+                    if (bytesPerColor == 3)
+                      colorNum++;
                     break;
                 case 3:
-                    // This is a padding byte
+                    // This is a padding byte only in Windows BMPs. Increment
+                    // the color index since we're done with the current color.
+                    colorNum++;
                     break;
             }
             mPos++; aBuffer++; aCount--;
             at = (at + 1) % bytesPerColor;
         }
       }
     }
     else if (aCount && mBIH.compression == BI_BITFIELDS && mPos < (WIN_HEADER_LENGTH + BITFIELD_LENGTH)) {