13#include <QLoggingCategory>
15Q_DECLARE_LOGGING_CATEGORY(LOG_PXRPLUGIN)
16Q_LOGGING_CATEGORY(LOG_PXRPLUGIN,
"kf.imageformats.plugins.pxr", QtWarningMsg)
23 quint16 ui16(quint8 c1, quint8 c2)
const {
24 return (quint16(c2) << 8) | quint16(c1);
27 quint32 ui32(quint8 c1, quint8 c2, quint8 c3, quint8 c4)
const {
28 return (quint32(c4) << 24) | (quint32(c3) << 16) | (quint32(c2) << 8) | quint32(c1);
39 return (m_rawHeader.
size() == 512 &&
43 bool isSupported()
const
53 return qint32(ui16(m_rawHeader.
at(418), m_rawHeader.
at(419)));
61 return qint32(ui16(m_rawHeader.
at(416), m_rawHeader.
at(417)));
66 return QSize(width(), height());
69 qint32 channel()
const
74 return qint32(ui16(m_rawHeader.
at(424), m_rawHeader.
at(425)));
82 return qint32(ui16(m_rawHeader.
at(426), m_rawHeader.
at(427)));
91 return qint32(ui16(m_rawHeader.
at(428), m_rawHeader.
at(429)));
96 if (channel() == 14 && depth() == 2) {
99 if (channel() == 8 && depth() == 2) {
105 qsizetype strideSize()
const
118 m_rawHeader = d->
read(512);
133 if (
auto sz = std::max(offset() - qint32(m_rawHeader.
size()), 0)) {
138 return d->
seek(offset());
142class PXRHandlerPrivate
145 PXRHandlerPrivate() {}
146 ~PXRHandlerPrivate() {}
151PXRHandler::PXRHandler()
153 , d(new PXRHandlerPrivate)
157bool PXRHandler::canRead()
const
159 if (canRead(device())) {
166bool PXRHandler::canRead(
QIODevice *device)
169 qCWarning(LOG_PXRPLUGIN) <<
"PXRHandler::canRead() called with no device";
174 if (!h.peek(device)) {
178 return h.isSupported();
181bool PXRHandler::read(
QImage *image)
183 auto&& header = d->m_header;
185 if (!header.read(device())) {
186 qCWarning(LOG_PXRPLUGIN) <<
"PXRHandler::read() invalid header";
190 auto img = imageAlloc(header.size(), header.format());
192 qCWarning(LOG_PXRPLUGIN) <<
"PXRHandler::read() error while allocating the image";
197 if (!header.jumpToImageData(d)) {
198 qCWarning(LOG_PXRPLUGIN) <<
"PXRHandler::read() error while seeking image data";
202 auto size = std::min(img.bytesPerLine(), header.strideSize());
203 for (
auto y = 0, h = img.height(); y < h; ++y) {
204 auto line =
reinterpret_cast<char*
>(img.scanLine(y));
205 if (d->
read(line, size) != size) {
206 qCWarning(LOG_PXRPLUGIN) <<
"PXRHandler::read() error while reading image scanline";
215bool PXRHandler::supportsOption(ImageOption option)
const
226QVariant PXRHandler::option(ImageOption option)
const
231 auto&& h = d->m_header;
234 }
else if (
auto d = device()) {
242 auto&& h = d->m_header;
245 }
else if (
auto d = device()) {
257 if (format ==
"pxr") {
268 if (device->
isReadable() && PXRHandler::canRead(device)) {
282#include "moc_pxr_p.cpp"
QFlags< Capability > Capabilities
char at(qsizetype i) const const
QByteArray fromRawData(const char *data, qsizetype size)
bool isEmpty() const const
qsizetype size() const const
bool startsWith(QByteArrayView bv) const const
void setDevice(QIODevice *device)
bool isOpen() const const
bool isReadable() const const
virtual bool isSequential() const const
QByteArray read(qint64 maxSize)
void rollbackTransaction()
virtual bool seek(qint64 pos)
QVariant fromValue(T &&value)