Results 1 to 2 of 2

Thread: change pixmap color, clip background

  1. #1
    Join Date
    Nov 2013
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default change pixmap color, clip background

    hi

    i have a pixmap from a png picture
    now i want to paint all pixels of this pixmap more red or blue for example, but ignore the background
    i tried to createmaskfromcolor function but it doesnt work.

    with setting the opacity i get the desired effect but the white background is also drawn in red.

    Qt Code:
    1. QColor color;
    2. QPixmap input=*CurrObject->getImage(TypeValues[ComboBoxType->currentIndex()]);
    3. QImage image(input.size(), QImage::Format_ARGB32_Premultiplied);
    4. color=Qt::red;
    5. image.fill(color);
    6. QPainter p(&image);
    7. p.setOpacity(0.5);
    8. p.drawPixmap(0,0,input);
    9. p.end();
    10. QPixmap output = QPixmap::fromImage(image);
    11. ui->Label2D->setPixmap(output);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2013
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: change pixmap color, clip background

    got it!
    just had to add
    Qt Code:
    1. output.setMask(input.mask());
    To copy to clipboard, switch view to plain text mode 
    at the end

Similar Threads

  1. cannot change QLCDNumber background color
    By saman_artorious in forum Qt Programming
    Replies: 2
    Last Post: 13th March 2013, 16:04
  2. How to change the color of background of QMainwindow?
    By weixj2003ld in forum Qt Programming
    Replies: 4
    Last Post: 5th July 2012, 23:56
  3. Replies: 1
    Last Post: 17th August 2010, 16:17
  4. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 07:14
  5. Change background color for a QPushButton?
    By Harvey West in forum Qt Programming
    Replies: 6
    Last Post: 5th January 2007, 14:23

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.