mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2026-06-13 10:49:10 -04:00
Switch all plugins to QLoggingCategory
This commit is contained in:
@@ -6,14 +6,20 @@
|
||||
|
||||
#include "ani_p.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QLoggingCategory>
|
||||
#include <QScopeGuard>
|
||||
#include <QVariant>
|
||||
#include <QtEndian>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_ANIPLUGIN, "kf.imageformats.plugins.ani", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_ANIPLUGIN, "kf.imageformats.plugins.ani", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
struct ChunkHeader {
|
||||
@@ -358,7 +364,7 @@ bool ANIHandler::ensureScanned() const
|
||||
|
||||
if (chunkId == "anih") {
|
||||
if (chunkSize != sizeof(AniHeader)) {
|
||||
qWarning() << "anih chunk size does not match ANIHEADER size";
|
||||
qCWarning(LOG_ANIPLUGIN) << "anih chunk size does not match ANIHEADER size";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -494,22 +500,22 @@ bool ANIHandler::ensureScanned() const
|
||||
}
|
||||
|
||||
if (m_imageCount != m_frameCount && m_imageSequence.isEmpty()) {
|
||||
qWarning("ANIHandler: 'nSteps' is not equal to 'nFrames' but no 'seq' entries were provided");
|
||||
qCWarning(LOG_ANIPLUGIN) << "ANIHandler: 'nSteps' is not equal to 'nFrames' but no 'seq' entries were provided";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_imageSequence.isEmpty() && m_imageSequence.count() != m_imageCount) {
|
||||
qWarning("ANIHandler: count of entries in 'seq' does not match 'nSteps' in anih");
|
||||
qCWarning(LOG_ANIPLUGIN) << "ANIHandler: count of entries in 'seq' does not match 'nSteps' in anih";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_displayRates.isEmpty() && m_displayRates.count() != m_imageCount) {
|
||||
qWarning("ANIHandler: count of entries in 'rate' does not match 'nSteps' in anih");
|
||||
qCWarning(LOG_ANIPLUGIN) << "ANIHandler: count of entries in 'rate' does not match 'nSteps' in anih";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_frameOffsets.isEmpty() && m_frameOffsets.count() - 1 != m_frameCount) {
|
||||
qWarning("ANIHandler: number of actual frames does not match 'nFrames' in anih");
|
||||
qCWarning(LOG_ANIPLUGIN) << "ANIHandler: number of actual frames does not match 'nFrames' in anih";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -520,7 +526,7 @@ bool ANIHandler::ensureScanned() const
|
||||
bool ANIHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("ANIHandler::canRead() called with no device");
|
||||
qCWarning(LOG_ANIPLUGIN) << "ANIHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
if (device->isSequential()) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <QColorSpace>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include "avif_p.h"
|
||||
#include "microexif_p.h"
|
||||
@@ -17,6 +18,12 @@
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_AVIFPLUGIN, "kf.imageformats.plugins.avif", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_AVIFPLUGIN, "kf.imageformats.plugins.avif", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
/*
|
||||
Quality range - compression/subsampling
|
||||
100 - lossless RGB compression
|
||||
@@ -168,7 +175,7 @@ bool QAVIFHandler::ensureDecoder()
|
||||
|
||||
decodeResult = avifDecoderSetIOMemory(m_decoder, m_rawAvifData.data, m_rawAvifData.size);
|
||||
if (decodeResult != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR: avifDecoderSetIOMemory failed: %s", avifResultToString(decodeResult));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR: avifDecoderSetIOMemory failed: %s", avifResultToString(decodeResult));
|
||||
|
||||
avifDecoderDestroy(m_decoder);
|
||||
m_decoder = nullptr;
|
||||
@@ -178,7 +185,7 @@ bool QAVIFHandler::ensureDecoder()
|
||||
|
||||
decodeResult = avifDecoderParse(m_decoder);
|
||||
if (decodeResult != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR: Failed to parse input: %s", avifResultToString(decodeResult));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR: Failed to parse input: %s", avifResultToString(decodeResult));
|
||||
|
||||
avifDecoderDestroy(m_decoder);
|
||||
m_decoder = nullptr;
|
||||
@@ -190,19 +197,19 @@ bool QAVIFHandler::ensureDecoder()
|
||||
m_container_height = m_decoder->image->height;
|
||||
|
||||
if ((m_container_width > 65535) || (m_container_height > 65535)) {
|
||||
qWarning("AVIF image (%dx%d) is too large!", m_container_width, m_container_height);
|
||||
qCWarning(LOG_AVIFPLUGIN, "AVIF image (%dx%d) is too large!", m_container_width, m_container_height);
|
||||
m_parseState = ParseAvifError;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((m_container_width == 0) || (m_container_height == 0)) {
|
||||
qWarning("Empty image, nothing to decode");
|
||||
qCWarning(LOG_AVIFPLUGIN, "Empty image, nothing to decode");
|
||||
m_parseState = ParseAvifError;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_container_width > ((16384 * 16384) / m_container_height)) {
|
||||
qWarning("AVIF image (%dx%d) has more than 256 megapixels!", m_container_width, m_container_height);
|
||||
qCWarning(LOG_AVIFPLUGIN, "AVIF image (%dx%d) has more than 256 megapixels!", m_container_width, m_container_height);
|
||||
m_parseState = ParseAvifError;
|
||||
return false;
|
||||
}
|
||||
@@ -276,7 +283,7 @@ bool QAVIFHandler::decode_one_frame()
|
||||
|
||||
QImage result = imageAlloc(m_decoder->image->width, m_decoder->image->height, resultformat);
|
||||
if (result.isNull()) {
|
||||
qWarning("Memory cannot be allocated");
|
||||
qCWarning(LOG_AVIFPLUGIN, "Memory cannot be allocated");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -285,12 +292,12 @@ bool QAVIFHandler::decode_one_frame()
|
||||
const QByteArray icc_data(reinterpret_cast<const char *>(m_decoder->image->icc.data), m_decoder->image->icc.size);
|
||||
colorspace = QColorSpace::fromIccProfile(icc_data);
|
||||
if (!colorspace.isValid()) {
|
||||
qWarning("AVIF image has Qt-unsupported or invalid ICC profile!");
|
||||
qCWarning(LOG_AVIFPLUGIN, "AVIF image has Qt-unsupported or invalid ICC profile!");
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 8, 0))
|
||||
else {
|
||||
if (colorspace.colorModel() == QColorSpace::ColorModel::Cmyk) {
|
||||
qWarning("CMYK ICC profile is not extected for AVIF, discarding the ICCprofile!");
|
||||
qCWarning(LOG_AVIFPLUGIN, "CMYK ICC profile is not extected for AVIF, discarding the ICCprofile!");
|
||||
colorspace = QColorSpace();
|
||||
} else if (colorspace.colorModel() == QColorSpace::ColorModel::Rgb && loadgray) {
|
||||
// Input is GRAY but ICC is RGB, we will return RGB image
|
||||
@@ -314,7 +321,7 @@ bool QAVIFHandler::decode_one_frame()
|
||||
}
|
||||
colorspace = QColorSpace(gray_whitePoint, redP, greenP, blueP, trc_new, gamma_new);
|
||||
if (!colorspace.isValid()) {
|
||||
qWarning("AVIF plugin created invalid QColorSpace!");
|
||||
qCWarning(LOG_AVIFPLUGIN, "AVIF plugin created invalid QColorSpace!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -362,7 +369,7 @@ bool QAVIFHandler::decode_one_frame()
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
qWarning("CICP colorPrimaries: %d, transferCharacteristics: %d\nThe colorspace is unsupported by this plug-in yet.",
|
||||
qCWarning(LOG_AVIFPLUGIN, "CICP colorPrimaries: %d, transferCharacteristics: %d\nThe colorspace is unsupported by this plug-in yet.",
|
||||
m_decoder->image->colorPrimaries,
|
||||
m_decoder->image->transferCharacteristics);
|
||||
q_trc = QColorSpace::TransferFunction::SRgb;
|
||||
@@ -396,7 +403,7 @@ bool QAVIFHandler::decode_one_frame()
|
||||
}
|
||||
|
||||
if (!colorspace.isValid()) {
|
||||
qWarning("AVIF plugin created invalid QColorSpace from NCLX/CICP!");
|
||||
qCWarning(LOG_AVIFPLUGIN, "AVIF plugin created invalid QColorSpace from NCLX/CICP!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,7 +446,7 @@ bool QAVIFHandler::decode_one_frame()
|
||||
|
||||
avifResult res = avifImageYUVToRGB(m_decoder->image, &rgb);
|
||||
if (res != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR in avifImageYUVToRGB: %s", avifResultToString(res));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR in avifImageYUVToRGB: %s", avifResultToString(res));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -478,7 +485,7 @@ bool QAVIFHandler::decode_one_frame()
|
||||
}
|
||||
|
||||
else { // Zero values, we need to avoid 0 divide.
|
||||
qWarning("ERROR: Wrong values in avifCleanApertureBox");
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR: Wrong values in avifCleanApertureBox");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,7 +563,7 @@ static void setMetadata(avifImage *avif, const QImage& image)
|
||||
#if AVIF_VERSION >= 1000000
|
||||
auto res = avifImageSetMetadataXMP(avif, reinterpret_cast<const uint8_t *>(xmp.constData()), xmp.size());
|
||||
if (res != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR in avifImageSetMetadataXMP: %s", avifResultToString(res));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR in avifImageSetMetadataXMP: %s", avifResultToString(res));
|
||||
}
|
||||
#else
|
||||
avifImageSetMetadataXMP(avif, reinterpret_cast<const uint8_t *>(xmp.constData()), xmp.size());
|
||||
@@ -567,7 +574,7 @@ static void setMetadata(avifImage *avif, const QImage& image)
|
||||
#if AVIF_VERSION >= 1000000
|
||||
auto res = avifImageSetMetadataExif(avif, reinterpret_cast<const uint8_t *>(exif.constData()), exif.size());
|
||||
if (res != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR in avifImageSetMetadataExif: %s", avifResultToString(res));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR in avifImageSetMetadataExif: %s", avifResultToString(res));
|
||||
}
|
||||
#else
|
||||
avifImageSetMetadataExif(avif, reinterpret_cast<const uint8_t *>(exif.constData()), exif.size());
|
||||
@@ -602,32 +609,32 @@ bool QAVIFHandler::read(QImage *image)
|
||||
bool QAVIFHandler::write(const QImage &image)
|
||||
{
|
||||
if (image.format() == QImage::Format_Invalid) {
|
||||
qWarning("No image data to save!");
|
||||
qCWarning(LOG_AVIFPLUGIN, "No image data to save!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((image.width() > 0) && (image.height() > 0)) {
|
||||
if ((image.width() > 65535) || (image.height() > 65535)) {
|
||||
qWarning("Image (%dx%d) is too large to save!", image.width(), image.height());
|
||||
qCWarning(LOG_AVIFPLUGIN, "Image (%dx%d) is too large to save!", image.width(), image.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (image.width() > ((16384 * 16384) / image.height())) {
|
||||
qWarning("Image (%dx%d) will not be saved because it has more than 256 megapixels!", image.width(), image.height());
|
||||
qCWarning(LOG_AVIFPLUGIN, "Image (%dx%d) will not be saved because it has more than 256 megapixels!", image.width(), image.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((image.width() > 32768) || (image.height() > 32768)) {
|
||||
qWarning("Image (%dx%d) has a dimension above 32768 pixels, saved AVIF may not work in other software!", image.width(), image.height());
|
||||
qCWarning(LOG_AVIFPLUGIN, "Image (%dx%d) has a dimension above 32768 pixels, saved AVIF may not work in other software!", image.width(), image.height());
|
||||
}
|
||||
} else {
|
||||
qWarning("Image has zero dimension!");
|
||||
qCWarning(LOG_AVIFPLUGIN, "Image has zero dimension!");
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *encoder_name = avifCodecName(AVIF_CODEC_CHOICE_AUTO, AVIF_CODEC_FLAG_CAN_ENCODE);
|
||||
if (!encoder_name) {
|
||||
qWarning("Cannot save AVIF images because libavif was built without AV1 encoders!");
|
||||
qCWarning(LOG_AVIFPLUGIN, "Cannot save AVIF images because libavif was built without AV1 encoders!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -636,7 +643,7 @@ bool QAVIFHandler::write(const QImage &image)
|
||||
if (avifCodecName(AVIF_CODEC_CHOICE_AOM, AVIF_CODEC_FLAG_CAN_ENCODE)) {
|
||||
lossless = true;
|
||||
} else {
|
||||
qWarning("You are using %s encoder. It is recommended to enable libAOM encoder in libavif to use lossless compression.", encoder_name);
|
||||
qCWarning(LOG_AVIFPLUGIN, "You are using %s encoder. It is recommended to enable libAOM encoder in libavif to use lossless compression.", encoder_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -718,7 +725,7 @@ bool QAVIFHandler::write(const QImage &image)
|
||||
#if AVIF_VERSION >= 110000
|
||||
res = avifImageAllocatePlanes(avif, AVIF_PLANES_YUV);
|
||||
if (res != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR in avifImageAllocatePlanes: %s", avifResultToString(res));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR in avifImageAllocatePlanes: %s", avifResultToString(res));
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
@@ -959,7 +966,7 @@ bool QAVIFHandler::write(const QImage &image)
|
||||
#if AVIF_VERSION >= 1000000
|
||||
res = avifImageSetProfileICC(avif, reinterpret_cast<const uint8_t *>(iccprofile.constData()), iccprofile.size());
|
||||
if (res != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR in avifImageSetProfileICC: %s", avifResultToString(res));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR in avifImageSetProfileICC: %s", avifResultToString(res));
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
@@ -992,7 +999,7 @@ bool QAVIFHandler::write(const QImage &image)
|
||||
|
||||
res = avifImageRGBToYUV(avif, &rgb);
|
||||
if (res != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR in avifImageRGBToYUV: %s", avifResultToString(res));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR in avifImageRGBToYUV: %s", avifResultToString(res));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1034,11 +1041,11 @@ bool QAVIFHandler::write(const QImage &image)
|
||||
if (status > 0) {
|
||||
return true;
|
||||
} else if (status == -1) {
|
||||
qWarning("Write error: %s", qUtf8Printable(device()->errorString()));
|
||||
qCWarning(LOG_AVIFPLUGIN, "Write error: %s", qUtf8Printable(device()->errorString()));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
qWarning("ERROR: Failed to encode: %s", avifResultToString(res));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR: Failed to encode: %s", avifResultToString(res));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1140,7 +1147,7 @@ bool QAVIFHandler::jumpToNextImage()
|
||||
if (m_decoder->imageIndex >= m_decoder->imageCount - 1) { // start from beginning
|
||||
decodeResult = avifDecoderReset(m_decoder);
|
||||
if (decodeResult != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR in avifDecoderReset: %s", avifResultToString(decodeResult));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR in avifDecoderReset: %s", avifResultToString(decodeResult));
|
||||
m_parseState = ParseAvifError;
|
||||
return false;
|
||||
}
|
||||
@@ -1150,13 +1157,13 @@ bool QAVIFHandler::jumpToNextImage()
|
||||
decodeResult = avifDecoderNextImage(m_decoder);
|
||||
|
||||
if (decodeResult != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR: Failed to decode Next image in sequence: %s", avifResultToString(decodeResult));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR: Failed to decode Next image in sequence: %s", avifResultToString(decodeResult));
|
||||
m_parseState = ParseAvifError;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((m_container_width != m_decoder->image->width) || (m_container_height != m_decoder->image->height)) {
|
||||
qWarning("Decoded image sequence size (%dx%d) do not match first image size (%dx%d)!",
|
||||
qCWarning(LOG_AVIFPLUGIN, "Decoded image sequence size (%dx%d) do not match first image size (%dx%d)!",
|
||||
m_decoder->image->width,
|
||||
m_decoder->image->height,
|
||||
m_container_width,
|
||||
@@ -1204,13 +1211,13 @@ bool QAVIFHandler::jumpToImage(int imageNumber)
|
||||
avifResult decodeResult = avifDecoderNthImage(m_decoder, imageNumber);
|
||||
|
||||
if (decodeResult != AVIF_RESULT_OK) {
|
||||
qWarning("ERROR: Failed to decode %d th Image in sequence: %s", imageNumber, avifResultToString(decodeResult));
|
||||
qCWarning(LOG_AVIFPLUGIN, "ERROR: Failed to decode %d th Image in sequence: %s", imageNumber, avifResultToString(decodeResult));
|
||||
m_parseState = ParseAvifError;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((m_container_width != m_decoder->image->width) || (m_container_height != m_decoder->image->height)) {
|
||||
qWarning("Decoded image sequence size (%dx%d) do not match declared container size (%dx%d)!",
|
||||
qCWarning(LOG_AVIFPLUGIN, "Decoded image sequence size (%dx%d) do not match declared container size (%dx%d)!",
|
||||
m_decoder->image->width,
|
||||
m_decoder->image->height,
|
||||
m_container_width,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <QColorSpace>
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
// #define DDS_DISABLE_STRIDE_ALIGNMENT
|
||||
#endif
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_DDSPLUGIN, "kf.imageformats.plugins.dds", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_DDSPLUGIN, "kf.imageformats.plugins.dds", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
enum Format {
|
||||
FormatUnknown = 0,
|
||||
|
||||
@@ -2389,7 +2395,7 @@ bool QDDSHandler::write(const QImage &outImage)
|
||||
return writeA32B32G32R32F(outImage, s);
|
||||
}
|
||||
|
||||
qWarning() << "Format" << formatName(format) << "is not supported";
|
||||
qCWarning(LOG_DDSPLUGIN) << "Format" << formatName(format) << "is not supported";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2462,7 +2468,7 @@ bool QDDSHandler::jumpToImage(int imageNumber)
|
||||
bool QDDSHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning() << "DDSHandler::canRead() called with no device";
|
||||
qCWarning(LOG_DDSPLUGIN) << "DDSHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2487,7 +2493,7 @@ bool QDDSHandler::ensureScanned() const
|
||||
that->m_format = FormatUnknown;
|
||||
|
||||
if (device()->isSequential()) {
|
||||
qWarning() << "Sequential devices are not supported";
|
||||
qCWarning(LOG_DDSPLUGIN) << "Sequential devices are not supported";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2520,25 +2526,25 @@ bool QDDSHandler::verifyHeader(const DDSHeader &dds) const
|
||||
quint32 requiredFlags = DDSHeader::FlagCaps | DDSHeader::FlagHeight
|
||||
| DDSHeader::FlagWidth | DDSHeader::FlagPixelFormat;
|
||||
if ((flags & requiredFlags) != requiredFlags) {
|
||||
qWarning() << "Wrong dds.flags - not all required flags present. "
|
||||
qCWarning(LOG_DDSPLUGIN) << "Wrong dds.flags - not all required flags present. "
|
||||
"Actual flags :" << flags;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dds.size != ddsSize) {
|
||||
qWarning() << "Wrong dds.size: actual =" << dds.size
|
||||
qCWarning(LOG_DDSPLUGIN) << "Wrong dds.size: actual =" << dds.size
|
||||
<< "expected =" << ddsSize;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dds.pixelFormat.size != pixelFormatSize) {
|
||||
qWarning() << "Wrong dds.pixelFormat.size: actual =" << dds.pixelFormat.size
|
||||
qCWarning(LOG_DDSPLUGIN) << "Wrong dds.pixelFormat.size: actual =" << dds.pixelFormat.size
|
||||
<< "expected =" << pixelFormatSize;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dds.width > INT_MAX || dds.height > INT_MAX) {
|
||||
qWarning() << "Can't read image with w/h bigger than INT_MAX";
|
||||
qCWarning(LOG_DDSPLUGIN) << "Can't read image with w/h bigger than INT_MAX";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,14 +75,20 @@
|
||||
|
||||
#include <QColorSpace>
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QFloat16>
|
||||
#include <QImage>
|
||||
#include <QImageIOPlugin>
|
||||
#include <QLocale>
|
||||
#include <QLoggingCategory>
|
||||
#include <QThread>
|
||||
#include <QTimeZone>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_EXRPLUGIN, "kf.imageformats.plugins.exr", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_EXRPLUGIN, "kf.imageformats.plugins.exr", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
class K_IStream : public Imf::IStream
|
||||
{
|
||||
public:
|
||||
@@ -236,10 +242,10 @@ static QStringList viewList(const Imf::Header &h)
|
||||
}
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
void printAttributes(const Imf::Header &h)
|
||||
static void printAttributes(const Imf::Header &h)
|
||||
{
|
||||
for (auto i = h.begin(); i != h.end(); ++i) {
|
||||
qDebug() << i.name();
|
||||
qCDebug(LOG_EXRPLUGIN) << i.name();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -385,14 +391,14 @@ bool EXRHandler::read(QImage *outImage)
|
||||
|
||||
// limiting the maximum image size on a reasonable size (as done in other plugins)
|
||||
if (width > EXR_MAX_IMAGE_WIDTH || height > EXR_MAX_IMAGE_HEIGHT) {
|
||||
qWarning() << "The maximum image size is limited to" << EXR_MAX_IMAGE_WIDTH << "x" << EXR_MAX_IMAGE_HEIGHT << "px";
|
||||
qCWarning(LOG_EXRPLUGIN) << "The maximum image size is limited to" << EXR_MAX_IMAGE_WIDTH << "x" << EXR_MAX_IMAGE_HEIGHT << "px";
|
||||
return false;
|
||||
}
|
||||
|
||||
// creating the image
|
||||
QImage image = imageAlloc(width, height, imageFormat(file));
|
||||
if (image.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid size?" << QSize(width, height);
|
||||
qCWarning(LOG_EXRPLUGIN) << "Failed to allocate image, invalid size?" << QSize(width, height);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -560,7 +566,7 @@ bool EXRHandler::write(const QImage &image)
|
||||
|
||||
// limiting the maximum image size on a reasonable size (as done in other plugins)
|
||||
if (width > EXR_MAX_IMAGE_WIDTH || height > EXR_MAX_IMAGE_HEIGHT) {
|
||||
qWarning() << "The maximum image size is limited to" << EXR_MAX_IMAGE_WIDTH << "x" << EXR_MAX_IMAGE_HEIGHT << "px";
|
||||
qCWarning(LOG_EXRPLUGIN) << "The maximum image size is limited to" << EXR_MAX_IMAGE_WIDTH << "x" << EXR_MAX_IMAGE_HEIGHT << "px";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -776,7 +782,7 @@ int EXRHandler::currentImageNumber() const
|
||||
bool EXRHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("EXRHandler::canRead() called with no device");
|
||||
qCWarning(LOG_EXRPLUGIN) << "EXRHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#include <QLoggingCategory>
|
||||
#include <QRegularExpressionMatch>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
/* *** HDR_HALF_QUALITY ***
|
||||
* If defined, a 16-bits float image is created, otherwise a 32-bits float ones (default).
|
||||
*/
|
||||
@@ -425,7 +423,7 @@ bool HDRHandler::read(QImage *outImage)
|
||||
|
||||
QImage img;
|
||||
if (!LoadHDR(s, h, img)) {
|
||||
// qDebug() << "Error loading HDR file.";
|
||||
// qCWarning(HDRPLUGIN) << "Error loading HDR file.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -502,7 +500,7 @@ bool HDRHandler::canRead() const
|
||||
bool HDRHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("HDRHandler::canRead() called with no device");
|
||||
qCWarning(HDRPLUGIN) << "HDRHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,19 @@
|
||||
#include <libheif/heif.h>
|
||||
|
||||
#include <QColorSpace>
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
#include <QPointF>
|
||||
#include <QSysInfo>
|
||||
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_HEIFPLUGIN, "kf.imageformats.plugins.heif", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_HEIFPLUGIN, "kf.imageformats.plugins.heif", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
#ifndef HEIF_MAX_METADATA_SIZE
|
||||
/*!
|
||||
* XMP and EXIF maximum size.
|
||||
@@ -112,7 +119,7 @@ bool HEIFHandler::read(QImage *outImage)
|
||||
bool HEIFHandler::write(const QImage &image)
|
||||
{
|
||||
if (image.format() == QImage::Format_Invalid || image.isNull()) {
|
||||
qWarning("No image data to save");
|
||||
qCWarning(LOG_HEIFPLUGIN) << "No image data to save";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -208,7 +215,7 @@ bool HEIFHandler::write_helper(const QImage &image)
|
||||
|
||||
err = heif_image_create(tmpimage.width(), tmpimage.height(), heif_colorspace_RGB, chroma, &h_image);
|
||||
if (err.code) {
|
||||
qWarning() << "heif_image_create error:" << err.message;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "heif_image_create error:" << err.message;
|
||||
heif_context_free(context);
|
||||
return false;
|
||||
}
|
||||
@@ -287,7 +294,7 @@ bool HEIFHandler::write_helper(const QImage &image)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Unsupported depth:" << save_depth;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Unsupported depth:" << save_depth;
|
||||
heif_image_release(h_image);
|
||||
heif_context_free(context);
|
||||
return false;
|
||||
@@ -297,7 +304,7 @@ bool HEIFHandler::write_helper(const QImage &image)
|
||||
struct heif_encoder *encoder = nullptr;
|
||||
err = heif_context_get_encoder_for_format(context, encoder_codec, &encoder);
|
||||
if (err.code) {
|
||||
qWarning() << "Unable to get an encoder instance:" << err.message;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Unable to get an encoder instance:" << err.message;
|
||||
heif_image_release(h_image);
|
||||
heif_context_free(context);
|
||||
return false;
|
||||
@@ -315,7 +322,7 @@ bool HEIFHandler::write_helper(const QImage &image)
|
||||
encoder_options->save_alpha_channel = save_alpha;
|
||||
|
||||
if ((tmpimage.width() % 2 == 1) || (tmpimage.height() % 2 == 1)) {
|
||||
qWarning() << "Image has odd dimension!\nUse even-numbered dimension(s) for better compatibility with other HEIF implementations.";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Image has odd dimension!\nUse even-numbered dimension(s) for better compatibility with other HEIF implementations.";
|
||||
if (save_alpha) {
|
||||
// This helps to save alpha channel when image has odd dimension
|
||||
encoder_options->macOS_compatibility_workaround = 0;
|
||||
@@ -347,7 +354,7 @@ bool HEIFHandler::write_helper(const QImage &image)
|
||||
}
|
||||
|
||||
if (err.code) {
|
||||
qWarning() << "heif_context_encode_image failed:" << err.message;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "heif_context_encode_image failed:" << err.message;
|
||||
heif_encoder_release(encoder);
|
||||
heif_image_release(h_image);
|
||||
heif_context_free(context);
|
||||
@@ -364,7 +371,7 @@ bool HEIFHandler::write_helper(const QImage &image)
|
||||
heif_image_release(h_image);
|
||||
|
||||
if (err.code) {
|
||||
qWarning() << "Writing HEIF image failed:" << err.message;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Writing HEIF image failed:" << err.message;
|
||||
heif_context_free(context);
|
||||
return false;
|
||||
}
|
||||
@@ -524,7 +531,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
struct heif_error err = heif_context_read_from_memory(ctx, static_cast<const void *>(buffer.constData()), buffer.size(), nullptr);
|
||||
|
||||
if (err.code) {
|
||||
qWarning() << "heif_context_read_from_memory error:" << err.message;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "heif_context_read_from_memory error:" << err.message;
|
||||
heif_context_free(ctx);
|
||||
m_parseState = ParseHeicError;
|
||||
return false;
|
||||
@@ -533,7 +540,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
struct heif_image_handle *handle = nullptr;
|
||||
err = heif_context_get_primary_image_handle(ctx, &handle);
|
||||
if (err.code) {
|
||||
qWarning() << "heif_context_get_primary_image_handle error:" << err.message;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "heif_context_get_primary_image_handle error:" << err.message;
|
||||
heif_context_free(ctx);
|
||||
m_parseState = ParseHeicError;
|
||||
return false;
|
||||
@@ -543,7 +550,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
m_parseState = ParseHeicError;
|
||||
heif_image_handle_release(handle);
|
||||
heif_context_free(ctx);
|
||||
qWarning() << "HEIC image has zero dimension";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "HEIC image has zero dimension";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -553,7 +560,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
m_parseState = ParseHeicError;
|
||||
heif_image_handle_release(handle);
|
||||
heif_context_free(ctx);
|
||||
qWarning() << "HEIF image with undefined or unsupported bit depth.";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "HEIF image with undefined or unsupported bit depth.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -582,7 +589,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
m_parseState = ParseHeicError;
|
||||
heif_image_handle_release(handle);
|
||||
heif_context_free(ctx);
|
||||
qWarning() << "Unsupported bit depth:" << bit_depth;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Unsupported bit depth:" << bit_depth;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -597,7 +604,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
|
||||
#if LIBHEIF_HAVE_VERSION(1, 13, 0)
|
||||
if (err.code == heif_error_Invalid_input && err.subcode == heif_suberror_Unknown_NCLX_matrix_coefficients && img == nullptr && buffer.contains("Xiaomi")) {
|
||||
qWarning() << "Non-standard HEIF image with invalid matrix_coefficients, probably made by a Xiaomi device!";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Non-standard HEIF image with invalid matrix_coefficients, probably made by a Xiaomi device!";
|
||||
|
||||
// second try to decode with strict decoding disabled
|
||||
decoder_option->strict_decoding = 0;
|
||||
@@ -610,7 +617,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
}
|
||||
|
||||
if (err.code) {
|
||||
qWarning() << "heif_decode_image error:" << err.message;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "heif_decode_image error:" << err.message;
|
||||
heif_image_handle_release(handle);
|
||||
heif_context_free(ctx);
|
||||
m_parseState = ParseHeicError;
|
||||
@@ -627,7 +634,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
heif_image_handle_release(handle);
|
||||
heif_context_free(ctx);
|
||||
m_parseState = ParseHeicError;
|
||||
qWarning() << "HEIC image size invalid:" << imageSize;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "HEIC image size invalid:" << imageSize;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -639,7 +646,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
heif_image_handle_release(handle);
|
||||
heif_context_free(ctx);
|
||||
m_parseState = ParseHeicError;
|
||||
qWarning() << "HEIC data pixels information not valid!";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "HEIC data pixels information not valid!";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -649,7 +656,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
heif_image_handle_release(handle);
|
||||
heif_context_free(ctx);
|
||||
m_parseState = ParseHeicError;
|
||||
qWarning() << "Unable to allocate memory!";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Unable to allocate memory!";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -844,7 +851,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
heif_image_handle_release(handle);
|
||||
heif_context_free(ctx);
|
||||
m_parseState = ParseHeicError;
|
||||
qWarning() << "Unsupported bit depth:" << bit_depth;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Unsupported bit depth:" << bit_depth;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
@@ -856,15 +863,15 @@ bool HEIFHandler::ensureDecoder()
|
||||
QByteArray ba(rawProfileSize, 0);
|
||||
err = heif_image_handle_get_raw_color_profile(handle, ba.data());
|
||||
if (err.code) {
|
||||
qWarning() << "icc profile loading failed";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "icc profile loading failed";
|
||||
} else {
|
||||
QColorSpace colorspace = QColorSpace::fromIccProfile(ba);
|
||||
if (!colorspace.isValid()) {
|
||||
qWarning() << "HEIC image has Qt-unsupported or invalid ICC profile!";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "HEIC image has Qt-unsupported or invalid ICC profile!";
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 8, 0))
|
||||
else if (colorspace.colorModel() == QColorSpace::ColorModel::Cmyk) {
|
||||
qWarning("CMYK ICC profile is not expected for HEIF, discarding the ICCprofile!");
|
||||
qCWarning(LOG_HEIFPLUGIN) << "CMYK ICC profile is not expected for HEIF, discarding the ICCprofile!";
|
||||
colorspace = QColorSpace();
|
||||
} else if (colorspace.colorModel() == QColorSpace::ColorModel::Gray) {
|
||||
if (hasAlphaChannel) {
|
||||
@@ -884,7 +891,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
}
|
||||
colorspace = QColorSpace(gray_whitePoint, redP, greenP, blueP, trc_new, gamma_new);
|
||||
if (!colorspace.isValid()) {
|
||||
qWarning("HEIF plugin created invalid QColorSpace!");
|
||||
qCWarning(LOG_HEIFPLUGIN) << "HEIF plugin created invalid QColorSpace!";
|
||||
}
|
||||
} else { // no alpha channel
|
||||
m_current_image.convertTo(bit_depth > 8 ? QImage::Format_Grayscale16 : QImage::Format_Grayscale8);
|
||||
@@ -894,14 +901,14 @@ bool HEIFHandler::ensureDecoder()
|
||||
m_current_image.setColorSpace(colorspace);
|
||||
}
|
||||
} else {
|
||||
qWarning() << "icc profile is empty or above limits";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "icc profile is empty or above limits";
|
||||
}
|
||||
|
||||
} else if (profileType == heif_color_profile_type_nclx) {
|
||||
struct heif_color_profile_nclx *nclx = nullptr;
|
||||
err = heif_image_handle_get_nclx_color_profile(handle, &nclx);
|
||||
if (err.code || !nclx) {
|
||||
qWarning() << "nclx profile loading failed";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "nclx profile loading failed";
|
||||
} else {
|
||||
const QPointF redPoint(nclx->color_primary_red_x, nclx->color_primary_red_y);
|
||||
const QPointF greenPoint(nclx->color_primary_green_x, nclx->color_primary_green_y);
|
||||
@@ -936,9 +943,9 @@ bool HEIFHandler::ensureDecoder()
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
qWarning("CICP color_primaries: %d, transfer_characteristics: %d\nThe colorspace is unsupported by this plug-in yet.",
|
||||
nclx->color_primaries,
|
||||
nclx->transfer_characteristics);
|
||||
qCWarning(LOG_HEIFPLUGIN) << "CICP color_primaries: %d, transfer_characteristics: %d\nThe colorspace is unsupported by this plug-in yet."
|
||||
<< nclx->color_primaries
|
||||
<< nclx->transfer_characteristics;
|
||||
q_trc = QColorSpace::TransferFunction::SRgb;
|
||||
break;
|
||||
}
|
||||
@@ -960,7 +967,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
heif_nclx_color_profile_free(nclx);
|
||||
|
||||
if (!m_current_image.colorSpace().isValid()) {
|
||||
qWarning() << "HEIC plugin created invalid QColorSpace from NCLX!";
|
||||
qCWarning(LOG_HEIFPLUGIN) << "HEIC plugin created invalid QColorSpace from NCLX!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,7 +991,7 @@ bool HEIFHandler::ensureDecoder()
|
||||
QByteArray ba(sz, char());
|
||||
auto err = heif_image_handle_get_metadata(handle, ids[n], ba.data());
|
||||
if (err.code != heif_error_Ok) {
|
||||
qWarning() << "Error while reading metadata" << err.message;
|
||||
qCWarning(LOG_HEIFPLUGIN) << "Error while reading metadata" << err.message;
|
||||
continue;
|
||||
}
|
||||
if (isXmp) {
|
||||
|
||||
@@ -13,10 +13,17 @@
|
||||
#include <QIODevice>
|
||||
#include <QImage>
|
||||
#include <QImageReader>
|
||||
#include <QLoggingCategory>
|
||||
#include <QThread>
|
||||
|
||||
#include <openjpeg.h>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_JP2PLUGIN, "kf.imageformats.plugins.jp2", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_JP2PLUGIN, "kf.imageformats.plugins.jp2", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
/* *** JP2_MAX_IMAGE_WIDTH and JP2_MAX_IMAGE_HEIGHT ***
|
||||
* The maximum size in pixel allowed by the plugin.
|
||||
*/
|
||||
@@ -48,19 +55,19 @@
|
||||
static void error_callback(const char *msg, void *client_data)
|
||||
{
|
||||
Q_UNUSED(client_data)
|
||||
qCritical() << msg;
|
||||
qCCritical(LOG_JP2PLUGIN) << msg;
|
||||
}
|
||||
|
||||
static void warning_callback(const char *msg, void *client_data)
|
||||
{
|
||||
Q_UNUSED(client_data)
|
||||
qWarning() << msg;
|
||||
qCWarning(LOG_JP2PLUGIN) << msg;
|
||||
}
|
||||
|
||||
static void info_callback(const char *msg, void *client_data)
|
||||
{
|
||||
Q_UNUSED(client_data)
|
||||
qInfo() << msg;
|
||||
qCInfo(LOG_JP2PLUGIN) << msg;
|
||||
}
|
||||
|
||||
static OPJ_SIZE_T jp2_read(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
|
||||
@@ -186,9 +193,9 @@ public:
|
||||
void enableThreads(opj_codec_t *codec) const
|
||||
{
|
||||
if (!opj_has_thread_support()) {
|
||||
qInfo() << "OpenJPEG doesn't support multi-threading!";
|
||||
qCInfo(LOG_JP2PLUGIN) << "OpenJPEG doesn't support multi-threading!";
|
||||
} else if (!opj_codec_set_threads(codec, std::max(1, QThread::idealThreadCount() / 2))) {
|
||||
qWarning() << "Unable to enable multi-threading!";
|
||||
qCWarning(LOG_JP2PLUGIN) << "Unable to enable multi-threading!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,12 +237,12 @@ public:
|
||||
|
||||
opj_set_default_decoder_parameters(&m_dparameters);
|
||||
if (!opj_setup_decoder(m_jp2_codec, &m_dparameters)) {
|
||||
qCritical() << "Failed to setup JP2 decoder!";
|
||||
qCCritical(LOG_JP2PLUGIN) << "Failed to setup JP2 decoder!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!opj_read_header(m_jp2_stream, m_jp2_codec, &m_jp2_image)) {
|
||||
qCritical() << "Failed to read JP2 header!";
|
||||
qCCritical(LOG_JP2PLUGIN) << "Failed to read JP2 header!";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -308,7 +315,7 @@ public:
|
||||
}
|
||||
|
||||
if (!opj_decode(m_jp2_codec, m_jp2_stream, m_jp2_image)) {
|
||||
qCritical() << "Failed to decoding JP2 image!";
|
||||
qCCritical(LOG_JP2PLUGIN) << "Failed to decoding JP2 image!";
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -335,12 +342,12 @@ public:
|
||||
bool checkSizeLimits(qint32 width, qint32 height, qint32 nchannels) const
|
||||
{
|
||||
if (width > JP2_MAX_IMAGE_WIDTH || height > JP2_MAX_IMAGE_HEIGHT || width < 1 || height < 1) {
|
||||
qCritical() << "Maximum image size is limited to" << JP2_MAX_IMAGE_WIDTH << "x" << JP2_MAX_IMAGE_HEIGHT << "pixels";
|
||||
qCCritical(LOG_JP2PLUGIN) << "Maximum image size is limited to" << JP2_MAX_IMAGE_WIDTH << "x" << JP2_MAX_IMAGE_HEIGHT << "pixels";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (qint64(width) * qint64(height) > JP2_MAX_IMAGE_PIXELS) {
|
||||
qCritical() << "Maximum image size is limited to" << JP2_MAX_IMAGE_PIXELS << "pixels";
|
||||
qCCritical(LOG_JP2PLUGIN) << "Maximum image size is limited to" << JP2_MAX_IMAGE_PIXELS << "pixels";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -348,7 +355,7 @@ public:
|
||||
auto maxBytes = qint64(QImageReader::allocationLimit()) * 1024 * 1024;
|
||||
auto neededBytes = qint64(width) * height * nchannels * 4;
|
||||
if (maxBytes > 0 && neededBytes > maxBytes) {
|
||||
qCritical() << "Allocation limit set to" << (maxBytes / 1024 / 1024) << "MiB but" << (neededBytes / 1024 / 1024) << "MiB are needed!";
|
||||
qCCritical(LOG_JP2PLUGIN) << "Allocation limit set to" << (maxBytes / 1024 / 1024) << "MiB but" << (neededBytes / 1024 / 1024) << "MiB are needed!";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -584,7 +591,7 @@ public:
|
||||
#endif
|
||||
default:
|
||||
if (image.depth() > 32) {
|
||||
qWarning() << "The image is saved losing precision!";
|
||||
qCWarning(LOG_JP2PLUGIN) << "The image is saved losing precision!";
|
||||
}
|
||||
convFormat = ncomp == 4 ? QImage::Format_RGBA8888 : QImage::Format_RGBX8888;
|
||||
break;
|
||||
@@ -677,13 +684,13 @@ public:
|
||||
bool writeImage(QIODevice *device, const QImage &image)
|
||||
{
|
||||
if (!imageToJp2(image)) {
|
||||
qCritical() << "Error while creating JP2 image!";
|
||||
qCCritical(LOG_JP2PLUGIN) << "Error while creating JP2 image!";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<opj_codec_t, std::function<void(opj_codec_t *)>> codec(opj_create_compress(encoderFormat()), opj_destroy_codec);
|
||||
if (codec == nullptr) {
|
||||
qCritical() << "Error while creating encoder!";
|
||||
qCCritical(LOG_JP2PLUGIN) << "Error while creating encoder!";
|
||||
return false;
|
||||
}
|
||||
enableThreads(codec.get());
|
||||
@@ -754,7 +761,7 @@ bool JP2Handler::canRead() const
|
||||
bool JP2Handler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("JP2Handler::canRead() called with no device");
|
||||
qCWarning(LOG_JP2PLUGIN) << "JP2Handler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QThread>
|
||||
#include <QtGlobal>
|
||||
|
||||
@@ -19,6 +20,13 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_JXLPLUGIN, "kf.imageformats.plugins.jxl", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_JXLPLUGIN, "kf.imageformats.plugins.jxl", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
|
||||
// Avoid rotation on buggy Qts (see also https://bugreports.qt.io/browse/QTBUG-126575)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 3)
|
||||
#ifndef JXL_QT_AUTOTRANSFORM
|
||||
@@ -163,7 +171,7 @@ bool QJpegXLHandler::ensureDecoder()
|
||||
|
||||
m_decoder = JxlDecoderCreate(nullptr);
|
||||
if (!m_decoder) {
|
||||
qWarning("ERROR: JxlDecoderCreate failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderCreate failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -182,14 +190,14 @@ bool QJpegXLHandler::ensureDecoder()
|
||||
m_runner = JxlThreadParallelRunnerCreate(nullptr, num_worker_threads);
|
||||
|
||||
if (JxlDecoderSetParallelRunner(m_decoder, JxlThreadParallelRunner, m_runner) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSetParallelRunner failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetParallelRunner failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (JxlDecoderSetInput(m_decoder, reinterpret_cast<const uint8_t *>(m_rawData.constData()), m_rawData.size()) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSetInput failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetInput failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -198,38 +206,38 @@ bool QJpegXLHandler::ensureDecoder()
|
||||
|
||||
JxlDecoderStatus status = JxlDecoderSubscribeEvents(m_decoder, JXL_DEC_BASIC_INFO | JXL_DEC_COLOR_ENCODING | JXL_DEC_FRAME);
|
||||
if (status == JXL_DEC_ERROR) {
|
||||
qWarning("ERROR: JxlDecoderSubscribeEvents failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSubscribeEvents failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
status = JxlDecoderProcessInput(m_decoder);
|
||||
if (status == JXL_DEC_ERROR) {
|
||||
qWarning("ERROR: JXL decoding failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JXL decoding failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
if (status == JXL_DEC_NEED_MORE_INPUT) {
|
||||
qWarning("ERROR: JXL data incomplete");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JXL data incomplete");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
status = JxlDecoderGetBasicInfo(m_decoder, &m_basicinfo);
|
||||
if (status != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JXL basic info not available");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JXL basic info not available");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_basicinfo.xsize == 0 || m_basicinfo.ysize == 0) {
|
||||
qWarning("ERROR: JXL image has zero dimensions");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JXL image has zero dimensions");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_basicinfo.xsize > MAX_IMAGE_WIDTH || m_basicinfo.ysize > MAX_IMAGE_HEIGHT) {
|
||||
qWarning("JXL image (%dx%d) is too large", m_basicinfo.xsize, m_basicinfo.ysize);
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL image (%dx%d) is too large", m_basicinfo.xsize, m_basicinfo.ysize);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -246,7 +254,7 @@ bool QJpegXLHandler::countALLFrames()
|
||||
|
||||
JxlDecoderStatus status = JxlDecoderProcessInput(m_decoder);
|
||||
if (status != JXL_DEC_COLOR_ENCODING) {
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_COLOR_ENCODING", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_COLOR_ENCODING", status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -258,10 +266,10 @@ bool QJpegXLHandler::countALLFrames()
|
||||
if (jxlcms) {
|
||||
status = JxlDecoderSetCms(m_decoder, *jxlcms);
|
||||
if (status != JXL_DEC_SUCCESS) {
|
||||
qWarning("JxlDecoderSetCms ERROR");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlDecoderSetCms ERROR");
|
||||
}
|
||||
} else {
|
||||
qWarning("No JPEG XL CMS Interface");
|
||||
qCWarning(LOG_JXLPLUGIN, "No JPEG XL CMS Interface");
|
||||
}
|
||||
|
||||
JxlColorEncodingSetToSRGB(&color_encoding, is_gray ? JXL_TRUE : JXL_FALSE);
|
||||
@@ -338,16 +346,16 @@ bool QJpegXLHandler::countALLFrames()
|
||||
m_colorspace = QColorSpace::fromIccProfile(icc_data);
|
||||
|
||||
if (!m_colorspace.isValid()) {
|
||||
qWarning("JXL image has Qt-unsupported or invalid ICC profile!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL image has Qt-unsupported or invalid ICC profile!");
|
||||
}
|
||||
} else {
|
||||
qWarning("Failed to obtain data from JPEG XL decoder");
|
||||
qCWarning(LOG_JXLPLUGIN, "Failed to obtain data from JPEG XL decoder");
|
||||
}
|
||||
} else {
|
||||
qWarning("Empty ICC data");
|
||||
qCWarning(LOG_JXLPLUGIN, "Empty ICC data");
|
||||
}
|
||||
} else {
|
||||
qWarning("no ICC, other color profile");
|
||||
qCWarning(LOG_JXLPLUGIN, "no ICC, other color profile");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,13 +367,13 @@ bool QJpegXLHandler::countALLFrames()
|
||||
if (status != JXL_DEC_FRAME) {
|
||||
switch (status) {
|
||||
case JXL_DEC_ERROR:
|
||||
qWarning("ERROR: JXL decoding failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JXL decoding failed");
|
||||
break;
|
||||
case JXL_DEC_NEED_MORE_INPUT:
|
||||
qWarning("ERROR: JXL data incomplete");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JXL data incomplete");
|
||||
break;
|
||||
default:
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_FRAME", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_FRAME", status);
|
||||
break;
|
||||
}
|
||||
m_parseState = ParseJpegXLError;
|
||||
@@ -373,7 +381,7 @@ bool QJpegXLHandler::countALLFrames()
|
||||
}
|
||||
|
||||
if (JxlDecoderGetFrameHeader(m_decoder, &frame_header) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderGetFrameHeader failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderGetFrameHeader failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -392,13 +400,13 @@ bool QJpegXLHandler::countALLFrames()
|
||||
}
|
||||
|
||||
if (m_framedelays.isEmpty()) {
|
||||
qWarning("no frames loaded by the JXL plug-in");
|
||||
qCWarning(LOG_JXLPLUGIN, "no frames loaded by the JXL plug-in");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_framedelays.count() == 1) {
|
||||
qWarning("JXL file was marked as animation but it has only one frame.");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL file was marked as animation but it has only one frame.");
|
||||
m_basicinfo.have_animation = JXL_FALSE;
|
||||
}
|
||||
} else { // static picture
|
||||
@@ -414,7 +422,7 @@ bool QJpegXLHandler::countALLFrames()
|
||||
for (uint32_t index = 0; index < m_basicinfo.num_extra_channels; index++) {
|
||||
status = JxlDecoderGetExtraChannelInfo(m_decoder, index, &channel_info);
|
||||
if (status != JXL_DEC_SUCCESS) {
|
||||
qWarning("JxlDecoderGetExtraChannelInfo for channel %d returned %d", index, status);
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlDecoderGetExtraChannelInfo for channel %d returned %d", index, status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -430,7 +438,7 @@ bool QJpegXLHandler::countALLFrames()
|
||||
for (uint32_t alpha_index = index + 1; alpha_index < m_basicinfo.num_extra_channels; alpha_index++) {
|
||||
status = JxlDecoderGetExtraChannelInfo(m_decoder, alpha_index, &channel_info);
|
||||
if (status != JXL_DEC_SUCCESS) {
|
||||
qWarning("JxlDecoderGetExtraChannelInfo for channel %d returned %d", alpha_index, status);
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlDecoderGetExtraChannelInfo for channel %d returned %d", alpha_index, status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -443,14 +451,14 @@ bool QJpegXLHandler::countALLFrames()
|
||||
}
|
||||
|
||||
if (!alpha_found) {
|
||||
qWarning("JXL BasicInfo indicate Alpha channel but it was not found");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL BasicInfo indicate Alpha channel but it was not found");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qWarning("JXL has BLACK channel but colorspace is not CMYK!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL has BLACK channel but colorspace is not CMYK!");
|
||||
}
|
||||
break;
|
||||
} else if ((channel_info.type == JXL_CHANNEL_ALPHA) && !alpha_found) {
|
||||
@@ -460,7 +468,7 @@ bool QJpegXLHandler::countALLFrames()
|
||||
}
|
||||
|
||||
if (!m_isCMYK && (m_colorspace.colorModel() == QColorSpace::ColorModel::Cmyk)) {
|
||||
qWarning("JXL has CMYK colorspace but BLACK channel was not found!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL has CMYK colorspace but BLACK channel was not found!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -484,7 +492,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
{
|
||||
JxlDecoderStatus status = JxlDecoderProcessInput(m_decoder);
|
||||
if (status != JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_NEED_IMAGE_OUT_BUFFER", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_NEED_IMAGE_OUT_BUFFER", status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -512,7 +520,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
if (m_basicinfo.alpha_bits > 0) { // CMYK + alpha
|
||||
QImage tmp_cmyk_image = imageAlloc(m_basicinfo.xsize, m_basicinfo.ysize, QImage::Format_CMYK8888);
|
||||
if (tmp_cmyk_image.isNull()) {
|
||||
qWarning("Memory cannot be allocated");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -521,7 +529,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
|
||||
uchar *pixels_alpha = reinterpret_cast<uchar *>(malloc(extra_buffer_size));
|
||||
if (!pixels_alpha) {
|
||||
qWarning("Memory cannot be allocated for ALPHA channel");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated for ALPHA channel");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -530,7 +538,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
if (!pixels_cmy) {
|
||||
free(pixels_alpha);
|
||||
pixels_alpha = nullptr;
|
||||
qWarning("Memory cannot be allocated for CMY buffer");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated for CMY buffer");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -541,7 +549,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
pixels_cmy = nullptr;
|
||||
free(pixels_alpha);
|
||||
pixels_alpha = nullptr;
|
||||
qWarning("Memory cannot be allocated for BLACK buffer");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated for BLACK buffer");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -553,7 +561,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
pixels_cmy = nullptr;
|
||||
free(pixels_alpha);
|
||||
pixels_alpha = nullptr;
|
||||
qWarning("ERROR: JxlDecoderSetImageOutBuffer failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetImageOutBuffer failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -565,7 +573,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
pixels_cmy = nullptr;
|
||||
free(pixels_alpha);
|
||||
pixels_alpha = nullptr;
|
||||
qWarning("ERROR: JxlDecoderSetExtraChannelBuffer failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetExtraChannelBuffer failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -577,7 +585,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
pixels_cmy = nullptr;
|
||||
free(pixels_alpha);
|
||||
pixels_alpha = nullptr;
|
||||
qWarning("ERROR: JxlDecoderSetExtraChannelBuffer failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetExtraChannelBuffer failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -590,7 +598,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
pixels_cmy = nullptr;
|
||||
free(pixels_alpha);
|
||||
pixels_alpha = nullptr;
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_FULL_IMAGE", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_FULL_IMAGE", status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -624,7 +632,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
if (m_current_image.isNull()) {
|
||||
free(pixels_alpha);
|
||||
pixels_alpha = nullptr;
|
||||
qWarning("ERROR: convertedToColorSpace returned empty image");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: convertedToColorSpace returned empty image");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -652,7 +660,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
} else { // CMYK (no alpha)
|
||||
m_current_image = imageAlloc(m_basicinfo.xsize, m_basicinfo.ysize, QImage::Format_CMYK8888);
|
||||
if (m_current_image.isNull()) {
|
||||
qWarning("Memory cannot be allocated");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -661,7 +669,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
|
||||
pixels_cmy = reinterpret_cast<uchar *>(malloc(cmy_buffer_size));
|
||||
if (!pixels_cmy) {
|
||||
qWarning("Memory cannot be allocated for CMY buffer");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated for CMY buffer");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -670,7 +678,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
if (!pixels_black) {
|
||||
free(pixels_cmy);
|
||||
pixels_cmy = nullptr;
|
||||
qWarning("Memory cannot be allocated for BLACK buffer");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated for BLACK buffer");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -680,7 +688,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
pixels_black = nullptr;
|
||||
free(pixels_cmy);
|
||||
pixels_cmy = nullptr;
|
||||
qWarning("ERROR: JxlDecoderSetImageOutBuffer failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetImageOutBuffer failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -690,7 +698,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
pixels_black = nullptr;
|
||||
free(pixels_cmy);
|
||||
pixels_cmy = nullptr;
|
||||
qWarning("ERROR: JxlDecoderSetExtraChannelBuffer failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetExtraChannelBuffer failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -701,7 +709,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
pixels_black = nullptr;
|
||||
free(pixels_cmy);
|
||||
pixels_cmy = nullptr;
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_FULL_IMAGE", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_FULL_IMAGE", status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -739,7 +747,7 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
} else { // RGB or GRAY
|
||||
m_current_image = imageAlloc(m_basicinfo.xsize, m_basicinfo.ysize, m_input_image_format);
|
||||
if (m_current_image.isNull()) {
|
||||
qWarning("Memory cannot be allocated");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -761,21 +769,21 @@ bool QJpegXLHandler::decode_one_frame()
|
||||
rgb_buffer_size += 2 * size_t(m_input_pixel_format.num_channels) * size_t(m_current_image.width());
|
||||
break;
|
||||
default:
|
||||
qWarning("ERROR: unsupported data type");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: unsupported data type");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (JxlDecoderSetImageOutBuffer(m_decoder, &m_input_pixel_format, m_current_image.bits(), rgb_buffer_size) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSetImageOutBuffer failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetImageOutBuffer failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
status = JxlDecoderProcessInput(m_decoder);
|
||||
if (status != JXL_DEC_FULL_IMAGE) {
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_FULL_IMAGE", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_FULL_IMAGE", status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -841,29 +849,29 @@ bool QJpegXLHandler::read(QImage *image)
|
||||
bool QJpegXLHandler::write(const QImage &image)
|
||||
{
|
||||
if (image.format() == QImage::Format_Invalid) {
|
||||
qWarning("No image data to save");
|
||||
qCWarning(LOG_JXLPLUGIN, "No image data to save");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((image.width() == 0) || (image.height() == 0)) {
|
||||
qWarning("Image has zero dimension!");
|
||||
qCWarning(LOG_JXLPLUGIN, "Image has zero dimension!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((image.width() > MAX_IMAGE_WIDTH) || (image.height() > MAX_IMAGE_HEIGHT)) {
|
||||
qWarning("Image (%dx%d) is too large to save!", image.width(), image.height());
|
||||
qCWarning(LOG_JXLPLUGIN, "Image (%dx%d) is too large to save!", image.width(), image.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t pixel_count = size_t(image.width()) * image.height();
|
||||
if (MAX_IMAGE_PIXELS && pixel_count > MAX_IMAGE_PIXELS) {
|
||||
qWarning("Image (%dx%d) will not be saved because it has more than %d megapixels!", image.width(), image.height(), MAX_IMAGE_PIXELS / 1024 / 1024);
|
||||
qCWarning(LOG_JXLPLUGIN, "Image (%dx%d) will not be saved because it has more than %d megapixels!", image.width(), image.height(), MAX_IMAGE_PIXELS / 1024 / 1024);
|
||||
return false;
|
||||
}
|
||||
|
||||
JxlEncoder *encoder = JxlEncoderCreate(nullptr);
|
||||
if (!encoder) {
|
||||
qWarning("Failed to create Jxl encoder");
|
||||
qCWarning(LOG_JXLPLUGIN, "Failed to create Jxl encoder");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -873,7 +881,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
if (num_worker_threads > 1) {
|
||||
runner = JxlThreadParallelRunnerCreate(nullptr, num_worker_threads);
|
||||
if (JxlEncoderSetParallelRunner(encoder, JxlThreadParallelRunner, runner) != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderSetParallelRunner failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderSetParallelRunner failed");
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
JxlEncoderDestroy(encoder);
|
||||
return false;
|
||||
@@ -953,7 +961,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
const QByteArray cmyk_profile = image.colorSpace().iccProfile();
|
||||
if (cmyk_profile.isEmpty()) {
|
||||
qWarning("ERROR saving CMYK JXL: empty ICC profile");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR saving CMYK JXL: empty ICC profile");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -963,7 +971,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
status = JxlEncoderSetBasicInfo(encoder, &output_info);
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderSetBasicInfo for CMYK image failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderSetBasicInfo for CMYK image failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -973,7 +981,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
status = JxlEncoderSetExtraChannelInfo(encoder, 0, &extra_black_channel);
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderSetExtraChannelInfo for CMYK image failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderSetExtraChannelInfo for CMYK image failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -983,7 +991,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
status = JxlEncoderSetICCProfile(encoder, reinterpret_cast<const uint8_t *>(cmyk_profile.constData()), cmyk_profile.size());
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderSetICCProfile for CMYK image failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderSetICCProfile for CMYK image failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -996,7 +1004,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
const char *box_type = "Exif";
|
||||
status = JxlEncoderAddBox(encoder, box_type, reinterpret_cast<const uint8_t *>(exif_data.constData()), exif_data.size(), JXL_FALSE);
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderAddBox failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderAddBox failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1009,7 +1017,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
const char *box_type = "xml ";
|
||||
status = JxlEncoderAddBox(encoder, box_type, reinterpret_cast<const uint8_t *>(xmp_data.constData()), xmp_data.size(), JXL_FALSE);
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderAddBox failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderAddBox failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1027,7 +1035,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
pixels_cmy = reinterpret_cast<uchar *>(malloc(cmy_buffer_size));
|
||||
if (!pixels_cmy) {
|
||||
qWarning("Memory cannot be allocated for CMY buffer");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated for CMY buffer");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1037,7 +1045,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
pixels_black = reinterpret_cast<uchar *>(malloc(extra_buffer_size));
|
||||
if (!pixels_black) {
|
||||
qWarning("Memory cannot be allocated for BLACK buffer");
|
||||
qCWarning(LOG_JXLPLUGIN, "Memory cannot be allocated for BLACK buffer");
|
||||
free(pixels_cmy);
|
||||
pixels_cmy = nullptr;
|
||||
|
||||
@@ -1074,7 +1082,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
status = JxlEncoderAddImageFrame(frame_settings_lossless, &pixel_format, pixels_cmy, cmy_buffer_size);
|
||||
if (status == JXL_ENC_ERROR) {
|
||||
qWarning("JxlEncoderAddImageFrame failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderAddImageFrame failed!");
|
||||
free(pixels_black);
|
||||
pixels_black = nullptr;
|
||||
free(pixels_cmy);
|
||||
@@ -1094,7 +1102,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
pixels_cmy = nullptr;
|
||||
|
||||
if (status == JXL_ENC_ERROR) {
|
||||
qWarning("JxlEncoderSetExtraChannelBuffer failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderSetExtraChannelBuffer failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1263,7 +1271,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
if (gray_profile.isValid()) {
|
||||
tmpimage = image.convertedToColorSpace(gray_profile, tmpformat);
|
||||
} else {
|
||||
qWarning("JXL plugin created invalid grayscale QColorSpace!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL plugin created invalid grayscale QColorSpace!");
|
||||
tmpimage = image.convertToFormat(tmpformat);
|
||||
}
|
||||
} else if (!is_gray && image.colorSpace().colorModel() != QColorSpace::ColorModel::Rgb) {
|
||||
@@ -1287,7 +1295,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
if (rgb_profile.isValid()) {
|
||||
tmpimage = image.convertedToColorSpace(rgb_profile, tmpformat);
|
||||
} else {
|
||||
qWarning("JXL plugin created invalid RGB QColorSpace!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL plugin created invalid RGB QColorSpace!");
|
||||
tmpimage = image.convertToFormat(tmpformat);
|
||||
}
|
||||
} else { // ColorSpace matches the format
|
||||
@@ -1304,7 +1312,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
output_info.ysize = tmpimage.height();
|
||||
|
||||
if (output_info.xsize == 0 || output_info.ysize == 0 || tmpimage.isNull()) {
|
||||
qWarning("Unable to allocate memory for output image");
|
||||
qCWarning(LOG_JXLPLUGIN, "Unable to allocate memory for output image");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1420,7 +1428,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
status = JxlEncoderSetBasicInfo(encoder, &output_info);
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderSetBasicInfo failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderSetBasicInfo failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1431,7 +1439,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
if (iccprofile.size() > 0) {
|
||||
status = JxlEncoderSetICCProfile(encoder, reinterpret_cast<const uint8_t *>(iccprofile.constData()), iccprofile.size());
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderSetICCProfile failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderSetICCProfile failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1441,7 +1449,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
} else {
|
||||
status = JxlEncoderSetColorEncoding(encoder, &color_profile);
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderSetColorEncoding failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderSetColorEncoding failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1455,7 +1463,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
const char *box_type = "Exif";
|
||||
status = JxlEncoderAddBox(encoder, box_type, reinterpret_cast<const uint8_t *>(exif_data.constData()), exif_data.size(), JXL_FALSE);
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderAddBox failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderAddBox failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1468,7 +1476,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
const char *box_type = "xml ";
|
||||
status = JxlEncoderAddBox(encoder, box_type, reinterpret_cast<const uint8_t *>(xmp_data.constData()), xmp_data.size(), JXL_FALSE);
|
||||
if (status != JXL_ENC_SUCCESS) {
|
||||
qWarning("JxlEncoderAddBox failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderAddBox failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1494,7 +1502,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
float *packed_pixels32 = reinterpret_cast<float *>(malloc(buffer_size));
|
||||
if (!packed_pixels32) {
|
||||
qWarning("ERROR: JXL plug-in failed to allocate memory");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JXL plug-in failed to allocate memory");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1522,7 +1530,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
|
||||
quint16 *packed_pixels16 = reinterpret_cast<quint16 *>(malloc(buffer_size));
|
||||
if (!packed_pixels16) {
|
||||
qWarning("ERROR: JXL plug-in failed to allocate memory");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JXL plug-in failed to allocate memory");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1560,7 +1568,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
buffer_size += 2 * size_t(pixel_format.num_channels) * size_t(tmpimage.width());
|
||||
break;
|
||||
default:
|
||||
qWarning("ERROR: unsupported data type");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: unsupported data type");
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
@@ -1569,7 +1577,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
}
|
||||
|
||||
if (status == JXL_ENC_ERROR) {
|
||||
qWarning("JxlEncoderAddImageFrame failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderAddImageFrame failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1594,7 +1602,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
offset = next_out - compressed.data();
|
||||
compressed.resize(compressed.size() * 2);
|
||||
} else if (status == JXL_ENC_ERROR) {
|
||||
qWarning("JxlEncoderProcessOutput failed!");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlEncoderProcessOutput failed!");
|
||||
if (runner) {
|
||||
JxlThreadParallelRunnerDestroy(runner);
|
||||
}
|
||||
@@ -1616,7 +1624,7 @@ bool QJpegXLHandler::write(const QImage &image)
|
||||
if (write_status > 0) {
|
||||
return true;
|
||||
} else if (write_status == -1) {
|
||||
qWarning("Write error: %s\n", qUtf8Printable(device()->errorString()));
|
||||
qCWarning(LOG_JXLPLUGIN, "Write error: %s\n", qUtf8Printable(device()->errorString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1838,14 +1846,14 @@ bool QJpegXLHandler::rewind()
|
||||
JxlDecoderRewind(m_decoder);
|
||||
if (m_runner) {
|
||||
if (JxlDecoderSetParallelRunner(m_decoder, JxlThreadParallelRunner, m_runner) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSetParallelRunner failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetParallelRunner failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (JxlDecoderSetInput(m_decoder, reinterpret_cast<const uint8_t *>(m_rawData.constData()), m_rawData.size()) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSetInput failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetInput failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -1854,14 +1862,14 @@ bool QJpegXLHandler::rewind()
|
||||
|
||||
if (m_basicinfo.uses_original_profile == JXL_FALSE && m_basicinfo.have_animation == JXL_FALSE) {
|
||||
if (JxlDecoderSubscribeEvents(m_decoder, JXL_DEC_COLOR_ENCODING | JXL_DEC_FULL_IMAGE) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSubscribeEvents failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSubscribeEvents failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
JxlDecoderStatus status = JxlDecoderProcessInput(m_decoder);
|
||||
if (status != JXL_DEC_COLOR_ENCODING) {
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_COLOR_ENCODING", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_COLOR_ENCODING", status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -1870,10 +1878,10 @@ bool QJpegXLHandler::rewind()
|
||||
if (jxlcms) {
|
||||
status = JxlDecoderSetCms(m_decoder, *jxlcms);
|
||||
if (status != JXL_DEC_SUCCESS) {
|
||||
qWarning("JxlDecoderSetCms ERROR");
|
||||
qCWarning(LOG_JXLPLUGIN, "JxlDecoderSetCms ERROR");
|
||||
}
|
||||
} else {
|
||||
qWarning("No JPEG XL CMS Interface");
|
||||
qCWarning(LOG_JXLPLUGIN, "No JPEG XL CMS Interface");
|
||||
}
|
||||
|
||||
bool is_gray = m_basicinfo.num_color_channels == 1 && m_basicinfo.alpha_bits == 0;
|
||||
@@ -1882,7 +1890,7 @@ bool QJpegXLHandler::rewind()
|
||||
JxlDecoderSetPreferredColorProfile(m_decoder, &color_encoding);
|
||||
} else {
|
||||
if (JxlDecoderSubscribeEvents(m_decoder, JXL_DEC_FULL_IMAGE) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSubscribeEvents failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSubscribeEvents failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -1913,7 +1921,7 @@ bool QJpegXLHandler::decodeContainer()
|
||||
JxlDecoderRewind(m_decoder);
|
||||
|
||||
if (JxlDecoderSetInput(m_decoder, buf, len) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSetInput failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetInput failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -1921,11 +1929,11 @@ bool QJpegXLHandler::decodeContainer()
|
||||
JxlDecoderCloseInput(m_decoder);
|
||||
|
||||
if (JxlDecoderSetDecompressBoxes(m_decoder, JXL_TRUE) != JXL_DEC_SUCCESS) {
|
||||
qWarning("WARNING: JxlDecoderSetDecompressBoxes failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "WARNING: JxlDecoderSetDecompressBoxes failed");
|
||||
}
|
||||
|
||||
if (JxlDecoderSubscribeEvents(m_decoder, JXL_DEC_BOX | JXL_DEC_BOX_COMPLETE) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSubscribeEvents failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSubscribeEvents failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -1947,7 +1955,7 @@ bool QJpegXLHandler::decodeContainer()
|
||||
case JXL_DEC_BOX:
|
||||
status = JxlDecoderGetBoxType(m_decoder, box_type, JXL_TRUE);
|
||||
if (status != JXL_DEC_SUCCESS) {
|
||||
qWarning("Error in JxlDecoderGetBoxType");
|
||||
qCWarning(LOG_JXLPLUGIN, "Error in JxlDecoderGetBoxType");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -1965,17 +1973,17 @@ bool QJpegXLHandler::decodeContainer()
|
||||
}
|
||||
break;
|
||||
case JXL_DEC_ERROR:
|
||||
qWarning("JXL Metadata decoding error");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL Metadata decoding error");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
break;
|
||||
case JXL_DEC_NEED_MORE_INPUT:
|
||||
qWarning("JXL metadata are probably incomplete");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL metadata are probably incomplete");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_BOX", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_BOX", status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
break;
|
||||
@@ -2003,7 +2011,7 @@ bool QJpegXLHandler::decodeContainer()
|
||||
} else if (headerindexBE != -1) {
|
||||
m_exif = exifBox.mid(headerindexBE);
|
||||
} else {
|
||||
qWarning("Exif box in JXL file doesn't have TIFF header");
|
||||
qCWarning(LOG_JXLPLUGIN, "Exif box in JXL file doesn't have TIFF header");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2016,13 +2024,13 @@ bool QJpegXLHandler::extractBox(QByteArray &output, size_t container_size)
|
||||
uint64_t rawboxsize = 0;
|
||||
JxlDecoderStatus status = JxlDecoderGetBoxSizeRaw(m_decoder, &rawboxsize);
|
||||
if (status != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderGetBoxSizeRaw failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderGetBoxSizeRaw failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rawboxsize > container_size) {
|
||||
qWarning("JXL metadata box is incomplete");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL metadata box is incomplete");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -2030,7 +2038,7 @@ bool QJpegXLHandler::extractBox(QByteArray &output, size_t container_size)
|
||||
output.resize(rawboxsize);
|
||||
status = JxlDecoderSetBoxBuffer(m_decoder, reinterpret_cast<uint8_t *>(output.data()), output.size());
|
||||
if (status != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSetBoxBuffer failed");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetBoxBuffer failed");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -2041,7 +2049,7 @@ bool QJpegXLHandler::extractBox(QByteArray &output, size_t container_size)
|
||||
size_t bytes_remains = JxlDecoderReleaseBoxBuffer(m_decoder);
|
||||
|
||||
if (output.size() > 4194304) { // approx. 4MB limit for decompressed metadata box
|
||||
qWarning("JXL metadata box is too large");
|
||||
qCWarning(LOG_JXLPLUGIN, "JXL metadata box is too large");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -2051,7 +2059,7 @@ bool QJpegXLHandler::extractBox(QByteArray &output, size_t container_size)
|
||||
uint8_t *extension_buffer = reinterpret_cast<uint8_t *>(output.data()) + (output.size() - extension_size);
|
||||
|
||||
if (JxlDecoderSetBoxBuffer(m_decoder, extension_buffer, extension_size) != JXL_DEC_SUCCESS) {
|
||||
qWarning("ERROR: JxlDecoderSetBoxBuffer failed after JXL_DEC_BOX_NEED_MORE_OUTPUT");
|
||||
qCWarning(LOG_JXLPLUGIN, "ERROR: JxlDecoderSetBoxBuffer failed after JXL_DEC_BOX_NEED_MORE_OUTPUT");
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
@@ -2059,7 +2067,7 @@ bool QJpegXLHandler::extractBox(QByteArray &output, size_t container_size)
|
||||
} while (status == JXL_DEC_BOX_NEED_MORE_OUTPUT);
|
||||
|
||||
if (status != JXL_DEC_BOX_COMPLETE) {
|
||||
qWarning("Unexpected event %d instead of JXL_DEC_BOX_COMPLETE", status);
|
||||
qCWarning(LOG_JXLPLUGIN, "Unexpected event %d instead of JXL_DEC_BOX_COMPLETE", status);
|
||||
m_parseState = ParseJpegXLError;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,14 @@
|
||||
#include <QColor>
|
||||
#include <QColorSpace>
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_PCXPLUGIN, "kf.imageformats.plugins.pcx", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_PCXPLUGIN, "kf.imageformats.plugins.pcx", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
#pragma pack(push, 1)
|
||||
class RGB
|
||||
@@ -325,7 +331,7 @@ static bool readImage1(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
img.setColorCount(2);
|
||||
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
qCWarning(LOG_PCXPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -360,12 +366,12 @@ static bool readImage4(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
img = imageAlloc(header.width(), header.height(), header.format());
|
||||
img.setColorCount(16);
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
qCWarning(LOG_PCXPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.BytesPerLine < (header.width() + 7) / 8) {
|
||||
qWarning() << "PCX image has invalid BytesPerLine value";
|
||||
qCWarning(LOG_PCXPLUGIN) << "PCX image has invalid BytesPerLine value";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -390,7 +396,7 @@ static bool readImage4(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
|
||||
uchar *p = img.scanLine(y);
|
||||
if (!p) {
|
||||
qWarning() << "Failed to get scanline for" << y << "might be out of bounds";
|
||||
qCWarning(LOG_PCXPLUGIN) << "Failed to get scanline for" << y << "might be out of bounds";
|
||||
}
|
||||
for (int x = 0; x < header.width(); ++x) {
|
||||
p[x] = pixbuf[x];
|
||||
@@ -413,7 +419,7 @@ static bool readImage2(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
img.setColorCount(4);
|
||||
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
qCWarning(LOG_PCXPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -456,7 +462,7 @@ static bool readImage4v2(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
img.setColorCount(16);
|
||||
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
qCWarning(LOG_PCXPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -497,7 +503,7 @@ static bool readImage8(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
img.setColorCount(256);
|
||||
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
qCWarning(LOG_PCXPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -535,7 +541,6 @@ static bool readImage8(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
}
|
||||
}
|
||||
|
||||
// qDebug() << "Palette Flag: " << flag;
|
||||
if (flag == 12 && (header.Version == 5 || header.Version == 2)) {
|
||||
// Read the palette
|
||||
quint8 r;
|
||||
@@ -560,7 +565,7 @@ static bool readImage24(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
img = imageAlloc(header.width(), header.height(), header.format());
|
||||
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
qCWarning(LOG_PCXPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(header.width(), header.height());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -983,7 +988,7 @@ QVariant PCXHandler::option(ImageOption option) const
|
||||
bool PCXHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("PCXHandler::canRead() called with no device");
|
||||
qCWarning(LOG_PCXPLUGIN) << "PCXHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -33,14 +33,20 @@
|
||||
#include "scanlineconverter_p.h"
|
||||
#include "util_p.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QColorSpace>
|
||||
#include <QDataStream>
|
||||
#include <QImage>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_PSDPLUGIN, "kf.imageformats.plugins.psd", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_PSDPLUGIN, "kf.imageformats.plugins.psd", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
typedef quint32 uint;
|
||||
typedef quint16 ushort;
|
||||
typedef quint8 uchar;
|
||||
@@ -343,7 +349,7 @@ static PSDImageResourceSection readImageResourceSection(QDataStream &s, bool *ok
|
||||
size -= sizeof(signature);
|
||||
// NOTE: MeSa signature is not documented but found in some old PSD take from Photoshop 7.0 CD.
|
||||
if (signature != S_8BIM && signature != S_MeSa) { // 8BIM and MeSa
|
||||
qDebug() << "Invalid Image Resource Block Signature!";
|
||||
qCDebug(LOG_PSDPLUGIN) << "Invalid Image Resource Block Signature!";
|
||||
*ok = false;
|
||||
break;
|
||||
}
|
||||
@@ -373,7 +379,7 @@ static PSDImageResourceSection readImageResourceSection(QDataStream &s, bool *ok
|
||||
if (read > 0)
|
||||
size -= read;
|
||||
if (quint32(read) != dataSize) {
|
||||
qDebug() << "Image Resource Block Read Error!";
|
||||
qCDebug(LOG_PSDPLUGIN) << "Image Resource Block Read Error!";
|
||||
*ok = false;
|
||||
break;
|
||||
}
|
||||
@@ -661,18 +667,18 @@ static QDataStream &operator>>(QDataStream &s, PSDHeader &header)
|
||||
static bool IsValid(const PSDHeader &header)
|
||||
{
|
||||
if (header.signature != 0x38425053) { // '8BPS'
|
||||
// qDebug() << "PSD header: invalid signature" << header.signature;
|
||||
// qCDebug(LOG_PSDPLUGIN) << "PSD header: invalid signature" << header.signature;
|
||||
return false;
|
||||
}
|
||||
if (header.version != 1 && header.version != 2) {
|
||||
qDebug() << "PSD header: invalid version" << header.version;
|
||||
qCDebug(LOG_PSDPLUGIN) << "PSD header: invalid version" << header.version;
|
||||
return false;
|
||||
}
|
||||
if (header.depth != 8 &&
|
||||
header.depth != 16 &&
|
||||
header.depth != 32 &&
|
||||
header.depth != 1) {
|
||||
qDebug() << "PSD header: invalid depth" << header.depth;
|
||||
qCDebug(LOG_PSDPLUGIN) << "PSD header: invalid depth" << header.depth;
|
||||
return false;
|
||||
}
|
||||
if (header.color_mode != CM_RGB &&
|
||||
@@ -683,17 +689,17 @@ static bool IsValid(const PSDHeader &header)
|
||||
header.color_mode != CM_LABCOLOR &&
|
||||
header.color_mode != CM_MULTICHANNEL &&
|
||||
header.color_mode != CM_BITMAP) {
|
||||
qDebug() << "PSD header: invalid color mode" << header.color_mode;
|
||||
qCDebug(LOG_PSDPLUGIN) << "PSD header: invalid color mode" << header.color_mode;
|
||||
return false;
|
||||
}
|
||||
// Specs tells: "Supported range is 1 to 56" but when the alpha channel is present the limit is 57:
|
||||
// Photoshop does not make you add more (see also 53alphas.psd test case).
|
||||
if (header.channel_count < 1 || header.channel_count > 57) {
|
||||
qDebug() << "PSD header: invalid number of channels" << header.channel_count;
|
||||
qCDebug(LOG_PSDPLUGIN) << "PSD header: invalid number of channels" << header.channel_count;
|
||||
return false;
|
||||
}
|
||||
if (header.width > std::min(300000, PSD_MAX_IMAGE_WIDTH) || header.height > std::min(300000, PSD_MAX_IMAGE_HEIGHT)) {
|
||||
qDebug() << "PSD header: invalid image size" << header.width << "x" << header.height;
|
||||
qCDebug(LOG_PSDPLUGIN) << "PSD header: invalid image size" << header.width << "x" << header.height;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -977,7 +983,7 @@ inline void cmykToRgb(uchar *target, qint32 targetChannels, const char *source,
|
||||
auto invmax = 1.0 / max; // speed improvements by ~10%
|
||||
|
||||
if (sourceChannels < 2) {
|
||||
qDebug() << "cmykToRgb: image is not a valid MCH/CMYK!";
|
||||
qCDebug(LOG_PSDPLUGIN) << "cmykToRgb: image is not a valid MCH/CMYK!";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1026,7 +1032,7 @@ inline void labToRgb(uchar *target, qint32 targetChannels, const char *source, q
|
||||
auto invmax = 1.0 / max;
|
||||
|
||||
if (sourceChannels < 3) {
|
||||
qDebug() << "labToRgb: image is not a valid LAB!";
|
||||
qCDebug(LOG_PSDPLUGIN) << "labToRgb: image is not a valid LAB!";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1167,39 +1173,39 @@ public:
|
||||
|
||||
// Check image file format.
|
||||
if (stream.atEnd() || !IsValid(m_header)) {
|
||||
// qDebug() << "This PSD file is not valid.";
|
||||
// qCDebug(LOG_PSDPLUGIN) << "This PSD file is not valid.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if it's a supported format.
|
||||
if (!IsSupported(m_header)) {
|
||||
// qDebug() << "This PSD file is not supported.";
|
||||
// qCDebug(LOG_PSDPLUGIN) << "This PSD file is not supported.";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Color Mode Data section
|
||||
m_cmds = readColorModeDataSection(stream, &ok);
|
||||
if (!ok) {
|
||||
qDebug() << "Error while skipping Color Mode Data section";
|
||||
qCDebug(LOG_PSDPLUGIN) << "Error while skipping Color Mode Data section";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Image Resources Section
|
||||
m_irs = readImageResourceSection(stream, &ok);
|
||||
if (!ok) {
|
||||
qDebug() << "Error while reading Image Resources Section";
|
||||
qCDebug(LOG_PSDPLUGIN) << "Error while reading Image Resources Section";
|
||||
return false;
|
||||
}
|
||||
// Checking for merged image (Photoshop compatibility data)
|
||||
if (!hasMergedData()) {
|
||||
qDebug() << "No merged data found";
|
||||
qCDebug(LOG_PSDPLUGIN) << "No merged data found";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Layer and Mask section
|
||||
m_lms = readLayerAndMaskSection(stream, isPsb(), &ok);
|
||||
if (!ok) {
|
||||
qDebug() << "Error while skipping Layer and Mask section";
|
||||
qCDebug(LOG_PSDPLUGIN) << "Error while skipping Layer and Mask section";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1260,19 +1266,19 @@ bool PSDHandler::read(QImage *image)
|
||||
quint16 compression;
|
||||
stream >> compression;
|
||||
if (compression > 1) {
|
||||
qDebug() << "Unknown compression type";
|
||||
qCDebug(LOG_PSDPLUGIN) << "Unknown compression type";
|
||||
return false;
|
||||
}
|
||||
|
||||
const QImage::Format format = d->format();
|
||||
if (format == QImage::Format_Invalid) {
|
||||
qWarning() << "Unsupported image format. color_mode:" << header.color_mode << "depth:" << header.depth << "channel_count:" << header.channel_count;
|
||||
qCWarning(LOG_PSDPLUGIN) << "Unsupported image format. color_mode:" << header.color_mode << "depth:" << header.depth << "channel_count:" << header.channel_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
img = imageAlloc(d->size(), format);
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(header.width, header.height);
|
||||
qCWarning(LOG_PSDPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(header.width, header.height);
|
||||
return false;
|
||||
}
|
||||
img.fill(qRgb(0, 0, 0));
|
||||
@@ -1287,7 +1293,7 @@ bool PSDHandler::read(QImage *image)
|
||||
auto native_cmyk = img.format() == CMYK_FORMAT;
|
||||
|
||||
if (header.height > kMaxQVectorSize / header.channel_count / sizeof(quint32)) {
|
||||
qWarning() << "LoadPSD() header height/channel_count too big" << header.height << header.channel_count;
|
||||
qCWarning(LOG_PSDPLUGIN) << "LoadPSD() header height/channel_count too big" << header.height << header.channel_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1346,12 +1352,12 @@ bool PSDHandler::read(QImage *image)
|
||||
for (qint32 c = 0; c < header.channel_count; ++c) {
|
||||
auto strideNumber = c * qsizetype(h) + y;
|
||||
if (!device->seek(stridePositions.at(strideNumber))) {
|
||||
qDebug() << "Error while seeking the stream of channel" << c << "line" << y;
|
||||
qCDebug(LOG_PSDPLUGIN) << "Error while seeking the stream of channel" << c << "line" << y;
|
||||
return false;
|
||||
}
|
||||
auto &&strideSize = strides.at(strideNumber);
|
||||
if (!readChannel(rawStride, stream, strideSize, compression)) {
|
||||
qDebug() << "Error while reading the stream of channel" << c << "line" << y;
|
||||
qCDebug(LOG_PSDPLUGIN) << "Error while reading the stream of channel" << c << "line" << y;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1432,7 +1438,7 @@ bool PSDHandler::read(QImage *image)
|
||||
for (qint32 y = 0, h = header.height; y < h; ++y) {
|
||||
auto&& strideSize = strides.at(c * qsizetype(h) + y);
|
||||
if (!readChannel(rawStride, stream, strideSize, compression)) {
|
||||
qDebug() << "Error while reading the stream of channel" << c << "line" << y;
|
||||
qCDebug(LOG_PSDPLUGIN) << "Error while reading the stream of channel" << c << "line" << y;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1465,7 +1471,7 @@ bool PSDHandler::read(QImage *image)
|
||||
|
||||
// Resolution info
|
||||
if (!setResolution(img, irs)) {
|
||||
// qDebug() << "No resolution info found!";
|
||||
// qCDebug(LOG_PSDPLUGIN) << "No resolution info found!";
|
||||
}
|
||||
|
||||
// ICC profile
|
||||
@@ -1493,12 +1499,12 @@ bool PSDHandler::read(QImage *image)
|
||||
|
||||
// XMP data
|
||||
if (!setXmpData(img, irs)) {
|
||||
// qDebug() << "No XMP data found!";
|
||||
// qCDebug(LOG_PSDPLUGIN) << "No XMP data found!";
|
||||
}
|
||||
|
||||
// EXIF data
|
||||
if (!setExifData(img, d->m_exif)) {
|
||||
// qDebug() << "No EXIF data found!";
|
||||
// qCDebug(LOG_PSDPLUGIN) << "No EXIF data found!";
|
||||
}
|
||||
|
||||
// Duotone images: color data contains the duotone specification (not documented).
|
||||
@@ -1569,7 +1575,7 @@ QVariant PSDHandler::option(ImageOption option) const
|
||||
bool PSDHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("PSDHandler::canRead() called with no device");
|
||||
qCWarning(LOG_PSDPLUGIN) << "PSDHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,13 @@
|
||||
#include <QFile>
|
||||
#include <QIODevice>
|
||||
#include <QImage>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_QOIPLUGIN, "kf.imageformats.plugins.qoi", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_QOIPLUGIN, "kf.imageformats.plugins.qoi", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
/* *** QOI_MAX_IMAGE_WIDTH and QOI_MAX_IMAGE_HEIGHT ***
|
||||
* The maximum size in pixel allowed by the plugin.
|
||||
@@ -347,7 +354,7 @@ bool QOIHandler::canRead() const
|
||||
bool QOIHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("QOIHandler::canRead() called with no device");
|
||||
qCWarning(LOG_QOIPLUGIN) << "QOIHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,14 @@
|
||||
#include "util_p.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_RASPLUGIN, "kf.imageformats.plugins.ras", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_RASPLUGIN, "kf.imageformats.plugins.ras", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
/* *** RAS_MAX_IMAGE_WIDTH and RAS_MAX_IMAGE_HEIGHT ***
|
||||
* The maximum size in pixel allowed by the plugin.
|
||||
@@ -73,14 +79,14 @@ static QDataStream &operator>>(QDataStream &s, RasHeader &head)
|
||||
s >> head.Type;
|
||||
s >> head.ColorMapType;
|
||||
s >> head.ColorMapLength;
|
||||
/*qDebug() << "MagicNumber: " << head.MagicNumber
|
||||
<< "Width: " << head.Width
|
||||
<< "Height: " << head.Height
|
||||
<< "Depth: " << head.Depth
|
||||
<< "Length: " << head.Length
|
||||
<< "Type: " << head.Type
|
||||
<< "ColorMapType: " << head.ColorMapType
|
||||
<< "ColorMapLength: " << head.ColorMapLength;*/
|
||||
// qCDebug(LOG_RASPLUGIN) << "MagicNumber: " << head.MagicNumber
|
||||
// << "Width: " << head.Width
|
||||
// << "Height: " << head.Height
|
||||
// << "Depth: " << head.Depth
|
||||
// << "Length: " << head.Length
|
||||
// << "Type: " << head.Type
|
||||
// << "ColorMapType: " << head.ColorMapType
|
||||
// << "ColorMapLength: " << head.ColorMapLength;
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -218,7 +224,7 @@ static bool LoadRAS(QDataStream &s, const RasHeader &ras, QImage &img)
|
||||
if (rasLineSize & 1)
|
||||
++rasLineSize;
|
||||
if (rasLineSize > kMaxQVectorSize) {
|
||||
qWarning() << "LoadRAS() unsupported line size" << rasLineSize;
|
||||
qCWarning(LOG_RASPLUGIN) << "LoadRAS() unsupported line size" << rasLineSize;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -256,7 +262,7 @@ static bool LoadRAS(QDataStream &s, const RasHeader &ras, QImage &img)
|
||||
for (quint32 y = 0; y < ras.Height; ++y) {
|
||||
auto rasLine = dec.readLine(rasLineSize);
|
||||
if (rasLine.size() != rasLineSize) {
|
||||
qWarning() << "LoadRAS() unable to read line" << y << ": the seems corrupted!";
|
||||
qCWarning(LOG_RASPLUGIN) << "LoadRAS() unable to read line" << y << ": the seems corrupted!";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -336,8 +342,8 @@ static bool LoadRAS(QDataStream &s, const RasHeader &ras, QImage &img)
|
||||
continue;
|
||||
}
|
||||
|
||||
qWarning() << "LoadRAS() unsupported format!"
|
||||
<< "ColorMapType:" << ras.ColorMapType << "Type:" << ras.Type << "Depth:" << ras.Depth;
|
||||
qCWarning(LOG_RASPLUGIN) << "LoadRAS() unsupported format!"
|
||||
<< "ColorMapType:" << ras.ColorMapType << "Type:" << ras.Type << "Depth:" << ras.Depth;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -373,7 +379,7 @@ bool RASHandler::canRead() const
|
||||
bool RASHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("RASHandler::canRead() called with no device");
|
||||
qCWarning(LOG_RASPLUGIN) << "RASHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -399,19 +405,19 @@ bool RASHandler::read(QImage *outImage)
|
||||
s >> ras;
|
||||
|
||||
if (ras.ColorMapLength > kMaxQVectorSize) {
|
||||
qWarning() << "read() unsupported image color map length in file header" << ras.ColorMapLength;
|
||||
qCWarning(LOG_RASPLUGIN) << "LoadRAS() unsupported image color map length in file header" << ras.ColorMapLength;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check supported file types.
|
||||
if (!IsSupported(ras)) {
|
||||
// qDebug() << "This RAS file is not supported.";
|
||||
// qCDebug(LOG_RASPLUGIN) << "This RAS file is not supported.";
|
||||
return false;
|
||||
}
|
||||
|
||||
QImage img;
|
||||
if (!LoadRAS(s, ras, img)) {
|
||||
// qDebug() << "Error loading RAS file.";
|
||||
// qCDebug(LOG_RASPLUGIN) << "Error loading RAS file.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <QColorSpace>
|
||||
#include <QDateTime>
|
||||
#include <QImage>
|
||||
#include <QLoggingCategory>
|
||||
#include <QSet>
|
||||
#include <QTimeZone>
|
||||
|
||||
@@ -41,6 +42,12 @@
|
||||
// #define EXCLUDE_LibRaw_QIODevice // Uncomment this code if you think that the problem is LibRaw_QIODevice (default commented)
|
||||
#endif
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_RAWPLUGIN, "kf.imageformats.plugins.raw", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_RAWPLUGIN, "kf.imageformats.plugins.raw", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
namespace // Private.
|
||||
{
|
||||
|
||||
@@ -1010,7 +1017,7 @@ int RAWHandler::currentImageNumber() const
|
||||
bool RAWHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("RAWHandler::canRead() called with no device");
|
||||
qCWarning(LOG_RAWPLUGIN) << "RAWHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
if (device->isSequential()) {
|
||||
|
||||
@@ -26,11 +26,17 @@
|
||||
#include <cstring>
|
||||
|
||||
#include <QColorSpace>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QList>
|
||||
#include <QLoggingCategory>
|
||||
#include <QMap>
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_LOGGING_CATEGORY(LOG_RGBPLUGIN, "kf.imageformats.plugins.rgb", QtDebugMsg)
|
||||
#else
|
||||
Q_LOGGING_CATEGORY(LOG_RGBPLUGIN, "kf.imageformats.plugins.rgb", QtWarningMsg)
|
||||
#endif
|
||||
|
||||
class RLEData : public QList<uchar>
|
||||
{
|
||||
public:
|
||||
@@ -296,12 +302,12 @@ bool SGIImagePrivate::readImage(QImage &img)
|
||||
|
||||
img = imageAlloc(size(), format());
|
||||
if (img.isNull()) {
|
||||
qWarning() << "Failed to allocate image, invalid dimensions?" << QSize(_xsize, _ysize);
|
||||
qCWarning(LOG_RGBPLUGIN) << "Failed to allocate image, invalid dimensions?" << QSize(_xsize, _ysize);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_zsize > 4) {
|
||||
// qDebug() << "using first 4 of " << _zsize << " channels";
|
||||
// qCDebug(LOG_RGBPLUGIN) << "using first 4 of " << _zsize << " channels";
|
||||
// Only let this continue if it won't cause a int overflow later
|
||||
// this is most likely a broken file anyway
|
||||
if (_ysize > std::numeric_limits<int>::max() / _zsize) {
|
||||
@@ -345,14 +351,14 @@ bool SGIImagePrivate::readImage(QImage &img)
|
||||
for (uint o = 0; o < _numrows; o++) {
|
||||
// don't change to greater-or-equal!
|
||||
if (_starttab[o] + _lengthtab[o] > (uint)_data.size()) {
|
||||
// qDebug() << "image corrupt (sanity check failed)";
|
||||
// qCDebug(LOG_RGBPLUGIN) << "image corrupt (sanity check failed)";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!readData(img)) {
|
||||
// qDebug() << "image corrupt (incomplete scanline)";
|
||||
// qCDebug(LOG_RGBPLUGIN) << "image corrupt (incomplete scanline)";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -475,7 +481,7 @@ bool SGIImagePrivate::scanData(const QImage &img, const QImage::Format &tfmt, co
|
||||
for (y = 0; y < _ysize; y++) {
|
||||
const int yPos = _ysize - y - 1; // scanline doesn't do any sanity checking
|
||||
if (yPos >= img.height()) {
|
||||
qWarning() << "Failed to get scanline for" << yPos;
|
||||
qCWarning(LOG_RGBPLUGIN) << "Failed to get scanline for" << yPos;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -496,7 +502,7 @@ bool SGIImagePrivate::scanData(const QImage &img, const QImage::Format &tfmt, co
|
||||
for (y = 0; y < _ysize; y++) {
|
||||
const int yPos = _ysize - y - 1;
|
||||
if (yPos >= img.height()) {
|
||||
qWarning() << "Failed to get scanline for" << yPos;
|
||||
qCWarning(LOG_RGBPLUGIN) << "Failed to get scanline for" << yPos;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -511,7 +517,7 @@ bool SGIImagePrivate::scanData(const QImage &img, const QImage::Format &tfmt, co
|
||||
for (y = 0; y < _ysize; y++) {
|
||||
const int yPos = _ysize - y - 1;
|
||||
if (yPos >= img.height()) {
|
||||
qWarning() << "Failed to get scanline for" << yPos;
|
||||
qCWarning(LOG_RGBPLUGIN) << "Failed to get scanline for" << yPos;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -531,7 +537,7 @@ bool SGIImagePrivate::scanData(const QImage &img, const QImage::Format &tfmt, co
|
||||
for (y = 0; y < _ysize; y++) {
|
||||
const int yPos = _ysize - y - 1;
|
||||
if (yPos >= img.height()) {
|
||||
qWarning() << "Failed to get scanline for" << yPos;
|
||||
qCWarning(LOG_RGBPLUGIN) << "Failed to get scanline for" << yPos;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -661,7 +667,7 @@ bool SGIImagePrivate::writeHeader()
|
||||
bool SGIImagePrivate::writeRle()
|
||||
{
|
||||
_rle = 1;
|
||||
// qDebug() << "writing RLE data";
|
||||
// qCDebug(LOG_RGBPLUGIN) << "writing RLE data";
|
||||
if (!writeHeader()) {
|
||||
return false;
|
||||
}
|
||||
@@ -747,7 +753,6 @@ bool SGIImagePrivate::writeVerbatim(const QImage &img, const QImage::Format &tfm
|
||||
|
||||
bool SGIImagePrivate::writeImage(const QImage &image)
|
||||
{
|
||||
// qDebug() << "writing "; // TODO add filename
|
||||
if (image.allGray()) {
|
||||
_dim = 2, _zsize = 1;
|
||||
} else {
|
||||
@@ -794,7 +799,7 @@ bool SGIImagePrivate::writeImage(const QImage &image)
|
||||
_rlemap.setBaseOffset(512 + _numrows * 2 * sizeof(quint32));
|
||||
|
||||
if (!scanData(image, tfmt, tcs)) {
|
||||
// qDebug() << "this can't happen";
|
||||
// qCDebug(LOG_RGBPLUGIN) << "this can't happen";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -884,7 +889,7 @@ QVariant RGBHandler::option(ImageOption option) const
|
||||
bool RGBHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("RGBHandler::canRead() called with no device");
|
||||
qCWarning(LOG_RGBPLUGIN) << "RGBHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ bool ScitexHandler::canRead() const
|
||||
bool ScitexHandler::canRead(QIODevice *device)
|
||||
{
|
||||
if (!device) {
|
||||
qWarning("ScitexHandler::canRead() called with no device");
|
||||
qCWarning(LOG_SCTPLUGIN) << "ScitexHandler::canRead() called with no device";
|
||||
return false;
|
||||
}
|
||||
ScitexHandlerPrivate hp;
|
||||
@@ -344,7 +344,7 @@ bool ScitexHandler::read(QImage *image)
|
||||
{
|
||||
auto dev = device();
|
||||
if (dev == nullptr) {
|
||||
qWarning("ScitexHandler::read() called with no device");
|
||||
qCWarning(LOG_SCTPLUGIN) << "ScitexHandler::read() called with no device";
|
||||
return false;
|
||||
}
|
||||
if (!d->loadHeader(dev)) {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "xcf_p.h"
|
||||
|
||||
#include <QColorSpace>
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
#include <QImage>
|
||||
#include <QImageReader>
|
||||
|
||||
Reference in New Issue
Block a user