Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-50912

QImage can't handle images over 2GB, even in 64bit builds

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.5.0
    • Fix Version/s: 5.12.0
    • Component/s: GUI: Painting
    • Labels:
      None

      Description

      When trying to create a large image like below, you get a null QImage.

      QImage image(25000, 25000, QImage::Format_RGB32);
      

      The code responsible for the failure is in QImageData::create() and looks like this:

          // sanity check for potential overflows
          if (INT_MAX/depth < width
              || bytes_per_line <= 0
              || height <= 0
              || INT_MAX/uint(bytes_per_line) < height
              || INT_MAX/sizeof(uchar *) < uint(height))
              return 0;
      

      The particular check that fails is:

      INT_MAX/uint(bytes_per_line) < height
      

      I presume QImageData::nbytes being of type int is the primary reason to have this check.

      It would be nice to remove this 2GB limitation for 64bit builds. Large images are commonly used in printing industry.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            allan.jensen Allan Sandfeld Jensen
            Reporter:
            jart Joseph Artsimovich
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes