Results 1 to 2 of 2

Thread: Faulty image when redering from a Painter device

  1. #1
    Join Date
    May 2012
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Faulty image when redering from a Painter device

    Hi Folks,

    I use the following code to save a selection of a scene into a file (Qt 4.7.4):
    Qt Code:
    1. if (mpScene->selectedItems().isEmpty()) return;
    2. QList<QGraphicsItem*> items(mpScene->selectedItems());
    3. QRect sourceRect;
    4. boostForeach(QGraphicsItem* item, items) {
    5. sourceRect = sourceRect.united(item->sceneBoundingRect().toRect());
    6. }
    7. QImage img(sourceRect.size(),QImage::Format_ARGB32_Premultiplied);
    8. QPainter p(&img);
    9. mpView->scene()->clearSelection();
    10. mpView->scene()->render(&p, QRectF(), sourceRect);
    11. p.end();
    12. QString path = QFileDialog::getSaveFileName(0,tr("Choose Image-File Destination"));
    13. img.save(path,"JPG",100);
    To copy to clipboard, switch view to plain text mode 

    While the code works fine, the result is not satisfactory at all.
    The following image is what I get:

    test2.jpg


    It seems like the renderer stops it's work in the middle or some cache is not written.
    This does not happen with bigger scenes but selections rectangles are almost always corrupted
    Has anybody any idea where this might come from ?

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Faulty image when redering from a Painter device

    Heed the warning here.

Similar Threads

  1. painter not active
    By athulms in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2011, 17:02
  2. Painter not active
    By bainedyal in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2011, 10:06
  3. Replies: 1
    Last Post: 2nd December 2010, 15:01
  4. Replies: 5
    Last Post: 20th October 2009, 07:18
  5. Painter greyscale, image quality paint-brush!
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 22nd March 2007, 20:32

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.