Results 1 to 3 of 3

Thread: QImage bytesize

  1. #1
    Join Date
    Dec 2016
    Posts
    11
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QImage bytesize

    Hi,

    I'm just wondering why QImage are consuming that much memory.

    I'm loading an image that is 1.2 Mb (I checked that using QFileInfo) and when querying the size using sizeInBytes on the QImage I get something like 24 Mb. Any idea ?
    What class can I use in order to load the image with the lowest size in memory (uncompressed), and to display it of course (I need to put it in a PixMap at the end in order to add it to a GraphicsScene) ?
    Do you think I'm misinterpreting the value from QFileInfo ?

    I can clearly see in the task manager, that my program consumes more memory than I think it should be.

    Qt Code:
    1. QFileInfo info(imagePath);
    2. qDebug() << "INFO:" << info.size() << " IMG BYTES: " << new QImage(imagePath)->sizeInBytes(); //INFO: 1277952 IMG BYTES: 24064000
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance !
    Last edited by panicq; 26th January 2021 at 13:19.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QImage bytesize

    Hi, just a guess: maybe your original file is compressed (jpg or something like that), while QImage stores a raw representation of the pixels? What size does your image have (width x height)?

    Ginsengelf

  3. #3
    Join Date
    Dec 2016
    Posts
    11
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QImage bytesize

    You're probably right, so QFileInfo::size() gave me the compressed byte size.

Similar Threads

  1. QImage contains smaller QImage
    By Ini in forum General Programming
    Replies: 5
    Last Post: 31st May 2016, 18:11
  2. How to add new QImage to the left side of old QImage??
    By ganapathi in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2016, 09:54
  3. Replies: 5
    Last Post: 16th May 2011, 22:15
  4. What's faster: QPixmap-to-QImage or QImage-to-QPixmap
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2006, 18:11
  5. Replies: 3
    Last Post: 15th March 2006, 12:44

Tags for this Thread

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.