Merge pull request #3317 from AndrewMeadows/inertia

fix for crash when computing average image color
This commit is contained in:
Andrzej Kapolka 2014-08-25 15:43:32 -07:00
commit 12d641ddba

View file

@ -416,8 +416,12 @@ void ImageReader::run() {
blueTotal += qBlue(rgb);
}
}
QColor averageColor(EIGHT_BIT_MAXIMUM, EIGHT_BIT_MAXIMUM, EIGHT_BIT_MAXIMUM);
if (imageArea > 0) {
averageColor.setRgb(redTotal / imageArea, greenTotal / imageArea, blueTotal / imageArea);
}
QMetaObject::invokeMethod(texture.data(), "setImage", Q_ARG(const QImage&, image), Q_ARG(bool, false),
Q_ARG(const QColor&, QColor(redTotal / imageArea, greenTotal / imageArea, blueTotal / imageArea)));
Q_ARG(const QColor&, averageColor));
return;
}
if (image.format() != QImage::Format_ARGB32) {