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 - Determine the proper scale to fit a specific Byte Array Size
QtWS25 Last Chance

QImage - Determine the proper scale to fit a specific Byte Array Size

Scheduled Pinned Locked Moved General and Desktop
qimagesaveqbytearray
3 Posts 2 Posters 1.3k 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.
  • diduD Offline
    diduD Offline
    didu
    wrote on last edited by
    #1

    Hello,

    I have a function that take a QImage.
    I need to save this QImage in a QByteArray with a specific size.

    it can happen that this QImage is too big, so I need to "scaled" it.
    Is there anyway to determine the proper scaled to make for making the QImage fit a specific byte size ?

    Thanks in advance,

    1 Reply Last reply
    0
    • cybercatalystC Offline
      cybercatalystC Offline
      cybercatalyst
      wrote on last edited by
      #2

      This dependes on the format, which most likely adds some kind of compression. The compression result is depend on the ordering of the pixels, which may be entirely different when pixels are differently aligned after scaling. This has a direct impact on the size in bytes.

      So, the conclusion is that there is some dependency (image contents, format, size) -> (size in bytes), but unless you aren't using an uncompressed format I wouldn't expect to be able to calculate the inversion of that function. This would be really complicated if even possible.

      1 Reply Last reply
      1
      • diduD Offline
        diduD Offline
        didu
        wrote on last edited by
        #3

        @cybercatalyst said:

        This dependes on the format, which most likely adds some kind of compression. The compression result is depend on the ordering of the pixels, which may be entirely different when pixels are differently aligned after scaling. This has a direct impact on the size in bytes.

        So, the conclusion is that there is some dependency (image contents, format, size) -> (size in bytes), but unless you aren't using an uncompressed format I wouldn't expect to be able to calculate the inversion of that function. This would be really complicated if even possible.

        Thanks for the answser.
        I think I will have to look for using BMP format. (https://support.microsoft.com/en-us/kb/132271)
        It is not the best optimization but it is the most quick calcul...

        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