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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.12.0
    • 5.5.0
    • GUI: Painting
    • 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

        For Gerrit Dashboard: QTBUG-50912
        # Subject Branch Project Status CR V

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            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