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); } } }
public int getIntrinsicWidth() { return _image.getWidth(); }
public int getIntrinsicHeight() { return _image.getHeight(); }
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 {
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 int getIntrinsicWidth() { return _image.getWidth(); }
public int getIntrinsicHeight() { return _image.getHeight(); }
long maxWidth = CalculatedStyle.getCSSMaxWidth(c, box); long maxHeight = CalculatedStyle.getCSSMaxHeight(c, box); int intrinsicHeight = fsImage.getHeight(); int intrinsicWidth = fsImage.getWidth(); 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 static void drawImage(RenderingContext c, BlockBox box, MarkerData markerData) { FSImage img = null; MarkerData.ImageMarker marker = markerData.getImageMarker(); img = marker.getImage(); if (img != null) { StrutMetrics strutMetrics = box.getMarkerData().getStructMetrics(); int x = getReferenceX(c, box); // FIXME: findbugs possible loss of precision, cf. int / (float)2 x += -marker.getLayoutWidth() + (marker.getLayoutWidth() / 2 - img.getWidth() / 2); c.getOutputDevice().drawImage(img, x, (int)(getReferenceBaseline(c, box) - strutMetrics.getAscent() / 2 - img.getHeight() / 2), box.getStyle().isImageRenderingInterpolate()); } }
private void paintHorizontalBand(FSImage image, int left, int top, int right, boolean interpolate) { int width = image.getWidth(); for (int x = left; x < right; x+= width) { drawImage(image, x, top, interpolate); } }
private void paintVerticalBand(FSImage image, int left, int top, int bottom, boolean interpolate) { int height = image.getHeight(); for (int y = top; y < bottom; y+= height) { drawImage(image, left, y, interpolate); } }
long maxWidth = CalculatedStyle.getCSSMaxWidth(c, box); long maxHeight = CalculatedStyle.getCSSMaxHeight(c, box); int intrinsicHeight = fsImage.getHeight(); int intrinsicWidth = fsImage.getWidth(); 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);