summaryrefslogtreecommitdiffstats
path: root/image/decoders/nsBMPDecoder.h
diff options
context:
space:
mode:
authorAndrew Osmond <aosmond@mozilla.com>2019-02-16 20:21:13 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-02-16 20:21:13 +0100
commitc66d87e6c00b6cbde3336a42aa9964f076dc9b2c (patch)
treeb31311d2a7eedbd476714ca918ddd33cb94e4797 /image/decoders/nsBMPDecoder.h
parent529067c0a2073e26a54441f9994ec814fac76938 (diff)
downloadUXP-c66d87e6c00b6cbde3336a42aa9964f076dc9b2c.tar
UXP-c66d87e6c00b6cbde3336a42aa9964f076dc9b2c.tar.gz
UXP-c66d87e6c00b6cbde3336a42aa9964f076dc9b2c.tar.lz
UXP-c66d87e6c00b6cbde3336a42aa9964f076dc9b2c.tar.xz
UXP-c66d87e6c00b6cbde3336a42aa9964f076dc9b2c.zip
BMPs from the clipboard may include extra padding.
In the original Windows clipboard BMP decoder implementation in nsImageFromClipboard::ConvertColorBitMap, if the bitmap used bitfields compression, it always adjusted the offset to the RGB data by 12 bytes. It did this even for newer BMP header formats which explicitly include space for the bitfields in their header sizes. This patch updates our BMP decoder to do the same for clipboard BMPs, since we have observed pasted BMPs using bitfield compression appearing incorrectly. To the user this appears as if we read a color mask; completely red, blue, green pixels at the start of the last row, causing all of the other rows to start with the last three pixels of the previous row.
Diffstat (limited to 'image/decoders/nsBMPDecoder.h')
-rw-r--r--image/decoders/nsBMPDecoder.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/image/decoders/nsBMPDecoder.h b/image/decoders/nsBMPDecoder.h
index 258381649..4b9568487 100644
--- a/image/decoders/nsBMPDecoder.h
+++ b/image/decoders/nsBMPDecoder.h
@@ -152,7 +152,6 @@ private:
enum class State {
FILE_HEADER,
- CLIPBOARD_HEADER,
INFO_HEADER_SIZE,
INFO_HEADER_REST,
BITFIELDS,
@@ -172,7 +171,7 @@ private:
nsBMPDecoder(RasterImage* aImage, uint32_t aDataOffset);
// Helper constructor called by the other two.
- nsBMPDecoder(RasterImage* aImage, State aState, size_t aLength);
+ nsBMPDecoder(RasterImage* aImage, State aState, size_t aLength, bool aForClipboard);
int32_t AbsoluteHeight() const { return abs(mH.mHeight); }
@@ -181,7 +180,6 @@ private:
void FinishRow();
LexerTransition<State> ReadFileHeader(const char* aData, size_t aLength);
- LexerTransition<State> ReadClipboardHeader(const char* aData, size_t aLength);
LexerTransition<State> ReadInfoHeaderSize(const char* aData, size_t aLength);
LexerTransition<State> ReadInfoHeaderRest(const char* aData, size_t aLength);
LexerTransition<State> ReadBitfields(const char* aData, size_t aLength);
@@ -200,6 +198,9 @@ private:
// If the BMP is within an ICO file our treatment of it differs slightly.
bool mIsWithinICO;
+ // If the BMP is decoded from the clipboard, we start with a data offset.
+ bool mIsForClipboard;
+
bmp::BitFields mBitFields;
// Might the image have transparency? Determined from the headers during