Merge "paintengine: improve error handling"

This commit is contained in:
Eirik Aavitsland 2021-03-19 11:09:28 +01:00 committed by Qt CI Bot
commit ac175ff483

View File

@ -3745,6 +3745,8 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
const QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB);
QImage dest = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied);
if (sourceImage.isNull() || dest.isNull())
return image; // we must have run out of memory
QRgb fg = qPremultiply(color.rgba());
QRgb bg = 0;
@ -3754,8 +3756,6 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
for (int y=0; y<height; ++y) {
const uchar *source = sourceImage.constScanLine(y);
QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y));
if (!source || !target)
QT_THROW(std::bad_alloc()); // we must have run out of memory
for (int x=0; x < width; ++x)
target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg;
}