Results 1 to 12 of 12

Thread: Raw Images on Qt Widget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Raw Images on Qt Widget

    If you want to draw a cross or a tick on top of the image, you will need to convert the image from indexedColor:

    Qt Code:
    1. // Load GrayScale as 8-bit-IndexedColor
    2. QImage image(buff,280,352,280,QImage::Format_Indexed8);
    3. // Setup Color-Table
    4. QVector<QRgb> colorTable(256);
    5. for(int i=0;i<256;++i)
    6. colorTable[i] = qRgb(i,i,i);
    7. image.setColorTable(colorTable);
    8. // Convert to RGB32 for painter
    9. QImage image2 = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
    10. QPainter painter(image2);
    11. painter.drawLine(...)
    12. ..
    13. ui->label->setPixmap(QPixmap::fromImage(image2));
    To copy to clipboard, switch view to plain text mode 

    Does that do the trick?

    Joh
    Last edited by JohannesMunk; 19th March 2010 at 13:51.

Similar Threads

  1. Images
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2009, 15:22
  2. Replies: 4
    Last Post: 27th July 2009, 15:45
  3. How can I change widget images and layouts?
    By sendyou in forum Qt Programming
    Replies: 1
    Last Post: 20th August 2008, 11:07
  4. Display multiple Images in a widget
    By jeetu_happy in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2007, 11:24
  5. Widget to display images and text ?
    By probine in forum Qt Tools
    Replies: 4
    Last Post: 9th October 2006, 20:49

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
  •  
Qt is a trademark of The Qt Company.