Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QImage real bytes count
QtWS25 Last Chance

QImage real bytes count

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.1k Views
  • 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.
  • S Offline
    S Offline
    silex92
    wrote on last edited by
    #1

    Hello,

    how to retrieve the amount of bytes for an object of type QImage so if it would be saved onto disk the file size will have the same amount of bytes?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      how should this be possible since it depends in which format you save the file on the disk?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • S Offline
        S Offline
        silex92
        wrote on last edited by
        #3

        PNG

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          it's still not possible directly from QImage ;)

          You would first save it to this format and check it's resulting data size. This may block your application depending on the size of the image. If so you may want to do this in another thread.

          @
          QImage image;
          QByteArray ba;
          QBuffer buffer(&ba);
          buffer.open(QIODevice::WriteOnly);
          image.save(&buffer, "PNG");
          buffer.close();

          int fileSize = ba.size();
          @

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • S Offline
            S Offline
            silex92
            wrote on last edited by
            #5

            It is still a synchronous job.
            [quote author="raven-worx" date="1379919631"]it's still not possible directly from QImage ;)

            You would first save it to this format and check it's resulting data size. This may block your application depending on the size of the image. If so you may want to do this in another thread.

            @
            QImage image;
            QByteArray ba;
            QBuffer buffer(&ba);
            buffer.open(QIODevice::WriteOnly);
            image.save(&buffer, "PNG");
            buffer.close();

            int fileSize = ba.size();
            @[/quote]

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              [quote author="silex92" date="1379920609"]It is still a synchronous job.
              [/quote]
              Yes as i said!
              If you do want it to do asynchronously use another thread using signals and slots with a queued connection.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved