Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skin preview: consider devicePixelRatio when scaling #3941

Merged
merged 1 commit into from Jun 4, 2021

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Jun 4, 2021

follow-up for #3926
fixes blurry preview images.

before
image

this PR (not ethat you can now read the library : ) try with QT_SCALE_FACTORS=3 for full effect
preview_after

@ronso0 ronso0 added this to the 2.3.0 milestone Jun 4, 2021
@ronso0 ronso0 added this to In progress in 2.3 release via automation Jun 4, 2021
@ronso0 ronso0 requested a review from ywwg June 4, 2021 01:21
@ronso0 ronso0 mentioned this pull request Jun 4, 2021
@Holzhaus Holzhaus changed the title skin preview: consider devicePixelRation when scaling skin preview: consider devicePixelRatio when scaling Jun 4, 2021
@ronso0 ronso0 moved this from In progress to Needs Review in 2.3 release Jun 4, 2021
preview = preview.scaled(QSize(640, 360), Qt::KeepAspectRatio, Qt::SmoothTransformation);
QSize scaledSize(static_cast<int>(640 * devicePixelRatio),
static_cast<int>(360 * devicePixelRatio));
preview.setDevicePixelRatio(devicePixelRatio);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line redundant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. without line79 the image would just be as big as set by the QSize.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, you refer to the duplicate setDevicePixelRatio line above the code quote here.
yes, that's unnnecessary.
fixed.

QSize scaledSize(static_cast<int>(640 * devicePixelRatio),
static_cast<int>(360 * devicePixelRatio));
preview.setDevicePixelRatio(devicePixelRatio);
preview = preview.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be shortened to

Suggested change
preview = preview.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
preview = preview.scaled(QSize(640, 360) * devicePixelRatio, Qt::KeepAspectRatio, Qt::SmoothTransformation);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find docu on how to scale a QSize with just a factor. did you try it?
if yes, feel free to push the shorter version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find docu on how to scale a QSize with just a factor.

https://doc.qt.io/qt-5/qsize.html#operator-2a-1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! thanks.

Copy link
Member

@ywwg ywwg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if this would be automatic or not. thanks for the fix

@ronso0
Copy link
Member Author

ronso0 commented Jun 4, 2021

Thanks for the quick review. Ready!

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you.

@daschuer daschuer merged commit cc49b89 into mixxxdj:2.3 Jun 4, 2021
2.3 release automation moved this from Needs Review to Done Jun 4, 2021
@ronso0 ronso0 deleted the preview-scaling branch June 4, 2021 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2.3 release
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants