Results 1 to 5 of 5

Thread: Qpixmap of 32 bit Depth

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Qpixmap of 32 bit Depth

    Dear all,

    One of my third party library needs a Qpixmap which should be of ARGB(32) format to enable the transparency. By default in Linux Qpixmap is of 24 bit depth.

    I have tried the below method for conversion and passed the Qpixmap, and still it shows as 24 bit depth....How do i create a pixmap of 32 bit depth in Qt.

    Qt Code:
    1. QImage overlay_image(768,768,QImage::Format_ARGB32);
    2.  
    3. bool loaded = overlay_image.load ("/aegea.png", 0 );
    4.  
    5. QPixmap overlay_map;
    6.  
    7. overlay_map= overlay_map.fromImage ( overlay_image,Qt::AutoColor );
    To copy to clipboard, switch view to plain text mode 

    Please advice me..

  2. #2
    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: Qpixmap of 32 bit Depth

    What is the data in aegea.png, because it is this you are manipulating (you discard the unitialised Format_ARGB32 QImage)? Are you doing anything with the QImage other than loading the file? If not, then why not just load the QPixmap directly?

    My example image is identified (ImageMagick) as:
    Qt Code:
    1. $ identify -verbose plane.png
    2. Image: plane.png
    3. Format: PNG (Portable Network Graphics)
    4. Class: DirectClass
    5. Geometry: 1040x138+0+0
    6. Resolution: 72x72
    7. Print size: 14.4444x1.91667
    8. Units: Undefined
    9. Type: TrueColorMatte
    10. Endianess: Undefined
    11. Colorspace: RGB
    12. Depth: 8-bit
    13. Channel depth:
    14. red: 8-bit
    15. green: 8-bit
    16. blue: 8-bit
    17. alpha: 8-bit
    18. ...
    To copy to clipboard, switch view to plain text mode 
    and is a mostly transparent banner of an aircraft with partial transparency of the spinning propeller. This code:
    Qt Code:
    1. // Your code with adjustment for static method
    2. QImage overlay_image(768,768,QImage::Format_ARGB32);
    3. bool loaded = overlay_image.load ("plane.png", 0 );
    4. QPixmap overlay_map = QPixmap::fromImage ( overlay_image,Qt::AutoColor );
    5. qDebug() << loaded;
    6. qDebug() << overlay_map.size() << overlay_map.depth() << overlay_map.hasAlphaChannel();
    7.  
    8. // Load the PNG directly
    9. overlay_map.load("plane.png");
    10. qDebug() << overlay_map.size() << overlay_map.depth() << overlay_map.hasAlphaChannel();
    To copy to clipboard, switch view to plain text mode 
    outputs
    Qt Code:
    1. true
    2. QSize(1040, 138) 32 true
    3. QSize(1040, 138) 32 true
    To copy to clipboard, switch view to plain text mode 
    on Linux, Qt 4.7.2.

Similar Threads

  1. QPixmap format, depth and quality
    By ascii in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2008, 15:27
  2. Image 32 bit depth to 8 bit depth
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 2nd September 2008, 09:35
  3. depth of QTreeWidgetItem
    By stefan in forum Newbie
    Replies: 3
    Last Post: 29th June 2008, 11:58
  4. Qtopia depth problem
    By paralyze in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 11th May 2007, 18:35

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.