Results 1 to 8 of 8

Thread: QPixmap(image) to transparent HBITMAP

  1. #1
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question QPixmap(image) to transparent HBITMAP

    i read about this problem some solution but don't work.

    shortly i want to do this;

    QPixmap pix;
    pix.load(":XXX/Resources/r1.png"); // transparent png file
    pix.toWinHBITMAP(QPixmap::PremultipliedAlpha); // but this is not transparent


    this is not transparent. it has black background.

    if somebody help me or give me a link about that i will be very happy.

    thank you...

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap(image) to transparent HBITMAP

    Hi,

    The QPixmap doc says:

    The HBITMAP is treated as having a alpha channel and premultiplied colors. This is preferred if the HBITMAP is accessed through the AlphaBlend() GDI function.

    So, the HBITMAP has alpha channel but it don't say that converts the pixmap to a transparent HBITMAP.
    When you get the HBITMAP you need to change the alpha channel value of the pixels to obtain the desired image.
    Òscar Llarch i Galán

  3. #3
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap(image) to transparent HBITMAP

    Can you give me an example?

  4. #4
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap(image) to transparent HBITMAP

    Hi,

    Has the orginal image a black background?
    Òscar Llarch i Galán

  5. #5
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap(image) to transparent HBITMAP

    No, it has transparent background.

  6. #6
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap(image) to transparent HBITMAP

    Hi,

    Can you get alpha values from a converted pixel? Which values you get it?
    Òscar Llarch i Galán

  7. #7
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap(image) to transparent HBITMAP

    hasAlpha() = 1
    hasAlphaChannel() = 1

    alphaChannel() is return only where is transparent pixels with black background.

  8. #8
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap(image) to transparent HBITMAP

    Hi,

    And wich value of the alpha channel are you getting on a background pixel?
    255 -> full color
    0 -> transparency (don't remember if 255=full color and 0=transparency or inverse).
    Òscar Llarch i Galán

Similar Threads

  1. How to set Qt window transparent?
    By montylee in forum Qt Programming
    Replies: 17
    Last Post: 24th December 2013, 20:11

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.