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

scribus-commit scribus-commit at lists.scribus.net
Mon Nov 30 22:48:46 UTC 2020


Author: jghali
Date: Mon Nov 30 22:48:46 2020
New Revision: 24302

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

Modified:
    trunk/Scribus/scribus/canvas.cpp

Modified: trunk/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24302&path=/trunk/Scribus/scribus/canvas.cpp
==============================================================================
--- trunk/Scribus/scribus/canvas.cpp	(original)
+++ trunk/Scribus/scribus/canvas.cpp	Mon Nov 30 22:48:46 2020
@@ -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