diff --git a/src/imageformats/rgb.cpp b/src/imageformats/rgb.cpp index 621363f..7f758dd 100644 --- a/src/imageformats/rgb.cpp +++ b/src/imageformats/rgb.cpp @@ -672,11 +672,13 @@ bool SGIImage::writeImage(const QImage &image) _dim = 3, _zsize = 3; } - if (img.format() == QImage::Format_ARGB32) { + if (img.hasAlphaChannel()) { _dim = 3, _zsize++; } - img = img.convertToFormat(QImage::Format_RGB32); + if (img.format() != QImage::Format_ARGB32) { + img = img.convertToFormat(QImage::Format_ARGB32); + } if (img.isNull()) { // qDebug() << "can't convert image to depth 32"; return false; @@ -685,7 +687,7 @@ bool SGIImage::writeImage(const QImage &image) const int w = img.width(); const int h = img.height(); - if (w > 65536 || h > 65536) { + if (w > 65535 || h > 65535) { return false; } @@ -712,12 +714,6 @@ bool SGIImage::writeImage(const QImage &image) rle_size += _rlevector[i]->size(); } - // qDebug() << "minimum intensity: " << _pixmin; - // qDebug() << "maximum intensity: " << _pixmax; - // qDebug() << "saved scanlines: " << _numrows - _rlemap.size(); - // qDebug() << "total savings: " << (verbatim_size - rle_size) << " bytes"; - // qDebug() << "compression: " << (rle_size * 100.0 / verbatim_size) << '%'; - if (verbatim_size <= rle_size) { writeVerbatim(img); } else { diff --git a/src/imageformats/tga.cpp b/src/imageformats/tga.cpp index 63eb882..77dbf00 100644 --- a/src/imageformats/tga.cpp +++ b/src/imageformats/tga.cpp @@ -430,10 +430,11 @@ bool TGAHandler::write(const QImage &image) QImage img(image); const bool hasAlpha = img.hasAlphaChannel(); - if (hasAlpha && img.format() != QImage::Format_ARGB32) + if (hasAlpha && img.format() != QImage::Format_ARGB32) { img = img.convertToFormat(QImage::Format_ARGB32); - else if (!hasAlpha && img.format() != QImage::Format_RGB32) + } else if (!hasAlpha && img.format() != QImage::Format_RGB32) { img = img.convertToFormat(QImage::Format_RGB32); + } if (img.isNull()) { qDebug() << "TGAHandler::write: image conversion to 32 bits failed!"; return false;