mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2026-09-24 23:42:03 -04:00
Switch all plugins to QLoggingCategory
This commit is contained in:
@@ -20,8 +20,8 @@
|
||||
|
||||
#include <QColorSpace>
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QLoggingCategory>
|
||||
#include <QVariant>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -29,6 +29,12 @@
|
||||
#include <qendian.h>
|
||||
#include <utility>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_PICPLUGIN, "kf.imageformats.plugins.pic", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_PICPLUGIN, "kf.imageformats.plugins.pic", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Reads a PIC file header from a data stream.
|
||||
*
|
||||
@@ -193,7 +199,7 @@ static bool readRow(QDataStream &stream, QRgb *row, quint16 width, const QList<P
|
||||
if (channel.encoding == MixedRLE) {
|
||||
bool success = decodeRLEData(RLEVariant::PIC, stream, row, width, readPixel, updatePixel);
|
||||
if (!success) {
|
||||
qDebug() << "decodeRLEData failed";
|
||||
qCDebug(LOG_PICPLUGIN) << "decodeRLEData failed";
|
||||
return false;
|
||||
}
|
||||
} else if (channel.encoding == Uncompressed) {
|
||||
@@ -203,12 +209,12 @@ static bool readRow(QDataStream &stream, QRgb *row, quint16 width, const QList<P
|
||||
}
|
||||
} else {
|
||||
// unknown encoding
|
||||
qDebug() << "Unknown encoding";
|
||||
qCDebug(LOG_PICPLUGIN) << "Unknown encoding";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
qDebug() << "DataStream status was" << stream.status();
|
||||
qCDebug(LOG_PICPLUGIN) << "DataStream status was" << stream.status();
|
||||
}
|
||||
return stream.status() == QDataStream::Ok;
|
||||
}
|
||||
@@ -232,7 +238,7 @@ bool SoftimagePICHandler::read(QImage *image)
|
||||
for (const PicChannel &channel : std::as_const(m_channels)) {
|
||||
if (channel.size != 8) {
|
||||
// we cannot read images that do not come in bytes
|
||||
qDebug() << "Channel size was" << channel.size;
|
||||
qCDebug(LOG_PICPLUGIN) << "Channel size was" << channel.size;
|
||||
m_state = Error;
|
||||
return false;
|
||||
}
|
||||
@@ -243,7 +249,7 @@ bool SoftimagePICHandler::read(QImage *image)
|
||||
|
||||
QImage img = imageAlloc(m_header.width, m_header.height, fmt);
|
||||
if (img.isNull()) {
|
||||
qDebug() << "Failed to allocate image, invalid dimensions?" << QSize(m_header.width, m_header.height) << fmt;
|
||||
qCDebug(LOG_PICPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(m_header.width, m_header.height) << fmt;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -252,7 +258,7 @@ bool SoftimagePICHandler::read(QImage *image)
|
||||
for (int y = 0; y < m_header.height; y++) {
|
||||
QRgb *row = reinterpret_cast<QRgb *>(img.scanLine(y));
|
||||
if (!readRow(m_dataStream, row, m_header.width, m_channels)) {
|
||||
qDebug() << "readRow failed";
|
||||
qCDebug(LOG_PICPLUGIN) << "readRow failed";
|
||||
m_state = Error;
|
||||
return false;
|
||||
}
|
||||
@@ -281,11 +287,11 @@ bool SoftimagePICHandler::write(const QImage &image)
|
||||
}
|
||||
|
||||
if (image.width() < 0 || image.height() < 0) {
|
||||
qDebug() << "Image size invalid:" << image.width() << image.height();
|
||||
qCDebug(LOG_PICPLUGIN) << "Image size invalid:" << image.width() << image.height();
|
||||
return false;
|
||||
}
|
||||
if (image.width() > 65535 || image.height() > 65535) {
|
||||
qDebug() << "Image too big:" << image.width() << image.height();
|
||||
qCDebug(LOG_PICPLUGIN) << "Image too big:" << image.width() << image.height();
|
||||
// there are only two bytes for each dimension
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user