Opened 7 years ago
Closed 7 years ago
#16201 closed enhancement (fixed)
[Patch] Simplify calculation of SVG size in ImageProvider
Reported by: | floscher | Owned by: | team |
---|---|---|---|
Priority: | minor | Milestone: | 18.05 |
Component: | Core | Version: | |
Keywords: | Cc: |
Description
This is a small patch improving how the ImageProvider
calculates the x and y scaling factors for an SVG:
- the scaled width and height as well as the scaling factors are now final variables that are assigned only once.
- all negative numbers in the desired image dimensions are treated the same (that dimension is scaled automatically). Before only -1 was treated this way, other negative values were treated as the desired width/height.
- the logo sizes are now square (128×129 → 128×128 and 256×258 → 256×256)
Attachments (4)
Change History (13)
by , 7 years ago
Attachment: | ImageProvider-SVG-scaling.patch added |
---|
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Milestone: | → 18.05 |
---|
comment:3 by , 7 years ago
Replying to floscher:
- the logo sizes are now square (128×129 → 128×128 and 256×258 → 256×256)
I don't remember why we (I?) did that but it was intentional and wasn't a typo. Did you change them to fix a specific issue?
comment:4 by , 7 years ago
I think (can't check right now), the logo was not exactly square until I modified the SVG logo and amongst other things made the size of the image exactly square by adjusting the blank space around the logo.
I'll check that later.
comment:5 by , 7 years ago
Ok, I see. You added the 128×129 dimension in https://josm.openstreetmap.de/changeset/7768/josm . At that time the PNG version of the logo was 256×258, but the SVG version was 1000×1000px in size at all times.
So it should be ok to make the dimensions square, now that only the SVG version is used.
comment:7 by , 7 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This breaks org.openstreetmap.josm.gui.mappaint.MapCSSRendererTest.testRender[way-repeat-image]
:
by , 7 years ago
Attachment: | ImageProvider-SVG-scaling-2.patch added |
---|
Follow-up patch for the previous patch: Fixes calculation of scaling factor which caused functional test to fail.
comment:8 by , 7 years ago
Thank you for the notification. The issue was, that I calculated the scaling factor based on the width/height of the resulting raster image (integer) and the size of the unscaled SVG (floating point number). It's now calculated from the size of the scaled SVG as floating point number and the size of the unscaled SVG also as floating point number.
The test org.openstreetmap.josm.gui.mappaint.MapCSSRendererTest.testRender[way-repeat-image]
still fails, but the differences are really minimal (30 pixels differ by 18 or less). These are probably rounding artifacts, because changed the calculation a bit around so rounding happens at different places than before.
by , 7 years ago
Attachment: | test-output.png added |
---|
Output of the way-repeat-image
test after the second patch
by , 7 years ago
Attachment: | test-differences.png added |
---|
Difference between the reference image and the output of way-repeat-image
test after the second patch
ping