Avoid unnecessary conversions

(cherry picked from commit edd6adcbac)
This commit is contained in:
Mirco Miranda 2023-05-10 15:34:14 +02:00 committed by Albert Astals Cid
parent f7fd14d418
commit 2ca57c9c59

View File

@ -672,12 +672,15 @@ bool SGIImage::writeImage(const QImage &image)
_dim = 3, _zsize = 3;
}
if (img.hasAlphaChannel()) {
auto hasAlpha = img.hasAlphaChannel();
if (hasAlpha) {
_dim = 3, _zsize++;
}
if (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) {
img = img.convertToFormat(QImage::Format_RGB32);
}
if (img.isNull()) {
// qDebug() << "can't convert image to depth 32";