Results 1 to 5 of 5

Thread: Qpixmap of 32 bit Depth

  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.

  3. #3
    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

    Default Re: Qpixmap of 32 bit Depth

    Hi Chris,

    I did the same and found the properties of my image as below:

    I think it doesnt have alpha : 8 bit

    Qt Code:
    1. identify -verbose aegean-120km.png
    2. Image: aegean-120km.png
    3. Format: PNG (Portable Network Graphics)
    4. Class: DirectClass
    5. Geometry: 1292x1001+0+0
    6. Resolution: 37.79x37.79
    7. Print size: 34.1889x26.4885
    8. Units: PixelsPerCentimeter
    9. Type: TrueColor
    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. Channel statistics:
    18. red:
    19. min: 0 (0)
    20. max: 235 (0.921569)
    21. mean: 54.9768 (0.215595)
    22. standard deviation: 22.5171 (0.0883024)
    23. kurtosis: 1.95082
    24. skewness: 0.869281
    25. green:
    26. min: 3 (0.0117647)
    27. max: 243 (0.952941)
    28. mean: 74.8666 (0.293594)
    29. standard deviation: 21.6226 (0.0847946)
    30. kurtosis: 1.41052
    31. skewness: 0.226536
    32. blue:
    33. min: 1 (0.00392157)
    34. max: 241 (0.945098)
    35. mean: 93.5669 (0.366929)
    36. standard deviation: 31.2464 (0.122535)
    37. kurtosis: -0.907665
    38. skewness: -0.429502
    39. Image statistics:
    40. Overall:
    41. min: 0 (0)
    42. max: 243 (0.952941)
    43. mean: 55.8526 (0.21903)
    44. standard deviation: 41.3977 (0.162344)
    45. kurtosis: -0.988763
    46. skewness: 0.0747025
    47. Rendering intent: Saturation
    48. Gamma: 0.45455
    49. Chromaticity:
    50. red primary: (0.64,0.33)
    51. green primary: (0.3,0.6)
    52. blue primary: (0.15,0.06)
    53. white point: (0.3127,0.329)
    54. Interlace: None
    55. Background color: rgb(1,1,1)
    56. Border color: rgb(223,223,223)
    57. Matte color: grey74
    58. Transparent color: black
    59. Page geometry: 1292x1001+0+0
    60. Dispose: Undefined
    61. Iterations: 0
    62. Compression: Zip
    63. Orientation: Undefined
    64. Properties:
    65. date:create: 2011-05-19T10:17:37+06:00
    66. date:modify: 2010-11-29T18:15:51+06:00
    67. signature: e48cd3c45e0ab3014e55d9ae6f51de1d41f485add63ec622c074a58b31a39933
    68. Artifacts:
    69. verbose: true
    70. Tainted: False
    71. Filesize: 1.372mb
    72. Number pixels: 1.233mb
    73. Version: ImageMagick 6.5.4-7 2010-02-26 Q16 OpenMP http://www.imagemagick.org
    To copy to clipboard, switch view to plain text mode 



    I did the same of loading the PNG directly for me on both the cases it gives me a depth of 24 bit.....

    Qt Code:
    1. true
    2. QSize(1292, 1001) 24 false
    3. QSize(1292, 1001) 24 false
    To copy to clipboard, switch view to plain text mode 


    Anything i have to try chris .....


    Added after 26 minutes:


    Hi chris,

    I tried this, it sets my pixmap to 32 bit ......

    Qt Code:
    1. overlay_map.load("/aegean-60km.bmp");
    2.  
    3. qDebug() << overlay_map.size() << overlay_map.depth() << overlay_map.hasAlphaChannel();
    4.  
    5. overlay_map.setAlphaChannel(QPixmap("/aegean-60km.bmp"));
    6.  
    7. qDebug() << overlay_map.size() << overlay_map.depth() << overlay_map.hasAlphaChannel();
    To copy to clipboard, switch view to plain text mode 


    QSize(1292, 1076) 24 false
    QSize(1292, 1076) 32 true

    Now i didnt get any error .....This is the right way to set the pixmap to 32 Bit depth....
    Last edited by augusbas; 19th May 2011 at 07:56.

  4. #4
    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

    No, the right way would be to create a PNG file with an alpha channel in the first place. The setAlphaChannel() method is obsolete and likely to disappear.

    If you really cannot supply a source image with an alpha channel then you could load it into a QImage and use QImage::convertToFormat()

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

    Quote Originally Posted by ChrisW67 View Post
    No, the right way would be to create a PNG file with an alpha channel in the first place. The setAlphaChannel() method is obsolete and likely to disappear.

    If you really cannot supply a source image with an alpha channel then you could load it into a QImage and use QImage::convertToFormat()

    OK Chris, i will follow the same ....

    Thank you for your support Chris...

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.