mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-05-28 00:30:23 -04:00
Added pixel limit detected by experimental tests
This commit is contained in:
parent
74a734efed
commit
bb1c6aab9e
@ -213,7 +213,7 @@ plugin ('n/a' means no limit, i.e. the limit depends on the format encoding).
|
||||
- EPS: n/a
|
||||
- HDR: n/a (large image)
|
||||
- HEIF: n/a
|
||||
- JP2: 300,000 x 300,000 pixels
|
||||
- JP2: 300,000 x 300,000 pixels, in any case no larger than 2 gigapixels
|
||||
- JXL: 262,144 x 262,144 pixels, in any case no larger than 256 megapixels
|
||||
- JXR: n/a, in any case no larger than 4 GB
|
||||
- KRA: same size as Qt's PNG plugin
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user