diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-03-27 11:53:40 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2019-03-29 10:22:41 +0100 |
commit | ea97248f39b2bcf65bc8aaf0577f49ca64b0e79f (patch) | |
tree | 901328e6cae25cc4e4e5b9714312249b3517e00d /vcl/qa/cppunit | |
parent | 89e5b431d468745da3a1eff14d48296107b9101b (diff) |
check that jpeg export of 8bit grayscale works
This is a simpler check for 77146ca8193a8e258dbb0dae0793497a66734ff1
(related to tdf#121615).
Change-Id: I33b92f07bebeb735466e0728c6c51b79fc0b5bb8
Reviewed-on: https://gerrit.libreoffice.org/69820
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r-- | vcl/qa/cppunit/jpeg/JpegWriterTest.cxx | 18 | ||||
-rw-r--r-- | vcl/qa/cppunit/jpeg/data/8BitGrayscale.jpg | bin | 0 -> 1384 bytes |
2 files changed, 18 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx b/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx index a81d0c478ff9..9ce9eb43bfd6 100644 --- a/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx +++ b/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx @@ -29,9 +29,11 @@ class JpegWriterTest : public test::BootstrapFixtureBase BitmapEx roundtripJPG(const OUString& aURL); public: + void testWrite8BitGrayscale(); void testWrite8BitNonGrayscale(); CPPUNIT_TEST_SUITE(JpegWriterTest); + CPPUNIT_TEST(testWrite8BitGrayscale); CPPUNIT_TEST(testWrite8BitNonGrayscale); CPPUNIT_TEST_SUITE_END(); }; @@ -64,6 +66,22 @@ BitmapEx JpegWriterTest::roundtripJPG(const BitmapEx& bitmap) return aImportGraphic.GetBitmapEx(); } +void JpegWriterTest::testWrite8BitGrayscale() +{ + Bitmap bitmap = roundtripJPG(getFullUrl("8BitGrayscale.jpg")).GetBitmap(); + Bitmap::ScopedReadAccess access(bitmap); + const ScanlineFormat format = access->GetScanlineFormat(); + // Check that it's still 8bit grayscale. + CPPUNIT_ASSERT_EQUAL(ScanlineFormat::N8BitPal, format); + CPPUNIT_ASSERT(bitmap.HasGreyPalette()); + // Check that the content is valid. + CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE), access->GetColor(0, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE), access->GetColor(0, access->Width() - 1)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE), access->GetColor(access->Height() - 1, 0)); + CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_BLACK), + access->GetColor(access->Height() - 1, access->Width() - 1)); +} + void JpegWriterTest::testWrite8BitNonGrayscale() { Bitmap bitmap = roundtripJPG(getFullUrl("8BitNonGrayscale.gif")).GetBitmap(); diff --git a/vcl/qa/cppunit/jpeg/data/8BitGrayscale.jpg b/vcl/qa/cppunit/jpeg/data/8BitGrayscale.jpg Binary files differnew file mode 100644 index 000000000000..91541e4a858a --- /dev/null +++ b/vcl/qa/cppunit/jpeg/data/8BitGrayscale.jpg |