fix: scaling of mirror pixmap#569
Conversation
b6de750 to
53f3077
Compare
|
This PR fixes issue #618. |
BackgroundSome more background on this simple PR. The class First OpenBoard/src/gui/UBScreenMirror.cpp Lines 108 to 109 in d4b91d8 Here the pixmap is scaled so that it fits to the target. Note that UBScreenMirror inherits QWidget, so the width() and height() functions return the dimensions of that widget. The flag Qt::KeepAspectRatio is used to avoid distortion. The pixmap is scaled so that one of its sides has the same size than the target, while the other is less or equal.
The OpenBoard/src/gui/UBScreenMirror.cpp Lines 61 to 76 in d4b91d8 Here first a black background is drawn. Then an x and y offset is computed to place the pixmap centered. Finally the pixmap is drawn using drawPixmap.
The original code uses an overload with the following signature: void QPainter::drawPixmap(int x, int y, int width, int height, const QPixmap &pixmap)This overload scales the pixmap according to the As the image was already properly scaled when grabbing, this scaling is not necessary. By just using the overload void QPainter::drawPixmap(int x, int y, const QPixmap &pixmap)we can avoid scaling and just position the pixmap in the center of the target widget. |
53f3077 to
93f1f69
Compare
|
As I already explained, what prevents me from merging it is that your commit reverts a fix I made for another issue, reported by the test team (and I reproduced it too) where in macOS, with two screens (can't remember the exact config, but probably with some differences in devicepixelratio, or resolution (but with same aspect ratio), or something else, didn't really investigate)), the "mirror pixmap" was only occupying a small part of the screen. |
|
Your comment brought me to the following excerpt from the Qt documentation:
This would mean that neither your fix nor mine is correct. I will investigate further and try to provide something which is able to handle HiDPI. |
exact |
93f1f69 to
fc1a75d
Compare
|
Here my idea of what happened:
The problem is, that device independent pixels as used for measuring the width and height of a widget were mixed with the size of a Note that there are some other places where
When shortly looking over these places I think it is not a problem for the magnifier. I have however no idea what the latter two are actually doing. BTW: Your fix helped, because then the pixmap was again scaled up for painting. But it creates a wrongly positioned and distorted image when the two displays don't have the same aspect ratio. |
fc1a75d to
d835e5e
Compare
|
Perhaps you might have again a look on this, whether it fits to both cases:
In the current status of this PR I tried to address both, but it needs testing on MacOS. |
d835e5e to
faaf75f
Compare
|
Hi, I can't prioritize on it but I didn't forget it. Also, the issue was not exactly the one you spotted as the ratio was more of 10 than 2, but still it was maybe somehow related to the devicepixelratio. I'll look at it when possible |
- when scaling the pixmap take the devicePixelRatio into account - do not scale the already scaled pixmap when drawing in UBScreenMirror - use device independent coordinates when positioning the pixmap
faaf75f to
e9908d7
Compare
|
As we are no longer supposed to have macOS machines with multiple screens in our schools, I'll assume the issue can no longer be experienced on our side, thus I can merge this long awaited request. If the issue reappears, at least I'll be able to analyse it further |
fix: do not scale the already scaled pixmap when drawing in UBScreenMirror