mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-19 12:14:20 -04:00
Added pixel limit detected by experimental tests
This commit is contained in:
@ -27,6 +27,13 @@
|
||||
#define JP2_MAX_IMAGE_HEIGHT JP2_MAX_IMAGE_WIDTH
|
||||
#endif
|
||||
|
||||
/* *** JP2_MAX_IMAGE_PIXELS ***
|
||||
* OpenJPEG seems limited to an image of 2 gigapixel size.
|
||||
*/
|
||||
#ifndef JP2_MAX_IMAGE_PIXELS
|
||||
#define JP2_MAX_IMAGE_PIXELS std::numeric_limits<qint32>::max()
|
||||
#endif
|
||||
|
||||
/* *** JP2_ENABLE_HDR ***
|
||||
* Enable float image formats. Disabled by default
|
||||
* due to lack of test images.
|
||||
@ -332,6 +339,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (qint64(width) * qint64(height) > JP2_MAX_IMAGE_PIXELS) {
|
||||
qCritical() << "Maximum image size is limited to" << JP2_MAX_IMAGE_PIXELS << "pixels";
|
||||
return false;
|
||||
}
|
||||
|
||||
// OpenJPEG uses a shadow copy @32-bit/channel so we need to do a check
|
||||
auto maxBytes = qint64(QImageReader::allocationLimit()) * 1024 * 1024;
|
||||
auto neededBytes = qint64(width) * height * nchannels * 4;
|
||||
|
Reference in New Issue
Block a user