Using the QImageReader::setClipRect function, can not be used to load the interesting parts of a given image
-
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! -
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!Looks like the bmp reader does not support this option - see https://doc.qt.io/qt-6/qimagereader.html#supportsOption
-
Looks like the bmp reader does not support this option - see https://doc.qt.io/qt-6/qimagereader.html#supportsOption
@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 -
Looks like the bmp reader does not support this option - see https://doc.qt.io/qt-6/qimagereader.html#supportsOption
@Christian-Ehrlicher Is there an alternative method to only load the part of interest of the given BMP image?
-
@Christian-Ehrlicher Is there an alternative method to only load the part of interest of the given BMP image?
@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.