Results 1 to 4 of 4

Thread: QPixmap transparancy

  1. #1
    Join Date
    Oct 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPixmap transparancy

    Hi,

    I am trying to load a .BMP file into a QPixmap and then retrieve a HBITMAP handle so I can to do some Windows specific stuff. However, when I do this I am still seeing the background colour. How do I go about masking out the background colour in the pixmap?

    At present I am attempting this:
    Qt Code:
    1. QPixmap telescopePixmap( ":/images/Tscpblue.bmp" );
    2. m_telescopeImage = telescopePixmap.toWinHBITMAP( QPixmap::PremultipliedAlpha );
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap transparancy

    I got this sorted out. It just needed the extra line of code as follows:
    Qt Code:
    1. QPixmap telescopePixmap( ":/images/Tscpblue.bmp" );
    2. telescopePixmap.setMask( telescopePixmap.createHeuristicMask() );
    3. m_telescopeImage = telescopePixmap.toWinHBITMAP( QPixmap::PremultipliedAlpha );
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: QPixmap transparancy

    Don't you just love it when people solve their problems on their own?

  4. #4
    Join Date
    Oct 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap transparancy

    Yes. Sometimes just talking it through does the trick

Similar Threads

  1. Convert QPixmap to QByteArray ?
    By probine in forum Qt Programming
    Replies: 5
    Last Post: 13th March 2014, 08:23
  2. QPixmap into QTextBrowser
    By xgoan in forum Qt Programming
    Replies: 6
    Last Post: 3rd November 2006, 13:05
  3. QPixmap -> HICON trouble.
    By krivenok in forum Qt Programming
    Replies: 1
    Last Post: 11th August 2006, 15:51
  4. Loading a custom image into a QPixmap
    By KShots in forum Qt Programming
    Replies: 12
    Last Post: 5th August 2006, 00:16
  5. QPixmap and HBITMAP
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2006, 16:24

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.