Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]Alpha composition in a QGraphicsScene with two overlayed QPixmap
Forum Updated to NodeBB v4.3 + New Features

[solved]Alpha composition in a QGraphicsScene with two overlayed QPixmap

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #1

    I have a main window with 2 QGraphicsScene, each containing 2 QPixmap.
    For both QGraphicsScene, the first QPixmap is a greyscale image.
    And the second one (drawn on top) is a color ARGB image with transparency.

    If the ARGB image has binary transparency (0 or 255) the rendering is exactly what I expect.
    But if this image has semi transparent pixel, then the composition is a total mess.

    "Correct (binary transparency)":http://pix.wefrag.com/i/a/d/2/d/f/44739f9da96542a083a794ed2eff5531.png :
    !http://pix.wefrag.com/i/a/d/2/d/f/th15044739f9da96542a083a794ed2eff5531.png(correct)!
    "Incorrect":http://pix.wefrag.com/i/3/9/4/3/c/44740cc2d86c965681266a8ab130904f.png
    !http://pix.wefrag.com/i/3/9/4/3/c/th15044740cc2d86c965681266a8ab130904f.png(incorrect)!
    "Overlay renderered on white":http://pix.wefrag.com/i/9/d/6/e/e/44741efd1dd259bfbd164bb8f92c6b34.png
    !http://pix.wefrag.com/i/9/d/6/e/e/th15044741efd1dd259bfbd164bb8f92c6b34.png(white)!

    What am I forgetting?
    Thanks a lot for your help!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      How are you drawing the two pixmaps? Can you paste the two images as well as a testcase?

      My first suspect in such a case are roundoff errors, but it's impossible to say without seeing some code.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        Thanks for your answer.
        I first fill a 4 channel uchar[] buffer that I convert to a QImage with: @QImage image(buffer, imgW, imgH, 4*imgW, QImage::Format_ARGB32_Premultiplied);@ I tried to save a png @image.save("overlay2.png");@ but when I open it with photoshop:

        • the background is transparent
        • the colored pixels are not (just like if they had been merged with a white background)
          I have the feeling that my alpha are not correct, but can I trust that png to debug my code?
        1 Reply Last reply
        0
        • J Offline
          J Offline
          JulienMaille
          wrote on last edited by
          #4

          I fixed a few mistakes, but I still have one big issue:

          • pixels with alpha=0 are transparent
          • pixels with alpha=255 show a correct color
          • pixels with alpha€[1-254] have a correct transparency but they are gray!!??

          EDIT: fixed by removing the premultiplied flag. If you had not asked for my images, I'm not sure I had searched bugs in this place!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved