Results 1 to 8 of 8

Thread: how to clean data in qimage with transparent?

  1. #1
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    2

    Question how to clean data in qimage with transparent?

    I want to draw a real time scan radar image on widget with background terrian data, so I want to clean previous data to no color with transparent to show background correctly , I try to use codes as following
    Qt Code:
    1. QColor qclr=QColor(Qt::tansparent);
    2. painter->setPen(qclr);
    3. painter->setBrush(qclr);
    4. painter->drawConvexPolygon(pg);
    To copy to clipboard, switch view to plain text mode 

    but it does not works, previous data are not cleared. if I replace color with Qt::gray ,it works but I can not see the background .

    I have read the post http://www.qtcentre.org/threads/3310...nsparent-color , it seem that there was no solution at that time ,how about now ?

    thanks

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to clean data in qimage with transparent?

    Hi, probably the data is not "cleared" because you paint above it with a transparent brush, so you can see through the newly painted pixels and see the old data.

    Have you tried wysota's solution from the other thread (set QPainter::QPainter::CompositionMode_Clear)?

    Ginsengelf

  3. The following user says thank you to Ginsengelf for this useful post:

    rolandsun (13th June 2012)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to clean data in qimage with transparent?

    What is the painter object working on? Is it a pixmap, a widget or what?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #4
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    2

    Default Re: how to clean data in qimage with transparent?

    painter works on QImage.

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to clean data in qimage with transparent?

    Why don't you just create an empty QImage and draw on that instead of clearing the one you have?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #6
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    2

    Default Re: how to clean data in qimage with transparent?

    In my case, I have to update the image every serveral milliseconds, only part of the image should be erased and repainted. so I think create a new QImage is infeasible.

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to clean data in qimage with transparent?

    In that case you should indeed use Clear composition mode.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    rolandsun (13th June 2012)

  10. #8
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    2

    Default Re: how to clean data in qimage with transparent?

    Finally QPainter::CompositionMode_Source works ,thanks.

Similar Threads

  1. QImage and Qt::transparent
    By babu198649 in forum Newbie
    Replies: 11
    Last Post: 13th February 2016, 18:51
  2. QImage data via FFmpeg
    By Degenko in forum Qt Programming
    Replies: 9
    Last Post: 14th September 2010, 04:05
  3. How can I create a transparent image with QImage?
    By learning_qt in forum Qt Programming
    Replies: 1
    Last Post: 28th January 2009, 15:06
  4. clean with transparent color
    By Lele in forum Qt Programming
    Replies: 9
    Last Post: 28th October 2007, 13:45
  5. Creating a QImage from uchar* data
    By forrestfsu in forum Qt Programming
    Replies: 6
    Last Post: 8th February 2007, 15:21

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.