Results 1 to 5 of 5

Thread: ARGB32 png blending of alpha layer in transparent background

  1. #1
    Join Date
    Mar 2016
    Posts
    6
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default ARGB32 png blending of alpha layer in transparent background

    I'm using a custom hardware display driver that is realized as a linuxfb. I'm trying to display an image and perform the alpha blending operation in hardware. The code below passes the alpha layer of the image through fine (and the rest of the main application window is transparent as I'd expect). But, qt seems to be pre-applying the alpha layer to the image and blending with zeros. Is there a way to tell Qt just to pass the image colors through without applying the alpha value to the pixel data?

    this->setStyleSheet("background:transparent");
    QImage img;
    img.load(":/images/images/box.png");
    ui->label2->setPixmap(QPixmap::fromImage(img));

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ARGB32 png blending of alpha layer in transparent background

    Maybe the image format is one that pre-applies the alpha value.

    Have you tried creating and empty image with fully separated channel data, e.g. QImage::Format_ARGB32, then setting the pixel values manually and then checking if they arrive correctly?

    Cheers,
    _

  3. #3
    Join Date
    Mar 2016
    Posts
    6
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: ARGB32 png blending of alpha layer in transparent background

    Yeah, it's a good thought. But, if I do img.format() it returns 5 or the enumerated value QImage::Format_ARGB32.

    Maybe I should be drawing the image in a different manner than using a QLabel?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ARGB32 png blending of alpha layer in transparent background

    You could try using QPainter::drawImage() in the paintEvent() of a custom widget class.

    However, since QPixmap is supposed to be the platform specific graphics device related image type, it could be that the platform abstraction plugin does not correctly detect that you want to have ARGB as the native format.

    I'd recommend checking the Linuxfb QPA code.
    On a quick check it looks like it is using RGB_16 as the format for it screen images:
    https://code.woboq.org/qt5/qtbase/sr...9QFbScreenC1Ev

    Cheers,
    _

  5. #5
    Join Date
    Mar 2016
    Posts
    6
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: ARGB32 png blending of alpha layer in transparent background

    Thanks. That's a good idea to start looking at the linuxfb constructor. I'll start playing with the code.

Similar Threads

  1. Transparent Widgets and alpha blending
    By idoroth in forum Newbie
    Replies: 2
    Last Post: 16th October 2011, 09:02
  2. Replies: 0
    Last Post: 8th November 2010, 21:17
  3. Replies: 3
    Last Post: 10th September 2010, 09:06
  4. Transparent background on QLabel on transparent QWidget
    By codeslicer in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 02:10
  5. Alpha blending..
    By chethana in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2007, 10:15

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.