diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-03-05 19:55:43 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-03-12 15:37:21 +0100 |
commit | e1d0846e060d2b3faedfe1a5877303037d8cf4d6 (patch) | |
tree | c232b6fcc14b77ff1022a3bc42277c9827324d17 /sd | |
parent | e286bd791bfaa00746ea143303761f76e0af1f0d (diff) |
drop PNGReader and use only PngImageReader
PNGReader is a home-made PNG reader that does not use libpng,
so it's more code, presumably less optimized and it apparently also
doesn't always map colors properly.
The only two features it has that PngImageReader doesn't are explicit
chunk reading (used only for reading Microsoft's GIF in PNG, I
implemented that for PngImageReader in a previous commit), and it
loads paletted images as BitmapEx with a palette instead of
converting to direct-color 24/32bpp or 8bpp-gray. The latter is even
questional if nowadays that's feature or a misfeature, as it saves
memory at the expense of speed. I can implement that if somebody
misses it.
I had to adjust some tests:
- CVE-2016-0952-1.png - invalid CRC of the PNG header, neither Gimp
nor Gwenview can display that, it should fail
- afl-sample-Z_NEED_DICT.png - failure while decompressing data,
but the loader considers that only a partially broken image since
the header is correct, so it "passes" (like in Gimp or Gwenview)
- SdImportTest::testTdf134210() and
testPictureWithSchemeColor::Load_Verify_Reload_Verify()
need the colors tested changed, because apparently gamma correction
or something is now applied correctly, and it wasn't before (again
checked the loaded images with Gimp)
Change-Id: Id46f8d8a01256daf48ca64264b47c4e609183837
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112042
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/export-tests-ooxml1.cxx | 6 | ||||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 16 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx | 6 |
3 files changed, 14 insertions, 14 deletions
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 1e5f673428c2..4972669e4b82 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -54,7 +54,7 @@ #include <svx/svdotable.hxx> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <rtl/uri.hxx> -#include <vcl/pngread.hxx> +#include <vcl/filter/PngImageReader.hxx> using namespace css; @@ -1344,8 +1344,8 @@ void SdOOXMLExportTest1::testNarrationMimeType() OUString aImageRelName; CPPUNIT_ASSERT(aImageAbsName.startsWith("file:///", &aImageRelName)); std::unique_ptr<SvStream> pImageStream = parseExportStream(aTempFile, aImageRelName); - vcl::PNGReader aReader(*pImageStream); - BitmapEx aBitmapEx = aReader.Read(); + vcl::PngImageReader aReader(*pImageStream); + BitmapEx aBitmapEx = aReader.read(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 256 // - Actual : 120 diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 12560e90d586..cce54cb16e4f 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -92,7 +92,7 @@ #include <comphelper/sequenceashashmap.hxx> #include <comphelper/graphicmimetype.hxx> #include <comphelper/lok.hxx> -#include <vcl/pngread.hxx> +#include <vcl/filter/PngImageReader.hxx> #include <vcl/BitmapReadAccess.hxx> #include <vcl/dibtools.hxx> #include <svx/svdograf.hxx> @@ -1614,8 +1614,8 @@ void SdImportTest::testTdf113163() xGraphicExporter->filter(aDescriptor); SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ); - vcl::PNGReader aPNGReader(aFileStream); - BitmapEx aBMPEx = aPNGReader.Read(); + vcl::PngImageReader aPNGReader(aFileStream); + BitmapEx aBMPEx = aPNGReader.read(); // make sure the bitmap is not empty and correct size (PNG export->import was successful) CPPUNIT_ASSERT_EQUAL(Size(100, 100), aBMPEx.GetSizePixel()); @@ -1665,8 +1665,8 @@ void SdImportTest::testTdf93124() xGraphicExporter->filter(aDescriptor); SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ); - vcl::PNGReader aPNGReader(aFileStream); - BitmapEx aBMPEx = aPNGReader.Read(); + vcl::PngImageReader aPNGReader(aFileStream); + BitmapEx aBMPEx = aPNGReader.read(); // make sure the bitmap is not empty and correct size (PNG export->import was successful) CPPUNIT_ASSERT_EQUAL(Size(320, 180), aBMPEx.GetSizePixel()); @@ -1730,8 +1730,8 @@ void SdImportTest::testTdf99729() xGraphicExporter->filter(aDescriptor); SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ); - vcl::PNGReader aPNGReader(aFileStream); - BitmapEx aBMPEx = aPNGReader.Read(); + vcl::PngImageReader aPNGReader(aFileStream); + BitmapEx aBMPEx = aPNGReader.read(); Bitmap aBMP = aBMPEx.GetBitmap(); Bitmap::ScopedReadAccess pRead(aBMP); for (tools::Long nX = 154; nX < (154 + 12); ++nX) @@ -2768,7 +2768,7 @@ void SdImportTest::testTdf134210() Graphic aGraphic(xGraphic); BitmapEx aBitmap(aGraphic.GetBitmapEx()); - CPPUNIT_ASSERT_EQUAL( Color(6708292), aBitmap.GetPixelColor( 0, 0 )); + CPPUNIT_ASSERT_EQUAL( Color(6313534), aBitmap.GetPixelColor( 0, 0 )); xDocShRef->DoClose(); } diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx index 04b99dbf6c15..d4da935ddd0c 100644 --- a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx +++ b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx @@ -21,7 +21,7 @@ #include <tools/stream.hxx> #include <vcl/bitmapex.hxx> -#include <vcl/pngread.hxx> +#include <vcl/filter/PngImageReader.hxx> #include <vcl/pngwrite.hxx> namespace sd::slidesorter::cache { @@ -180,8 +180,8 @@ BitmapEx PngCompression::Decompress ( if (pData != nullptr) { SvMemoryStream aStream (pData->mpData, pData->mnDataSize, StreamMode::READ); - vcl::PNGReader aReader (aStream); - aResult = aReader.Read().GetBitmap(); + vcl::PngImageReader aReader (aStream); + aResult = aReader.read().GetBitmap(); } return aResult; |