Skip to content

Fix for aspect ratio losing ratio #3439

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brunoais
Copy link

Fix for aspect ratio losing ratio (bad code version)

The reason why it's bad code is because I'm using a global variable for this purpose and that is a really bad idea. Unfortunately, I don't know where can this information be stored.

Please help: The part I'm missing is somewhere to store the float variable. Once I have a suitable place, this PR is complete.

Note: I'm not used to C++ code, this is my first time working with C++ code without prior help, please be patient.

Fixes #3436

The problem was that the ratio was being calculated on every "tick" of movement instead of keeping it.
So every pixel moved, a new ratio was calculated which is not the user's intent.
This way, the ratio is kept while the user is resizing the image and tries to minimize the rounding issues.
Rounding issues still exist but they are now only minimal on at what is highest of the ratio.
@brunoais brunoais force-pushed the #3436_fixKeepAspectRatio branch from 401be4d to eddbcca Compare December 16, 2023 18:02
@borgmanJeremy borgmanJeremy self-assigned this May 1, 2025
bool symmetryMod = qApp->keyboardModifiers() & Qt::ShiftModifier;
bool preserveAspect = qApp->keyboardModifiers() & Qt::ControlModifier;
if(aspectRatio < 0 || ! preserveAspect){
Copy link
Collaborator

Choose a reason for hiding this comment

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

whats the reason for checking if the aspectRatio is < 0?

Copy link
Member

Choose a reason for hiding this comment

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

I think because of line 194, this if statement means "if the user have not forced certain aspect ratio (and if it is not marked to be preserved), then ..."

But based on what I can see, aspect ratio will always be -1.0 before this if. Unless in C++ the variables are not bound to the function scope and line 224 in changes the global value of the variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using CTRL to resize and maintain aspect ratio doesn't work if the ratio is not 1:1
3 participants