summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r--vcl/qa/cppunit/jpeg/JpegWriterTest.cxx18
-rw-r--r--vcl/qa/cppunit/jpeg/data/8BitGrayscale.jpgbin0 -> 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
new file mode 100644
index 000000000000..91541e4a858a
--- /dev/null
+++ b/vcl/qa/cppunit/jpeg/data/8BitGrayscale.jpg
Binary files differ