r24394 by jghali - Backport r24302: Fix canvas drawing in case device pixel ratio is not an integer value

scribus-commit scribus-commit at lists.scribus.net
Tue Jan 12 12:34:22 UTC 2021


Author: jghali
Date: Tue Jan 12 12:34:22 2021
New Revision: 24394

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24394
Log:
Backport r24302: Fix canvas drawing in case device pixel ratio is not an integer value

Modified:
    branches/Version156/Scribus/scribus/canvas.cpp

Modified: branches/Version156/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24394&path=/branches/Version156/Scribus/scribus/canvas.cpp
==============================================================================
--- branches/Version156/Scribus/scribus/canvas.cpp	(original)
+++ branches/Version156/Scribus/scribus/canvas.cpp	Tue Jan 12 12:34:22 2021
@@ -961,10 +961,10 @@
 //	QTime tim;
 //	tim.start();
 // 	qDebug() << "Canvas::drawContents" << clipx << clipy << clipw << cliph<<m_viewMode.forceRedraw<<m_viewMode.operItemSelecting;
-	int docPagesCount=m_doc->Pages->count();
-	ScPainter *painter=nullptr;
-	QImage img = QImage(clipw * devicePixelRatio(), cliph * devicePixelRatio(), QImage::Format_ARGB32_Premultiplied);
-	img.setDevicePixelRatio(devicePixelRatio());
+	int docPagesCount = m_doc->Pages->count();
+	ScPainter *painter = nullptr;
+	QImage img = QImage(clipw * devicePixelRatioF(), cliph * devicePixelRatioF(), QImage::Format_ARGB32_Premultiplied);
+	img.setDevicePixelRatio(devicePixelRatioF());
 	painter = new ScPainter(&img, img.width(), img.height(), 1.0, 0);
 	painter->clear(palette().color(QPalette::Window));
 	painter->newPath();
@@ -2405,17 +2405,17 @@
 
 QPixmap Canvas::createPixmap(double w, double h)
 {
-	QPixmap p(w * devicePixelRatio(), h * devicePixelRatio());
-	p.setDevicePixelRatio(devicePixelRatio());
+	QPixmap p(w * devicePixelRatioF(), h * devicePixelRatioF());
+	p.setDevicePixelRatio(devicePixelRatioF());
 	return p;
 }
 
 void Canvas::drawPixmap(QPainter& painter, double x, double y, const QPixmap& pixmap, double sx, double sy, double sw, double sh)
 {
-	sx *= devicePixelRatio();
-	sy *= devicePixelRatio();
-	sw *= devicePixelRatio();
-	sh *= devicePixelRatio();
+	sx *= devicePixelRatioF();
+	sy *= devicePixelRatioF();
+	sw *= devicePixelRatioF();
+	sh *= devicePixelRatioF();
 	painter.drawPixmap(x, y, pixmap, sx, sy, sw, sh);
 }
 




More information about the scribus-commit mailing list