From 09b9ff7bf9be81c654cb1dd60ed5252f83588c92 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sat, 12 Oct 2024 01:42:26 +0200 Subject: [PATCH] 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) --- src/imageformats/exr.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/imageformats/exr.cpp b/src/imageformats/exr.cpp index a219ee0..c459bd0 100644 --- a/src/imageformats/exr.cpp +++ b/src/imageformats/exr.cpp @@ -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());