Changeset 19641 in josm for trunk/src


Ignore:
Timestamp:
2026-10-06T11:40:41+02:00 (2 weeks ago)
Author:
gaben
Message:

fix #18131 - antialias clipped SVG images (e.g. the JOSM logo)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r19605 r19641  
    8383import com.github.weisj.jsvg.parser.LoaderContext;
    8484import com.github.weisj.jsvg.parser.SVGLoader;
     85import com.github.weisj.jsvg.renderer.SVGRenderingHints;
    8586
    8687/**
    … …  
    14781479        }
    14791480        return resizeMode.createBufferedImage(dim, new Dimension((int) sourceWidth, (int) sourceHeight), g -> {
     1481            // jsvg clips through Graphics2D#clip by default, which is not antialiased (jagged edges, see #18131).
     1482            // Soft clipping avoids that, but needs accurate mask/clip rendering, otherwise the clip is applied as a
     1483            // paint that the clipped elements' own paints override and parts of the image go missing.
     1484            g.setRenderingHint(SVGRenderingHints.KEY_SOFT_CLIPPING, SVGRenderingHints.VALUE_SOFT_CLIPPING_ON);
     1485            g.setRenderingHint(SVGRenderingHints.KEY_MASK_CLIP_RENDERING, SVGRenderingHints.VALUE_MASK_CLIP_RENDERING_ACCURACY);
    14801486            svg.render(null, g);
    14811487        }, null);
Note: See TracChangeset for help on using the changeset viewer.