Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
4.8.4, 5.0.2, 5.1.0 Beta 1
-
Windows 7, Linux
Linux: Okular, Google Chrome
-
624740cdcdd4abfb15bbbc8a8aa056c57712499f
Description
Run the following code. As a result, "kjg.pdf" and "kjg.png" is created using the same image. Pdf, which is created using QPrinter, does NOT look correct. Png, which uses QImage::save(), looks correct.
#include <QApplication> #include <QPrinter> #include <QPainter> #include <QImage> #include <QString> int main( int argc, char **argv ) { QApplication app( argc, argv ); double dpi = 300.0; // Setup 8.5 x 11 inch printer //------------------------------- QPrinter *printer = new QPrinter( QPrinter::HighResolution ); printer->setOutputFormat( QPrinter::PdfFormat ); printer->setFullPage( true ); printer->setOutputFileName( "kjg.pdf" ); printer->setColorMode( QPrinter::Color ); printer->setOrientation( QPrinter::Portrait ); printer->setPaperSize( QSizeF( 8.5, 11 ), QPrinter::Inch ); printer->setResolution( (int) dpi ); // Setup 8.5 x 11 @ 300 dpi raster image. //----------------------------------------- QImage *outImg = new QImage( 2550, 3300, QImage::Format_ARGB32 ); // Create out painters //---------------------- QList<QPainter *> painters; painters.append( new QPainter( printer ) ); painters.append( new QPainter( outImg ) ); // Image to draw. //---------------- int w = 100; int h = 1000; QImage *img = new QImage( w, h, QImage::Format_ARGB32 ); img->fill( qRgba( 255, 0, 0, 128 ) ); for( int j = 0; j < 2; j++ ) { if( ! painters[j]->isActive() ) { qDebug( "Painter not active." ); delete outImg; delete printer; return( 0 ); } painters[j]->setRenderHint( QPainter::Antialiasing ); int x = 10; int y = 100; int prevX; for( int i = 0; i < 10; i++ ) { if( i != 0 ) { x = prevX + w; // Play with this value to see the different behavior. // x += 1; } prevX = x; painters[j]->drawImage( x, y, *img ); } painters[j]->end(); } outImg->save( "kjg.png", "PNG" ); delete img; delete outImg; delete printer; return( 0 ); }
Attachments
Issue Links
- is required for
-
QTBUG-25379 QtPrintSupport - PDF Issues
- Open
-
QTBUG-37693 QtPrintSupport - Painting Issues
- Open
-
QTBUG-37713 QtPrintSupport - 5.3 issues
- Open
Gerrit Reviews
For Gerrit Dashboard: QTBUG-31540 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
97703,3 | Fix printing of semitransparent images to PDF | 5.4 | qt/qtbase | Status: MERGED | +2 | 0 |