Results 1 to 2 of 2

Thread: QPainter::drawImage randomly(?) omits some images

  1. #1
    Join Date
    Dec 2009
    Posts
    47
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default QPainter::drawImage randomly(?) omits some images

    Hi

    I need to print a series of small images (QR codes); 3 * 9 per page, total ~30 pages. The following code is called repeatedly.

    Qt Code:
    1. QImage bbcode;
    2. ...
    3. #ifdef QT_DEBUG
    4. painter.setPen(Qt::darkRed);
    5. painter.drawRect(textRect[Use4bbImage]);
    6. bbcode.save(QString(QStringLiteral("%1_%2.jpg")).arg(printQuery.value(0).toInt()).arg(printQuery.value(1).toInt()), 0, 100);
    7. qDebug() << "draw image" << bbcode << bbcode.rect() << "on" << textRect[Use4bbImage];
    8. #endif
    9. painter.drawImage(textRect[Use4bbImage], bbcode, bbcode.rect());
    To copy to clipboard, switch view to plain text mode 

    The debug output:
    Qt Code:
    1. draw image QImage(QSize(140, 140) ) QRect(0,0 140x140) on QRect(0,0 2000x2000)
    To copy to clipboard, switch view to plain text mode 
    Strangely, only appproximately half of the images are printed (on some pages almost all, on others only a few). The code above confirms that all three parameters to painter.drawImage are correct: the textRect[Use4bbImage] is the correct QRect (as the darkRed frame is drawn around the place where the image should be placed), the image bbcode exists (as it is correctly saved to a file), bbcode.rect() is always the same size (as per debug output).

    I use Qt 5.3.1 on linux (Ubuntu 12.04 LTS). The issue remains whether I print to pdf or whether I print to a real printer.

    Any ideas? How should I proceed to find the bug?

    Al_

  2. #2
    Join Date
    Dec 2009
    Posts
    47
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QPainter::drawImage randomly(?) omits some images

    Ok, I found a work-around.

    The images are QR codes that are for some reason stored as RGB images (but of course in reality only black and white is used). If I convert the images to monochrome prior to printing, then all are printed.

    I assume that the color-coded (but only b/w) images exceed some complexity limit of Qt. I would still be interested what the exact limitation is.

    Al_

Similar Threads

  1. Replies: 5
    Last Post: 13th November 2013, 02:54
  2. Factoring drawImage
    By Alundra in forum Qt Programming
    Replies: 0
    Last Post: 6th November 2013, 12:39
  3. How to draw a line with tiled images with QPainter?
    By MadBear in forum Qt Programming
    Replies: 5
    Last Post: 25th July 2011, 07:36
  4. Replies: 1
    Last Post: 29th June 2011, 17:52
  5. QPainter.drawImage() not working with resource image file
    By thiagoalencar22 in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2010, 22:07

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.