From 2af9dc886a9bc0b6ecdb91d68a0abea121cc684a Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 8 Mar 2019 11:56:04 -0800 Subject: [PATCH] Add logging category to TGAReader --- libraries/image/src/image/TGAReader.cpp | 38 +++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/libraries/image/src/image/TGAReader.cpp b/libraries/image/src/image/TGAReader.cpp index a230185b49..a6dd7e9c71 100644 --- a/libraries/image/src/image/TGAReader.cpp +++ b/libraries/image/src/image/TGAReader.cpp @@ -11,6 +11,8 @@ #include "TGAReader.h" +#include "ImageLogging.h" + #include #include @@ -57,12 +59,12 @@ QImage image::readTGA(QIODevice& content) { TGAHeader header; if (content.isSequential()) { - qWarning() << "TGA - Sequential devices are not supported for reading"; + qWarning(imagelogging) << "TGA - Sequential devices are not supported for reading"; return QImage(); } if (content.bytesAvailable() < TGA_HEADER_SIZE_BYTES) { - qWarning() << "TGA - Unexpectedly reached end of file"; + qWarning(imagelogging) << "TGA - Unexpectedly reached end of file"; return QImage(); } @@ -78,28 +80,28 @@ QImage image::readTGA(QIODevice& content) { content.read((char*)&header.imageDescriptor, 1); if (WANT_DEBUG) { - qDebug() << "Id Length: " << (int)header.idLength; - qDebug() << "Color map: " << (int)header.colorMap.firstEntryIndex << header.colorMap.length << header.colorMap.entrySize; - qDebug() << "Color map type: " << (int)header.colorMapType; - qDebug() << "Image type: " << (int)header.imageType; - qDebug() << "Origin: " << header.xOrigin << header.yOrigin; - qDebug() << "Size: " << header.width << header.height; - qDebug() << "Depth: " << header.pixelDepth; - qDebug() << "Image desc: " << header.imageDescriptor.attributeBitsPerPixel << (int)header.imageDescriptor.orientation; + qDebug(imagelogging) << "Id Length: " << (int)header.idLength; + qDebug(imagelogging) << "Color map: " << (int)header.colorMap.firstEntryIndex << header.colorMap.length << header.colorMap.entrySize; + qDebug(imagelogging) << "Color map type: " << (int)header.colorMapType; + qDebug(imagelogging) << "Image type: " << (int)header.imageType; + qDebug(imagelogging) << "Origin: " << header.xOrigin << header.yOrigin; + qDebug(imagelogging) << "Size: " << header.width << header.height; + qDebug(imagelogging) << "Depth: " << header.pixelDepth; + qDebug(imagelogging) << "Image desc: " << header.imageDescriptor.attributeBitsPerPixel << (int)header.imageDescriptor.orientation; } if (header.xOrigin != 0 || header.yOrigin != 0) { - qWarning() << "TGA - origin not supporter"; + qWarning(imagelogging) << "TGA - origin not supporter"; return QImage(); } if (!(header.pixelDepth == 24 && header.imageDescriptor.attributeBitsPerPixel == 0) && header.pixelDepth != 32) { - qWarning() << "TGA - Only pixel depths of 24 (with no alpha) and 32 bits are supported"; + qWarning(imagelogging) << "TGA - Only pixel depths of 24 (with no alpha) and 32 bits are supported"; return QImage(); } if (header.imageDescriptor.attributeBitsPerPixel != 0 && header.imageDescriptor.attributeBitsPerPixel != 8) { - qWarning() << "TGA - Only 0 or 8 bits for the alpha channel is supported"; + qWarning(imagelogging) << "TGA - Only 0 or 8 bits for the alpha channel is supported"; return QImage(); } @@ -110,7 +112,7 @@ QImage image::readTGA(QIODevice& content) { if (header.imageType == TGAImageType::UncompressedTrueColor) { qint64 minimumSize = header.width * header.height * bytesPerPixel; if (content.bytesAvailable() < minimumSize) { - qWarning() << "TGA - Unexpectedly reached end of file"; + qWarning(imagelogging) << "TGA - Unexpectedly reached end of file"; return QImage(); } @@ -146,7 +148,7 @@ QImage image::readTGA(QIODevice& content) { constexpr char LENGTH_MASK{ (char)0x7f }; char repetition; if (content.read(&repetition, 1) != 1) { - qWarning() << "TGA - Unexpectedly reached end of file"; + qWarning(imagelogging) << "TGA - Unexpectedly reached end of file"; return QImage(); } bool isRepetition = repetition & IS_REPETITION_MASK; @@ -159,7 +161,7 @@ QImage image::readTGA(QIODevice& content) { // Read into temporary buffer char color[4]; if (content.read(color, bytesPerPixel) != bytesPerPixel) { - qWarning() << "TGA - Unexpectedly reached end of file"; + qWarning(imagelogging) << "TGA - Unexpectedly reached end of file"; return QImage(); } color[3] |= alphaMask; @@ -177,7 +179,7 @@ QImage image::readTGA(QIODevice& content) { } else { qint64 minimumSize = length * bytesPerPixel; if (content.bytesAvailable() < minimumSize) { - qWarning() << "TGA - Unexpectedly reached end of file"; + qWarning(imagelogging) << "TGA - Unexpectedly reached end of file"; return QImage(); } @@ -194,7 +196,7 @@ QImage image::readTGA(QIODevice& content) { } return image; } else { - qWarning() << "TGA - Unsupported image type: " << (int)header.imageType; + qWarning(imagelogging) << "TGA - Unsupported image type: " << (int)header.imageType; } return QImage();