Skip to content

Fix image size pre 470#32550

Merged
mike-spa merged 2 commits intomusescore:masterfrom
mike-spa:fixImageSizePre470
Mar 11, 2026
Merged

Fix image size pre 470#32550
mike-spa merged 2 commits intomusescore:masterfrom
mike-spa:fixImageSizePre470

Conversation

@mike-spa
Copy link
Contributor

@mike-spa mike-spa commented Mar 9, 2026

Resolves: #32387

@mike-spa mike-spa requested a review from miiizen March 9, 2026 09:01
EditChord::addChordParentheses(chord, { note });
}

static constexpr int OLD_DPI = 360;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be called PRE_470_DPI

{
// The frame radius used to be expressed in raster units and divided by 2 at drawing. Since 4.7 it is expressed in spatium.
static constexpr int OLD_DPI = 360;
return Spatium(frameRadius * (DPI / OLD_DPI) / DefaultStyle::baseStyle().value(Sid::spatium).toDouble()) / 2;
Copy link
Contributor

@shoogle shoogle Mar 10, 2026

Choose a reason for hiding this comment

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

Not your bug, but you should probably replace:

(DPI / OLD_DPI)

With:

(static_cast<double>(DPI) / OLD_DPI)

This ensures the division is computed as a double (i.e. floating-point) rather than truncated to int. (C++ arithmetic uses the higher-precision type, so only one operand needs to be double for the result to be double.)

This would also fix it, but it's less explicit, so probably best avoided:

(frameRadius * DPI) / OLD_DPI

Of course, if DPI and OLD_DPI divide cleanly then it makes no difference, at least until one of them is changed in the future.

{
if (image->size().isNull() && image->score()->mscVersion() < 470) {
image->init();
image->setSize(image->size() * (DPI / OLD_DPI));
Copy link
Contributor

@shoogle shoogle Mar 10, 2026

Choose a reason for hiding this comment

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

Potentially the same bug as above, though I'm not sure whether image->size() is an integer or floating-point type, and what the input to setSize() needs to be.

But even if these are all integers, there will be a rounding error unless you at least do:

image->setSize((image->size() * DPI) / OLD_DPI); // Multiply first to avoid rounding error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DPI is actually already a double so this is not a problem, but you're right that OLD_DPI (now called PRE_470_DPI) should be a double too, for clarity.

@mike-spa mike-spa force-pushed the fixImageSizePre470 branch from 8a4ab49 to 80db03a Compare March 11, 2026 10:44
@mike-spa mike-spa merged commit 1a09e19 into musescore:master Mar 11, 2026
12 checks passed
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.

Unresized images in older scores display too small

3 participants