summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2010-07-21 17:54:56 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-07-22 12:03:20 (GMT)
commitbf15a487e4e0b5d4edca232258526e0d3cf471a0 (patch)
tree5cb0c7c6d31defa6ec661e9eadefd60ee7652128
parent6240f4a990d2f0b4a4b24c823f8875ca3b8226a4 (diff)
downloadQt-bf15a487e4e0b5d4edca232258526e0d3cf471a0.zip
Qt-bf15a487e4e0b5d4edca232258526e0d3cf471a0.tar.gz
Qt-bf15a487e4e0b5d4edca232258526e0d3cf471a0.tar.bz2
Premultiply the color table instead of each pixel for image conversion
When converting indexed images in place, each color was converted to premultiplied. Instead, we can just convert the color table like it is done in the non-in-place version. Reviewed-by: Kim
-rw-r--r--src/gui/image/qimage.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index e5930ac..e8c01c7 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2343,6 +2343,9 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve
data->colortable.resize(256);
for (int i = 0; i < 256; ++i)
data->colortable[i] = qRgb(i, i, i);
+ } else {
+ for (int i = 0; i < data->colortable.size(); ++i)
+ data->colortable[i] = PREMUL(data->colortable.at(i));
}
const int tableSize = data->colortable.size() - 1;
@@ -2352,11 +2355,11 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve
for (int pixI = 0; pixI < width; ++pixI) {
--src_data;
--dest_data;
- const uint pixel = data->colortable[qMin<int>(tableSize, *src_data)];
- *dest_data = (quint32) PREMUL(pixel);
+ *dest_data = data->colortable[qMin<int>(tableSize, *src_data)];
}
}
+ data->colortable = QVector<QRgb>();
data->format = QImage::Format_ARGB32_Premultiplied;
data->bytes_per_line = dst_bytes_per_line;
data->depth = depth;
@@ -2401,6 +2404,7 @@ static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversio
}
}
+ data->colortable = QVector<QRgb>();
data->format = QImage::Format_RGB32;
data->bytes_per_line = dst_bytes_per_line;
data->depth = depth;
@@ -2446,6 +2450,7 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers
}
}
+ data->colortable = QVector<QRgb>();
data->format = QImage::Format_RGB16;
data->bytes_per_line = dst_bytes_per_line;
data->depth = depth;