summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qimage.cpp8
-rw-r--r--src/gui/image/qimage_conversions.cpp14
-rw-r--r--src/gui/image/qimagewriter.cpp6
3 files changed, 20 insertions, 8 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 162a1a20b8..3238d83729 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2454,10 +2454,16 @@ QColor QImage::pixelColor(int x, int y) const
*/
void QImage::setPixelColor(int x, int y, const QColor &color)
{
- if (!d || x < 0 || x >= width() || y < 0 || y >= height() || !color.isValid()) {
+ if (!d || x < 0 || x >= width() || y < 0 || y >= height()) {
qWarning("QImage::setPixelColor: coordinate (%d,%d) out of range", x, y);
return;
}
+
+ if (!color.isValid()) {
+ qWarning("QImage::setPixelColor: color is invalid");
+ return;
+ }
+
// QColor is always unpremultiplied
QRgba64 c = color.rgba64();
if (!hasAlphaChannel())
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp
index 41b4807671..16789c802e 100644
--- a/src/gui/image/qimage_conversions.cpp
+++ b/src/gui/image/qimage_conversions.cpp
@@ -1747,24 +1747,30 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt:
Q_ASSERT(src->width == dest->width);
Q_ASSERT(src->height == dest->height);
- QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format);
+ QVector<QRgb> colorTable = src->has_alpha_clut ? fix_color_table(src->colortable, dest->format) : src->colortable;
if (colorTable.size() == 0) {
colorTable.resize(256);
for (int i=0; i<256; ++i)
colorTable[i] = qRgb(i, i, i);
}
+ if (colorTable.size() < 256) {
+ int tableSize = colorTable.size();
+ colorTable.resize(256);
+ for (int i=tableSize; i<256; ++i)
+ colorTable[i] = 0;
+ }
int w = src->width;
const uchar *src_data = src->data;
uchar *dest_data = dest->data;
- int tableSize = colorTable.size() - 1;
+ const QRgb *colorTablePtr = colorTable.constData();
for (int y = 0; y < src->height; y++) {
- uint *p = (uint *)dest_data;
+ uint *p = reinterpret_cast<uint *>(dest_data);
const uchar *b = src_data;
uint *end = p + w;
while (p < end)
- *p++ = colorTable.at(qMin<int>(tableSize, *b++));
+ *p++ = colorTablePtr[*b++];
src_data += src->bytes_per_line;
dest_data += dest->bytes_per_line;
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index 1a0bb4d6ff..f3af2738af 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -837,9 +837,9 @@ void supportedImageHandlerMimeTypes(QFactoryLoader *loader,
const int pluginCount = metaDataList.size();
for (int i = 0; i < pluginCount; ++i) {
- const QJsonObject metaData = metaDataList.at(i).value(QStringLiteral("MetaData")).toObject();
- const QJsonArray keys = metaData.value(QStringLiteral("Keys")).toArray();
- const QJsonArray mimeTypes = metaData.value(QStringLiteral("MimeTypes")).toArray();
+ const QJsonObject metaData = metaDataList.at(i).value(QLatin1String("MetaData")).toObject();
+ const QJsonArray keys = metaData.value(QLatin1String("Keys")).toArray();
+ const QJsonArray mimeTypes = metaData.value(QLatin1String("MimeTypes")).toArray();
QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(loader->instance(i));
const int keyCount = keys.size();
for (int k = 0; k < keyCount; ++k) {