Commit 8b6e5f08 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Another build fix

parent b1c60044
......@@ -1360,72 +1360,24 @@ QImage KisImage::convertToQImage(qint32 x,
QImage KisImage::convertToQImage(const QRect& scaledRect, const QSize& scaledImageSize, const KoColorProfile *profile)
QImage KisImage::convertToQImage(const QSize& scaledImageSize, const KoColorProfile *profile)
{
if (scaledRect.isEmpty() || scaledImageSize.isEmpty()) {
if (scaledImageSize.isEmpty()) {
return QImage();
}
try {
qint32 imageWidth = width();
qint32 imageHeight = height();
quint32 pixelSize = colorSpace()->pixelSize();
double xScale = static_cast<double>(imageWidth) / scaledImageSize.width();
double yScale = static_cast<double>(imageHeight) / scaledImageSize.height();
QRect srcRect;
srcRect.setLeft(static_cast<int>(scaledRect.left() * xScale));
srcRect.setRight(static_cast<int>(ceil((scaledRect.right() + 1) * xScale)) - 1);
srcRect.setTop(static_cast<int>(scaledRect.top() * yScale));
srcRect.setBottom(static_cast<int>(ceil((scaledRect.bottom() + 1) * yScale)) - 1);
KisPaintDeviceSP mergedImage = projection();
quint8 *scaledImageData = new quint8[scaledRect.width() * scaledRect.height() * pixelSize];
quint8 *imageRow = new quint8[srcRect.width() * pixelSize];
const qint32 imageRowX = srcRect.x();
for (qint32 y = 0; y < scaledRect.height(); ++y) {
qint32 dstY = scaledRect.y() + y;
qint32 dstX = scaledRect.x();
qint32 srcY = (dstY * imageHeight) / scaledImageSize.height();
mergedImage->readBytes(imageRow, imageRowX, srcY, srcRect.width(), 1);
quint8 *dstPixel = scaledImageData + (y * scaledRect.width() * pixelSize);
quint32 columnsRemaining = scaledRect.width();
KisPaintDeviceSP dev = new KisPaintDevice(*projection().data());
while (columnsRemaining > 0) {
double scaleX = qreal(scaledImageSize.width()) / width();
double scaleY = qreal(scaledImageSize.height()) / height();
qint32 srcX = (dstX * imageWidth) / scaledImageSize.width();
QPointer<KoUpdater> updater = new KoDummyUpdater();
memcpy(dstPixel, imageRow + ((srcX - imageRowX) * pixelSize), pixelSize);
KisTransformWorker worker(dev, scaleX, scaleY, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, updater, KisFilterStrategyRegistry::instance()->value("Bicubic"));
worker.run();
++dstX;
dstPixel += pixelSize;
--columnsRemaining;
}
}
delete [] imageRow;
QImage image = colorSpace()->convertToQImage(scaledImageData, scaledRect.width(), scaledRect.height(), const_cast<KoColorProfile*>(profile),
KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::internalConversionFlags());
delete [] scaledImageData;
return image;
}
catch (std::bad_alloc) {
warnKrita << "KisImage::convertToQImage ran out of memory";
return QImage();
}
return dev->convertToQImage(profile);
}
void KisImage::notifyLayersChanged()
{
m_d->signalRouter.emitNotification(LayersChangedSignal);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment