Debian Codegraph @

qt6/tests/check_overprint.cpp

raw
1 #include <QtTest/QTest>
2
3 #include <poppler-qt6.h>
4
5 #include <memory>
6
7 class TestOverprint : public QObject
8 {
9 Q_OBJECT
10 public:
11 explicit TestOverprint(QObject *parent = nullptr) : QObject(parent) { }
12 private Q_SLOTS:
13 void checkOverprintImageRendering();
14 };
15
16 void TestOverprint::checkOverprintImageRendering()
17 {
18 std::unique_ptr<Poppler::Document> doc = Poppler::Document::load(QStringLiteral(TESTDATADIR "/tests/mask-seams.pdf"));
19 QVERIFY(doc);
20
21 doc->setRenderHint(Poppler::Document::OverprintPreview, true);
22
23 std::unique_ptr<Poppler::Page> page = doc->page(0);
24 QVERIFY(page);
25
26 constexpr int width = 600;
27 constexpr int height = 400;
28
29 QImage img = page->renderToImage(300.0, 300.0, 0, 0, width, height);
30 QCOMPARE(img.format(), QImage::Format_RGB32);
31 QCOMPARE(img.width(), width);
32 QCOMPARE(img.height(), height);
33 QCOMPARE(img.bytesPerLine(), width * 4);
34 QCOMPARE(img.sizeInBytes(), width * height * 4);
35 }
36
37 QTEST_GUILESS_MAIN(TestOverprint)
38 #include "check_overprint.moc"