vcl/CppunitTest_vcl_filter_bmp.mk           |   46 +++++++++++++++++++++++++++
 vcl/Module_vcl.mk                           |    1 
 vcl/qa/cppunit/filter/bmp/bmp.cxx           |   47 ++++++++++++++++++++++++++++
 vcl/qa/cppunit/filter/bmp/data/tdf73523.bmp |binary
 vcl/source/gdi/dibtools.cxx                 |    1 
 5 files changed, 94 insertions(+), 1 deletion(-)

New commits:
commit 7025e57c8f1e26f40754dd0aeb07aa7096a90e1f
Author:     Andras Timar <andras.ti...@collabora.com>
AuthorDate: Mon Jan 3 22:12:01 2022 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jan 4 08:41:33 2022 +0100

    tdf#73523 do not seek backwards, the color mask info is not there
    
    Change-Id: I97f0fd4f184ea77beeab8b22fc98fdb78472d9bb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127920
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/vcl/CppunitTest_vcl_filter_bmp.mk 
b/vcl/CppunitTest_vcl_filter_bmp.mk
new file mode 100644
index 000000000000..c9020b8c59c5
--- /dev/null
+++ b/vcl/CppunitTest_vcl_filter_bmp.mk
@@ -0,0 +1,46 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,vcl_filter_bmp))
+
+$(eval $(call gb_CppunitTest_use_externals,vcl_filter_bmp,\
+       boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,vcl_filter_bmp, \
+    vcl/qa/cppunit/filter/bmp/bmp \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,vcl_filter_bmp, \
+    comphelper \
+    cppu \
+    sal \
+    test \
+    tl \
+    unotest \
+    utl \
+    vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,vcl_filter_bmp))
+
+$(eval $(call gb_CppunitTest_use_ure,vcl_filter_bmp))
+$(eval $(call gb_CppunitTest_use_vcl,vcl_filter_bmp))
+
+$(eval $(call gb_CppunitTest_use_rdb,vcl_filter_bmp,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,vcl_filter_bmp,\
+       officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,vcl_filter_bmp))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index f2b4058d876c..3c9ef13c011b 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -212,6 +212,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\
         CppunitTest_vcl_pdfium_library_test) \
     $(if $(filter SKIA,$(BUILD_TYPE)), \
         CppunitTest_vcl_skia) \
+    CppunitTest_vcl_filter_bmp \
     CppunitTest_vcl_filter_igif \
 ))
 
diff --git a/vcl/qa/cppunit/filter/bmp/bmp.cxx 
b/vcl/qa/cppunit/filter/bmp/bmp.cxx
new file mode 100644
index 000000000000..4cf04c4843a2
--- /dev/null
+++ b/vcl/qa/cppunit/filter/bmp/bmp.cxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <test/bootstrapfixture.hxx>
+
+#include <tools/stream.hxx>
+#include <unotest/directories.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/graphicfilter.hxx>
+
+using namespace com::sun::star;
+
+namespace
+{
+char const DATA_DIRECTORY[] = "/vcl/qa/cppunit/filter/bmp/data/";
+
+/// Covers vcl/source/gdi/dibtools.cxx fixes.
+class Test : public test::BootstrapFixture
+{
+};
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf73523)
+{
+    GraphicFilter aGraphicFilter;
+    test::Directories aDirectories;
+    OUString aURL = aDirectories.getURLFromSrc(DATA_DIRECTORY) + 
"tdf73523.bmp";
+    SvFileStream aStream(aURL, StreamMode::READ);
+    Graphic aGraphic = aGraphicFilter.ImportUnloadedGraphic(aStream);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: c[80000000]
+    // - Actual  : c[00000000]
+    // i.e. the pixel is red not black
+    CPPUNIT_ASSERT_EQUAL(COL_RED, aGraphic.GetBitmapEx().GetPixelColor(0, 0));
+}
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/filter/bmp/data/tdf73523.bmp 
b/vcl/qa/cppunit/filter/bmp/data/tdf73523.bmp
new file mode 100644
index 000000000000..f4364ea3e841
Binary files /dev/null and b/vcl/qa/cppunit/filter/bmp/data/tdf73523.bmp differ
diff --git a/vcl/qa/cppunit/graphicfilter/data/bmp/fail/crash-1.bmp 
b/vcl/qa/cppunit/graphicfilter/data/bmp/pass/crash-1.bmp
similarity index 100%
rename from vcl/qa/cppunit/graphicfilter/data/bmp/fail/crash-1.bmp
rename to vcl/qa/cppunit/graphicfilter/data/bmp/pass/crash-1.bmp
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index c846d0a3a60c..99ec4af8f386 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -537,7 +537,6 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, 
BitmapWriteAccess& r
         // Read color mask
         if(bTCMask && BITFIELDS == rHeader.nCompression)
         {
-            rIStm.SeekRel( -12 );
             rIStm.ReadUInt32( nRMask );
             rIStm.ReadUInt32( nGMask );
             rIStm.ReadUInt32( nBMask );

Reply via email to