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. Using the QImageReader::setClipRect function, can not be used to load the interesting parts of a given image
Forum Updated to NodeBB v4.3 + New Features

Using the QImageReader::setClipRect function, can not be used to load the interesting parts of a given image

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 282 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.
  • T Offline
    T Offline
    Tricoffee
    wrote on last edited by
    #1
    QString filename = "C:/NDev/CPPDev/XVisual/SEB2023.bmp";
    QImageReader* reader = new QImageReader(filename);
    int tileHeight = 512;
    int tileWidth = 512;
    QRect tileRect(0, 0, tileWidth, tileHeight);
    reader->setClipRect(tileRect);
    QImage image = reader->read();
    

    Using the QImageReader::setClipRect function,
    can not be used to load the interesting parts of a given image,
    but load an entire image in memory at once!

    Christian EhrlicherC 1 Reply Last reply
    0
    • T Tricoffee
      QString filename = "C:/NDev/CPPDev/XVisual/SEB2023.bmp";
      QImageReader* reader = new QImageReader(filename);
      int tileHeight = 512;
      int tileWidth = 512;
      QRect tileRect(0, 0, tileWidth, tileHeight);
      reader->setClipRect(tileRect);
      QImage image = reader->read();
      

      Using the QImageReader::setClipRect function,
      can not be used to load the interesting parts of a given image,
      but load an entire image in memory at once!

      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Looks like the bmp reader does not support this option - see https://doc.qt.io/qt-6/qimagereader.html#supportsOption

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      T 2 Replies Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Looks like the bmp reader does not support this option - see https://doc.qt.io/qt-6/qimagereader.html#supportsOption

        T Offline
        T Offline
        Tricoffee
        wrote on last edited by
        #3

        @Christian-Ehrlicher Yes,you're right.

            if(reader->supportsOption(QImageIOHandler::ClipRect))
            {
                qDebug() << "Support QImageIOHandler::ClipRect";
            }
            else
            {
                qDebug() << "QImageIOHandler::ClipRect are not Supported";
            }
        

        The above judgment statement outputs:
        QImageIOHandler::ClipRect are not Supported

        1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          Looks like the bmp reader does not support this option - see https://doc.qt.io/qt-6/qimagereader.html#supportsOption

          T Offline
          T Offline
          Tricoffee
          wrote on last edited by
          #4

          @Christian-Ehrlicher Is there an alternative method to only load the part of interest of the given BMP image?

          Christian EhrlicherC 1 Reply Last reply
          0
          • T Tricoffee

            @Christian-Ehrlicher Is there an alternative method to only load the part of interest of the given BMP image?

            Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Tricoffee said in Using the QImageReader::setClipRect function, can not be used to load the interesting parts of a given image:

            Is there an alternative method to only load the part of interest of the given BMP image?

            No, read the complete image and then copy out the part of interest.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1

            • Login

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