Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.2.0 RC2
-
None
-
2a546690bf457f4bfee0910ba979441511843f8b (qt/qtbase/dev) 4901e9215b9a406ca45e6efe676cf21961f7d774 (qt/qtbase/6.2)
Description
When executing the following code
#include <QGuiApplication> #include <QImage> #include <QPainter> #include <QPdfWriter> static const int TEXTURE_SIZE = 64; static const int PAINT_SCALE = 40; static const int PAINT_SIZE = 256; static QImage createTexture() { QImage image(TEXTURE_SIZE, TEXTURE_SIZE, QImage::Format_ARGB32); QPainter p(&image); p.setPen(Qt::NoPen); p.fillRect(0, 0, TEXTURE_SIZE, TEXTURE_SIZE, Qt::red); p.setBrush(QBrush(Qt::white, Qt::BDiagPattern)); p.drawRect(0, 0, TEXTURE_SIZE, TEXTURE_SIZE); p.end(); return image; } static void drawOnPainter(QPainter *painter) { painter->setPen(Qt::NoPen); painter->scale(PAINT_SCALE, PAINT_SCALE); QBrush brush(createTexture()); brush.setTransform(painter->worldTransform().inverted()); painter->setBrush(brush); painter->drawRect(0, 0, PAINT_SIZE, PAINT_SIZE); } static void drawOnPdf() { QPdfWriter pdf("test.pdf"); pdf.setResolution(72); pdf.setPageSize(QPageSize::A4); QPainter p(&pdf); drawOnPainter(&p); p.end(); } static void drawOnImage() { QImage i(700, 700, QImage::Format_ARGB32); QPainter p(&i); drawOnPainter(&p); p.end(); i.save("test.png"); } int main (int argc, char **argv) { QGuiApplication app(argc, argv); drawOnPdf(); drawOnImage(); return 0; }
The generated PDF file is "terrible" compared to the PNG file (attached both)
Attachments
For Gerrit Dashboard: QTBUG-96978 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
373978,1 | QPdfEngine: Don't say the it supports PatternTransform | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |
374484,3 | Support transformations in pattern/texture brushes in pdf | dev | qt/qtbase | Status: MERGED | +2 | 0 |
375312,2 | Support transformations in pattern/texture brushes in pdf | 6.2 | qt/qtbase | Status: MERGED | +2 | 0 |