vcl/qa/cppunit/BmpFilterTest.cxx | 13 +++++++++++++ vcl/qa/cppunit/data/tdf169871.bmp |binary vcl/source/bitmap/dibtools.cxx | 6 +++--- 3 files changed, 16 insertions(+), 3 deletions(-)
New commits: commit 7b37f205672181fd330365fcf8249a5c70718b41 Author: Andras Timar <[email protected]> AuthorDate: Sun Dec 7 22:03:08 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Dec 8 10:52:37 2025 +0100 tdf#169871 fix wrong application of color mask nV5RedMask, nV5GreenMask and nV5BlueMask are valid only when used with 16-bpp or 32-bpp bitmap and the bitmap is not compressed. Change-Id: Ic6ca1364a12f9bc11d789e317428cd9c3e144873 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195210 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/vcl/qa/cppunit/BmpFilterTest.cxx b/vcl/qa/cppunit/BmpFilterTest.cxx index 3669f99071e3..c83c13bfef70 100644 --- a/vcl/qa/cppunit/BmpFilterTest.cxx +++ b/vcl/qa/cppunit/BmpFilterTest.cxx @@ -217,4 +217,17 @@ CPPUNIT_TEST_FIXTURE(BmpFilterTest, testTdf73523) CPPUNIT_ASSERT_EQUAL(COL_RED, aBitmap.GetPixelColor(0, 0)); } +CPPUNIT_TEST_FIXTURE(BmpFilterTest, testTdf169871) +{ + SvFileStream aFileStream(getFullUrl(u"tdf169871.bmp"), StreamMode::READ); + Graphic aGraphic; + CPPUNIT_ASSERT(BmpReader(aFileStream, aGraphic)); + auto aBitmap = aGraphic.GetBitmapEx(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: rgba[800000ff] + // - Actual : rgba[000080ff] + // i.e. the pixel is red not blue + CPPUNIT_ASSERT_EQUAL(COL_RED, aBitmap.GetPixelColor(0, 0)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/data/tdf169871.bmp b/vcl/qa/cppunit/data/tdf169871.bmp new file mode 100644 index 000000000000..85684813f024 Binary files /dev/null and b/vcl/qa/cppunit/data/tdf169871.bmp differ diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx index 97bcb86b0feb..c5d8b43145e6 100644 --- a/vcl/source/bitmap/dibtools.cxx +++ b/vcl/source/bitmap/dibtools.cxx @@ -525,12 +525,12 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r } else { - if (rHeader.nV5RedMask > 0) + if (bTCMask && BITFIELDS == rHeader.nCompression) + { nRMask = rHeader.nV5RedMask; - if (rHeader.nV5GreenMask > 0) nGMask = rHeader.nV5GreenMask; - if (rHeader.nV5BlueMask > 0) nBMask = rHeader.nV5BlueMask; + } const tools::Long nWidth(rHeader.nWidth); const tools::Long nHeight(rHeader.nHeight);
