use of sun.awt.image.MultiResolutionCachedImage in project jdk8u_jdk by JetBrains.
the class AquaImageFactory method getAppIconCompositedOn.
static IconUIResource getAppIconCompositedOn(final Image background) {
if (background instanceof MultiResolutionCachedImage) {
int width = background.getWidth(null);
Image mrIconImage = ((MultiResolutionCachedImage) background).map(rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
return new IconUIResource(new ImageIcon(mrIconImage));
}
BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
return new IconUIResource(new ImageIcon(iconImage));
}
use of sun.awt.image.MultiResolutionCachedImage in project jdk8u_jdk by JetBrains.
the class CImage method toImage.
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
if (ptr == 0)
return null;
Dimension2D size = nativeGetNSImageSize(ptr);
final int baseWidth = (int) size.getWidth();
final int baseHeight = (int) size.getHeight();
Dimension2D[] sizes = nativeGetNSImageRepresentationSizes(ptr, size.getWidth(), size.getHeight());
// Check if a single represenation has a bigger size and in that case use it as the dest size.
if (sizes != null && sizes.length == 1 && (sizes[0].getWidth() > baseWidth && sizes[0].getHeight() > baseHeight)) {
size = sizes[0];
}
final int dstWidth = (int) size.getWidth();
final int dstHeight = (int) size.getHeight();
return sizes == null || sizes.length < 2 ? new MultiResolutionCachedImage(baseWidth, baseHeight, (width, height) -> toImage(dstWidth, dstHeight)) : new MultiResolutionCachedImage(baseWidth, baseHeight, sizes, (width, height) -> toImage(width, height));
}
Aggregations