Kaydet (Commit) ea97248f authored tarafından Luboš Luňák's avatar Luboš Luňák

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: 's avatarLuboš Luňák <l.lunak@collabora.com>
üst 89e5b431
...@@ -29,9 +29,11 @@ class JpegWriterTest : public test::BootstrapFixtureBase ...@@ -29,9 +29,11 @@ class JpegWriterTest : public test::BootstrapFixtureBase
BitmapEx roundtripJPG(const OUString& aURL); BitmapEx roundtripJPG(const OUString& aURL);
public: public:
void testWrite8BitGrayscale();
void testWrite8BitNonGrayscale(); void testWrite8BitNonGrayscale();
CPPUNIT_TEST_SUITE(JpegWriterTest); CPPUNIT_TEST_SUITE(JpegWriterTest);
CPPUNIT_TEST(testWrite8BitGrayscale);
CPPUNIT_TEST(testWrite8BitNonGrayscale); CPPUNIT_TEST(testWrite8BitNonGrayscale);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -64,6 +66,22 @@ BitmapEx JpegWriterTest::roundtripJPG(const BitmapEx& bitmap) ...@@ -64,6 +66,22 @@ BitmapEx JpegWriterTest::roundtripJPG(const BitmapEx& bitmap)
return aImportGraphic.GetBitmapEx(); 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() void JpegWriterTest::testWrite8BitNonGrayscale()
{ {
Bitmap bitmap = roundtripJPG(getFullUrl("8BitNonGrayscale.gif")).GetBitmap(); Bitmap bitmap = roundtripJPG(getFullUrl("8BitNonGrayscale.gif")).GetBitmap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment