Results 1 to 3 of 3

Thread: how to merge QPixmaps

  1. #1
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default how to merge QPixmaps

    Hello,

    I have 3 QPixmaps and I'd like to merge them (put them on top of each other). What's the best way to do that?
    So, I have 3 images (A,B,C) and I want to make 1 composite image (D) out of the three.
    I want to define that A is the bottom image, B is the middle image and C is the top image.
    So, C should get the highest priority. If parts of C are transparent, only then should the corresponding part of B show. And if C and B are both transparent, only then should the corresponding parts of A show. Just like in real life when you stack images that have transparent regions.
    I'm pretty sure that I have seen a sample code here in this site (and the code was elegantly simple) but I just can't find it again.
    I'm thankful for any ideas.

  2. #2
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to merge QPixmaps

    Painting all three pixmaps on a new one should do it, Right?

  3. #3
    Join Date
    Nov 2007
    Posts
    17
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to merge QPixmaps

    look this: http://www.qtcentre.org/forum/f-qt-p...mage-7485.html

    My solution is a bit different but I'm quite happy with

    Qt Code:
    1. QIcon icon1(":/Resources/Icon1.png");
    2. QPixmap icon2(":/Resources/Icon2.png");
    3. QPixmap pixmap= icon1.pixmap(QSize(32,32));
    4.  
    5. // paints a midget of icon2 onto icon1
    6. icon2 = icon2.scaled(QSize(12,12),Qt::KeepAspectRatio, Qt::SmoothTransformation);
    7. QPainter painter(&pixmap);
    8. painter.drawPixmap(0,pixmap.height()-icon2.height(),icon2);
    9. ui.btnImage->setIcon(pixmap);
    To copy to clipboard, switch view to plain text mode 
    Last edited by montuno; 27th March 2008 at 12:14.

Similar Threads

  1. How to merge QTableView and QTreeView ???
    By Xaleandr in forum Newbie
    Replies: 2
    Last Post: 29th December 2007, 17:58
  2. Are transparent QPixmaps possible?
    By eric in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2007, 20:43
  3. SVG to alpha channel QPixmaps?
    By WinchellChung in forum Newbie
    Replies: 5
    Last Post: 24th August 2007, 21:07
  4. Can I split file and merge them.
    By safknw in forum Newbie
    Replies: 1
    Last Post: 3rd October 2006, 09:40
  5. Replies: 7
    Last Post: 18th July 2006, 21:33

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.