exr: Fix read/write with openexr 3.3

It really wants to have a filename

Also it uses seek and tell a lot so sequential devices are for now not
supported

BUGS: 494571

(cherry picked from commit 3489806ae2568b4aba1167b29828dfb745231fb5)
This commit is contained in:
Albert Astals Cid
2024-10-12 01:42:26 +02:00
committed by Heiko Becker
parent ee77e349e3
commit 09b9ff7bf9

View File

@ -68,8 +68,8 @@
class K_IStream : public Imf::IStream
{
public:
K_IStream(QIODevice *dev, const QByteArray &fileName)
: IStream(fileName.data())
K_IStream(QIODevice *dev)
: IStream("K_IStream")
, m_dev(dev)
{
}
@ -159,7 +159,7 @@ bool EXRHandler::read(QImage *outImage)
int width;
int height;
K_IStream istr(device(), QByteArray());
K_IStream istr(device());
Imf::RgbaInputFile file(istr);
Imath::Box2i dw = file.dataWindow();
bool isRgba = file.channels() & Imf::RgbaChannels::WRITE_A;
@ -271,6 +271,13 @@ bool EXRHandler::canRead(QIODevice *device)
return false;
}
#if OPENEXR_VERSION_MAJOR == 3 && OPENEXR_VERSION_MINOR > 2
// openexpr >= 3.3 uses seek and tell extensively
if (device->isSequential()) {
return false;
}
#endif
const QByteArray head = device->peek(4);
return Imf::isImfMagic(head.data());