Results 1 to 8 of 8

Thread: HELP PLEASE- Superimpose two images in a QPixmap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: HELP PLEASE- Superimpose two images in a QPixmap

    Zero in the alpha channel makes a pixel totally transparent, and 1.0 (255 when expressed as 8 bit int) makes it totally opaque.

    I gather you want a partly transparent top image to be drawn over the bottom image.

    Qt Code:
    1. QImage top("top.jpg");
    2. QImage bot("bottom.jpg");
    3. // both images are opaque because JPEG has no alpha channel
    4.  
    5. QPixmap combined(bot.size());
    6. QPainter p(&combined);
    7. p.drawImage(QPoint(0, 0), bot); // drawn as-is
    8. p.setOpacity(0.2);
    9. p.drawImage(QPoint(0, 0), top); // drawn at 20% opacity
    10. p.end();
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to ChrisW67 for this useful post:

    NoQuiteFeynman (30th August 2013)

Similar Threads

  1. QPixMap doesn't show one of two images !
    By ladiesfinger in forum Qt Programming
    Replies: 5
    Last Post: 10th January 2011, 16:29
  2. Replies: 4
    Last Post: 28th August 2008, 13:13
  3. Replies: 1
    Last Post: 21st August 2008, 07:44
  4. Replies: 5
    Last Post: 9th April 2007, 14:26
  5. [QT3] QToolTip with Images (QPixMap) ?
    By BrainB0ne in forum Qt Programming
    Replies: 4
    Last Post: 27th January 2006, 08:31

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.