Results 1 to 8 of 8

Thread: HELP PLEASE- Superimpose two images in a QPixmap

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2013
    Posts
    4
    Thanks
    4

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

    Hello

    Thank you for the reply - it's much appreciated.

    Sorry if I'm being daft, but doesn't 255 specify no opacity? Please see:

    http://www.qtcentre.org/threads/1307...Qt-transparent

    Your further advice would be much appreciated.

    Kindest regards

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

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

    Quote Originally Posted by NoQuiteFeynman View Post
    Hello

    Thank you for the reply - it's much appreciated.

    Sorry if I'm being daft, but doesn't 255 specify no opacity? Please see:

    http://www.qtcentre.org/threads/1307...Qt-transparent
    I don't see any "255" in your code. Could you elaborate what you mean?
    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.


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

    NoQuiteFeynman (30th August 2013)

  4. #3
    Join Date
    Jul 2013
    Posts
    4
    Thanks
    4

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

    Hi

    Thanks for the continuing responses.

    I thought you meant that I need to use image.fill(qRgba(0,0,0,255)); for transparency! Other advice on the board says I need to use image.fill(qRgba(0,0,0,0)); for transparency.

    Should I use something else for transparency?

    Please advise.

    Kindest regards

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

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

    Quote Originally Posted by NoQuiteFeynman View Post
    Should I use something else for transparency?
    A transparent image that you render on the pixmap (be it transparent or not). I don't know what sizes your jpeg images have but assuming their size is somewhere close to 500x500, they will most probably cover the whole area of the pixmap so it doesn't matter if you "fill the pixmap with transparency" or not if you then draw a non-transparent image over it.
    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.


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

    NoQuiteFeynman (30th August 2013)

  7. #5
    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 

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

    NoQuiteFeynman (30th August 2013)

  9. #6
    Join Date
    Jul 2013
    Posts
    4
    Thanks
    4

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

    Hi

    This works, thank you very much for your help ChrisW67 and Wysota, it's very much appreciated!

    All the best.

    Kindest regards

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.