Commit e5b05eff authored by Boudewijn Rempt's avatar Boudewijn Rempt

Use our own scaling method to create the preview

Instead of using a QImage, either full-sized or already down-sampled,
that then gets scaled again.

CCBUG:352781
parent 60332e6b
......@@ -564,7 +564,7 @@ void KisImage::scaleImage(const QSize &size, qreal xres, qreal yres, KisFilterSt
applicator.end();
}
void KisImage::scaleNode(KisNodeSP node, qreal sx, qreal sy, KisFilterStrategy *filterStrategy)
void KisImage::scaleNode(KisNodeSP node, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy)
{
KUndo2MagicString actionName(kundo2_i18n("Scale Layer"));
KisImageSignalVector emitSignals;
......@@ -575,7 +575,7 @@ void KisImage::scaleNode(KisNodeSP node, qreal sx, qreal sy, KisFilterStrategy *
emitSignals, actionName);
KisProcessingVisitorSP visitor =
new KisTransformProcessingVisitor(sx, sy,
new KisTransformProcessingVisitor(scaleX, scaleY,
0, 0,
QPointF(),
0,
......
......@@ -120,7 +120,7 @@ public:
/**
* XXX: docs!
*/
QImage convertToQImage(const QRect& scaledRect, const QSize& scaledImageSize, const KoColorProfile *profile);
QImage convertToQImage(const QSize& scaledImageSize, const KoColorProfile *profile);
/**
* Calls KisUpdateScheduler::lock
......@@ -183,8 +183,11 @@ public:
*/
void cropNode(KisNodeSP node, const QRect& newRect);
/// XXX: ApiDox
void scaleImage(const QSize &size, qreal xres, qreal yres, KisFilterStrategy *filterStrategy);
void scaleNode(KisNodeSP node, qreal sx, qreal sy, KisFilterStrategy *filterStrategy);
/// XXX: ApiDox
void scaleNode(KisNodeSP node, qreal scaleX, qreal scaleY, KisFilterStrategy *filterStrategy);
/**
* Execute a rotate transform on all layers in this image.
......
......@@ -103,7 +103,7 @@ KisImageBuilder_Result OraConverter::buildFile(const QUrl &uri, KisImageWSP imag
QSize previewSize = image->bounds().size();
previewSize.scale(QSize(256,256), Qt::KeepAspectRatio);
QImage preview = image->convertToQImage(QRect(0, 0, previewSize.width(), previewSize.height()), previewSize, 0);
QImage preview = image->convertToQImage(previewSize, 0);
KoStoreDevice io(store);
if (io.open(QIODevice::WriteOnly)) {
......
......@@ -50,7 +50,7 @@ QImage LayerThumbProvider::requestImage(const QString& id, QSize* size, const QS
if (id.split("/").first() == QLatin1String("fullimage")) {
KisViewManager* view = qobject_cast<KisViewManager*>(d->layerModel->view());
int width = 300 * ((float)view->image()->bounds().width() / (float)view->image()->bounds().height());
return view->image()->convertToQImage(QRect(0, 0, width, 300), QSize(width, 300), view->image()->profile());
return view->image()->convertToQImage(QSize(width, 300), view->image()->profile());
}
return d->layerModel->layerThumbnail(id);
}
......
......@@ -870,10 +870,12 @@ bool KisDocument::saveNativeFormatCalligra(KoStore *store)
(void)store->close();
}
if (store->open("preview.png")) {
// ### TODO: missing error checking (The partition could be full!)
savePreview(store);
(void)store->close();
if (!isAutosaving()) {
if (store->open("preview.png")) {
// ### TODO: missing error checking (The partition could be full!)
savePreview(store);
(void)store->close();
}
}
if (!completeSaving(store)) {
......@@ -997,16 +999,7 @@ QPixmap KisDocument::generatePreview(const QSize& size)
QRect bounds = d->image->bounds();
QSize newSize = bounds.size();
newSize.scale(size, Qt::KeepAspectRatio);
QImage image;
if (bounds.width() < 10000 && bounds.height() < 10000) {
image = d->image->convertToQImage(d->image->bounds(), 0);
}
else {
image = d->image->convertToQImage(QRect(0, 0, newSize.width(), newSize.height()), newSize, 0);
}
image = image.scaled(newSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
return QPixmap::fromImage(image);
return QPixmap::fromImage(d->image->convertToQImage(newSize, 0));
}
return QPixmap(size);
}
......
......@@ -99,3 +99,8 @@ void KoUpdater::interrupt()
{
m_interrupted = true;
}
KoDummyUpdater::KoDummyUpdater()
: KoUpdater(new KoUpdaterPrivate(0, 0, "dummy"))
{
}
......@@ -118,4 +118,12 @@ private:
int m_progressPercent;
};
/// An updater that does nothing
class KOWIDGETUTILS_EXPORT KoDummyUpdater : public KoUpdater
{
public:
KoDummyUpdater();
};
#endif
......@@ -49,9 +49,12 @@ public:
, m_progress(0)
, m_weight(weight)
, m_interrupted(false)
, m_hasOutput(parent->hasOutput())
, m_hasOutput(false)
, m_parent(parent)
{
if (parent) {
m_hasOutput = parent->hasOutput();
}
setObjectName(name);
}
......
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