19#include <QLoggingCategory>
21Q_DECLARE_LOGGING_CATEGORY(LOG_PFMPLUGIN)
22Q_LOGGING_CATEGORY(LOG_PFMPLUGIN,
"kf.imageformats.plugins.pfm", QtWarningMsg)
76 return (m_width > 0 && m_height > 0);
79 bool isBlackAndWhite()
const
84 bool isPhotoshop()
const
101 return QSize(m_width, m_height);
119 auto pf = d->
read(3);
128 auto list = wh.split(QStringLiteral(
" "));
142 if (!ok_o || !ok_w || !ok_h || o == 0) {
160class PFMHandlerPrivate
163 PFMHandlerPrivate() {}
164 ~PFMHandlerPrivate() {}
169PFMHandler::PFMHandler()
171 , d(new PFMHandlerPrivate)
175bool PFMHandler::canRead()
const
177 if (canRead(device())) {
184bool PFMHandler::canRead(
QIODevice *device)
187 qCWarning(LOG_PFMPLUGIN) <<
"PFMHandler::canRead() called with no device";
192 if (!h.peek(device)) {
199bool PFMHandler::read(
QImage *image)
201 auto&& header = d->m_header;
202 if (!header.read(device())) {
203 qCWarning(LOG_PFMPLUGIN) <<
"PFMHandler::read() invalid header";
209 s.setByteOrder(header.byteOrder());
211 auto img = imageAlloc(header.size(), header.format());
213 qCWarning(LOG_PFMPLUGIN) <<
"PFMHandler::read() error while allocating the image";
217 for (
auto y = 0, h = img.height(); y < h; ++y) {
218 auto bw = header.isBlackAndWhite();
219 auto line =
reinterpret_cast<float *
>(img.scanLine(header.isPhotoshop() ? y : h - y - 1));
220 for (
auto x = 0, n = img.width() * 4; x < n; x += 4) {
221 line[x + 3] = float(1);
224 line[x + 1] = line[x];
225 line[x + 2] = line[x];
231 qCWarning(LOG_PFMPLUGIN) <<
"PFMHandler::read() detected corrupted data";
243bool PFMHandler::supportsOption(ImageOption option)
const
257QVariant PFMHandler::option(ImageOption option)
const
262 auto&& h = d->m_header;
265 }
else if (
auto dev = device()) {
273 auto&& h = d->m_header;
276 }
else if (
auto dev = device()) {
284 auto&& h = d->m_header;
287 }
else if (
auto dev = device()) {
299 if (format ==
"pfm") {
310 if (device->
isReadable() && PFMHandler::canRead(device)) {
324#include "moc_pfm_p.cpp"
QFlags< Capability > Capabilities
KIOCORE_EXPORT QStringList list(const QString &fileClass)
bool isEmpty() const const
void setDevice(QIODevice *device)
bool isOpen() const const
bool isReadable() const const
QByteArray read(qint64 maxSize)
QByteArray readLine(qint64 maxSize)
void rollbackTransaction()
qsizetype size() const const
QString fromLatin1(QByteArrayView str)
double toDouble(bool *ok) const const
QVariant fromValue(T &&value)