private void scaleBackgroundImage(CssContext c, CalculatedStyle style, Rectangle backgroundContainer, FSImage image) { BackgroundSize backgroundSize = style.getBackgroundSize(); if (! backgroundSize.isBothAuto()) { if (backgroundSize.isCover() || backgroundSize.isContain()) { int testHeight = (int)((double)image.getHeight() * backgroundContainer.width / image.getWidth()); if (backgroundSize.isContain()) { if (testHeight > backgroundContainer.height) { image.scale(-1, backgroundContainer.height); } else { image.scale(backgroundContainer.width, -1); } } else if (backgroundSize.isCover()) { if (testHeight > backgroundContainer.height) { image.scale(backgroundContainer.width, -1); } else { image.scale(-1, backgroundContainer.height); } } } else { int scaledWidth = calcBackgroundSizeLength(c, style, backgroundSize.getWidth(), backgroundContainer.width); int scaledHeight = calcBackgroundSizeLength(c, style, backgroundSize.getHeight(), backgroundContainer.height); image.scale(scaledWidth, scaledHeight); } } }
fsImage.scale((int) maxWidth, -1); } else { fsImage.scale(-1, (int) maxHeight); fsImage.scale((int) maxWidth, -1); } else if (hasMaxHeight && intrinsicHeight > maxHeight) { fsImage.scale(-1, (int) maxHeight); long maxHeight = box.getStyle().asLength(c, CSSName.MAX_HEIGHT).value(); if (cssHeight > maxHeight && cssHeight >= cssWidth) { fsImage.scale(-1, (int) maxHeight); } else if (cssWidth > maxWidth) { fsImage.scale((int) maxWidth, -1); } else { fsImage.scale(cssWidth, cssHeight); fsImage.scale(cssWidth, cssHeight);
fsImage.scale((int) maxWidth, -1); } else { fsImage.scale(-1, (int) maxHeight); fsImage.scale((int) maxWidth, -1); } else if (hasMaxHeight && intrinsicHeight > maxHeight) { fsImage.scale(-1, (int) maxHeight); long maxHeight = box.getStyle().asLength(c, CSSName.MAX_HEIGHT).value(); if (cssHeight > maxHeight && cssHeight >= cssWidth) { fsImage.scale(-1, (int) maxHeight); } else if (cssWidth > maxWidth) { fsImage.scale((int) maxWidth, -1); } else { fsImage.scale(cssWidth, cssHeight); fsImage.scale(cssWidth, cssHeight);
private MarkerData.ImageMarker makeImageMarker( LayoutContext c, StrutMetrics structMetrics, String image) { FSImage img = null; if (! image.equals("none")) { img = c.getUac().getImageResource(image).getImage(); if (img != null) { StrutMetrics strutMetrics = structMetrics; if (img.getHeight() > strutMetrics.getAscent()) { img.scale(-1, (int) strutMetrics.getAscent()); } MarkerData.ImageMarker result = new MarkerData.ImageMarker(); result.setImage(img); result.setLayoutWidth(img.getWidth() * 2); return result; } } return null; }
public synchronized ImageResource get(final String uri, final int width, final int height) { if (ImageUtil.isEmbeddedBase64Image(uri)) { ImageResource resource = loadEmbeddedBase64ImageResource(uri); resource.getImage().scale(width, height); return resource; } else {