mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Fix high DPI rendering for the iamge editor widget in Edit Book
This commit is contained in:
parent
c875d408a7
commit
bc6e4b8813
@ -595,14 +595,17 @@ class Canvas(QWidget):
|
|||||||
i = self.current_image
|
i = self.current_image
|
||||||
width, height = i.width(), i.height()
|
width, height = i.width(), i.height()
|
||||||
scaled, width, height = fit_image(width, height, pwidth, pheight)
|
scaled, width, height = fit_image(width, height, pwidth, pheight)
|
||||||
|
dpr = self.devicePixelRatio()
|
||||||
if scaled:
|
if scaled:
|
||||||
i = self.current_image.scaled(width, height, transformMode=Qt.SmoothTransformation)
|
i = self.current_image.scaled(int(dpr * width), int(dpr * height), transformMode=Qt.SmoothTransformation)
|
||||||
self.current_scaled_pixmap = QPixmap.fromImage(i)
|
self.current_scaled_pixmap = QPixmap.fromImage(i)
|
||||||
|
self.current_scaled_pixmap.setDevicePixelRatio(dpr)
|
||||||
|
|
||||||
@painter
|
@painter
|
||||||
def draw_pixmap(self, painter):
|
def draw_pixmap(self, painter):
|
||||||
p = self.current_scaled_pixmap
|
p = self.current_scaled_pixmap
|
||||||
width, height = p.width(), p.height()
|
dpr = self.devicePixelRatio()
|
||||||
|
width, height = int(p.width()/dpr), int(p.height()/dpr)
|
||||||
pwidth, pheight = self.last_canvas_size
|
pwidth, pheight = self.last_canvas_size
|
||||||
x = int(abs(pwidth - width)/2.)
|
x = int(abs(pwidth - width)/2.)
|
||||||
y = int(abs(pheight - height)/2.)
|
y = int(abs(pheight - height)/2.)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user