copy-image with use device pixel ratio on hi-dpi screen

Asked by Benedykt 'Silmethule' Jaworski

When I select a rectangle in an open PDF and copy the image on a hi-dpi screen with interface scaling (1.5x), and the viewing option “use device pixel ratio” is turned on, the copied image is lower-res than the displayed PDF, as if “use device pixel ratio” were turned off.

If I take a direct screenshot of the PDF viewer window I get 1.5x1.5 times bigger image than the copied one.

Is this expected behaviour that the image being copied is lower-res than the PDF rendered on screen? It’s surprising to me and I don’t like to be forced to zoom in on the page much more than when viewing it to get reasonable quality image when copying.

Question information

Language:
English Edit question
Status:
Solved
For:
qpdfview Edit question
Assignee:
No assignee Edit question
Solved by:
Adam Reichold
Solved:
Last query:
Last reply:
Revision history for this message
Adam Reichold (adamreichold) said :
#1

Hello Benedykt,

I think this is just a bug insofar the code path for rendering an image into the clipboard did not consider the device pixel ratio while the code page for rendering the page for the screen does. I just pushed trunk revision 2149 which should fix this. Could you give this a try?

Thanks and regards,
Adam

Revision history for this message
Benedykt 'Silmethule' Jaworski (silmethule) said :
#2

Built it and now the *resolution* of the copied image is correct indeed – but the coordinates are not. If I try to copy the whole visible area, only about 0.75x0.75 of it actually gets copied (and if I try to copy some smaller part, then a rectangle gets copied, but somewhat shifted and smaller area than chosen).

So I guess now the calculation of the selection coordinates is wrong.

Revision history for this message
Benedykt 'Silmethule' Jaworski (silmethule) said :
#3

Copying text works fine, so I guess that generally the PDF is handled as if there were no use of device pixel ratio and thus the selection `rect` passed to `m_page.render()` is too small and its coordinates translated, relative to the coordinates of the selected part being rendered in higher resolution?

Revision history for this message
Best Adam Reichold (adamreichold) said :
#4

Hello again,

thank you for testing the change. Indeed the transformation from logical to physical output coordinates did not consider the device pixel ratio. (The painting using Qt's API transparently applies that scaling, so when the code needs to do the same step manually the device pixel ratio needs to explicitly included.)

I just pushed trunk revision 2150 which works here when setting e.g. QT_SCALE_FACTOR=2. Could you give that another go?

Regards,
Adam

Revision history for this message
Benedykt 'Silmethule' Jaworski (silmethule) said :
#5
Revision history for this message
Benedykt 'Silmethule' Jaworski (silmethule) said :
#6

Rev. 2150 seems to working correctly without problems! Thanks for fixing it so quickly.

Best regards,
silmeth