Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How much memory

    General and Desktop
    3
    5
    3639
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tclin1998 last edited by

      Hi:
      QPixmap pmap;
      if pmap's size is 600 x 800; depth is 24;
      Does it take

      600 * 800 * (32/ 8 byte) / 1024 / 1024 = 1.83 Mega bytes ?

      Thanks!

      -Todd

      1 Reply Last reply Reply Quote 0
      • G
        giesbert last edited by

        Hi Todd,

        I think so, yes.
        Afaik it's not compressed. What could be is that it uses 24 bit and not 32 per pixel, but i'm not sure about that.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply Reply Quote 0
        • A
          andre last edited by

          A pixmap is not compressed in memory (uncompressing them for each time they need to be drawn would be way too slow), so yes, it takes to full space to store everything you need, and possibly more for padding.

          Lesson to take home: don't try to allocate ridiculously large images (neither in a QPixmap, nor in a QImage, for that matter).

          1 Reply Last reply Reply Quote 1
          • T
            tclin1998 last edited by

            Thanks Gerolf and Andre.
            One more questions about the QPixmap memoery.

            QPixmap mm(800, 600); // ~ 1.83M
            I then resize it using the Qt 4 recommendation method.
            mm = QPixmap(0,0);

            How about the old 1.83M memory. Does Qt recycle it for me or I need to do something
            to avoid memory leaks.

            Thanks
            -Todd

            1 Reply Last reply Reply Quote 0
            • A
              andre last edited by

              Qt will release it at the appropriate time. When that is, could depend on the backend implementation for QPixmap that you are using. However: it is not something for you to worry about, normally.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post