Changeset 16997 in josm


Ignore:
Timestamp:
2020-09-02T19:58:37+02:00 (3 weeks ago)
Author:
simon04
Message:

see #19706, see #19725 - ImageProvider: re-activate upscaling of SVG images

Location:
trunk
Files:
11 edited

Legend:

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

    r16988 r16997  
    14901490            return null;
    14911491        }
     1492        if (resizeMode == ImageResizeMode.BOUNDED) {
     1493            resizeMode = ImageResizeMode.BOUNDED_UPSCALE;
     1494        }
    14921495        return resizeMode.createBufferedImage(dim, new Dimension((int) sourceWidth, (int) sourceHeight), g -> {
    14931496            try {
  • trunk/src/org/openstreetmap/josm/tools/ImageResizeMode.java

    r16978 r16997  
    3333        @Override
    3434        Dimension computeDimension(Dimension dim, Dimension icon) {
     35            final int maxWidth = Math.min(dim.width, icon.width);
     36            final int maxHeight = Math.min(dim.height, icon.height);
     37            return BOUNDED_UPSCALE.computeDimension(new Dimension(maxWidth, maxHeight), icon);
     38        }
     39    },
     40
     41    BOUNDED_UPSCALE {
     42        @Override
     43        Dimension computeDimension(Dimension dim, Dimension icon) {
    3544            CheckParameterUtil.ensureThat((dim.width > 0 || dim.width == -1) && (dim.height > 0 || dim.height == -1),
    3645                    () -> dim + " is invalid");
    37             final int maxWidth = Math.min(dim.width, icon.width);
    38             final int maxHeight = Math.min(dim.height, icon.height);
     46            final int maxWidth = dim.width;
     47            final int maxHeight = dim.height;
    3948            final Dimension spec;
    4049            if (maxWidth == -1 || maxHeight == -1) {
  • trunk/test/functional/org/openstreetmap/josm/tools/ImageProviderTest.java

    r16989 r16997  
    185185        ImageResource resource = new ImageProvider("presets/misc/housenumber_small").getResource();
    186186        testImage(8, 6, "housenumber_small-BOUNDED-08x08", resource.getImageIconBounded(new Dimension(8, 8)));
    187         testImage(12, 9, "housenumber_small-BOUNDED-16x16", resource.getImageIconBounded(new Dimension(16, 16)));
    188         testImage(12, 9, "housenumber_small-BOUNDED-24x24", resource.getImageIconBounded(new Dimension(24, 24)));
     187        testImage(16, 12, "housenumber_small-BOUNDED-16x16", resource.getImageIconBounded(new Dimension(16, 16)));
     188        testImage(24, 18, "housenumber_small-BOUNDED-24x24", resource.getImageIconBounded(new Dimension(24, 24)));
    189189    }
    190190
     
    261261        GuiSizesHelper.setPixelDensity(guiScale);
    262262        Point hotSpot = new Point();
    263         final UnaryOperator<Dimension> bestCursorSizeFunction = dim -> dim;
     263        UnaryOperator<Dimension> bestCursorSizeFunction = dim -> dim;
    264264        Image image = ImageProvider.getCursorImage("normal", "selection", bestCursorSizeFunction, hotSpot);
     265        bestCursorSizeFunction = dim -> new Dimension((int) (dim.width * guiScale), (int) (dim.height * guiScale));
    265266        assertCursorDimensionsCorrect(new Point.Double(3.0, 2.0), image, bestCursorSizeFunction, hotSpot);
    266267        assertImageEquals("cursor", getReferenceFile("cursor-normal-selection-" + Math.round(guiScale * 10)),
Note: See TracChangeset for help on using the changeset viewer.