Search in sources :

Example 1 with MultiResolutionCachedImage

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));
}
Also used : MultiResolutionCachedImage(sun.awt.image.MultiResolutionCachedImage) MultiResolutionImage(java.awt.image.MultiResolutionImage) BufferedImage(java.awt.image.BufferedImage) MultiResolutionCachedImage(sun.awt.image.MultiResolutionCachedImage) BufferedImage(java.awt.image.BufferedImage)

Example 2 with MultiResolutionCachedImage

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));
}
Also used : java.awt(java.awt) MultiResolutionCachedImage(sun.awt.image.MultiResolutionCachedImage) java.awt.image(java.awt.image) Arrays(java.util.Arrays) List(java.util.List) Dimension2D(java.awt.geom.Dimension2D) MultiResolutionImage(java.awt.image.MultiResolutionImage) SunWritableRaster(sun.awt.image.SunWritableRaster) Dimension2D(java.awt.geom.Dimension2D) MultiResolutionCachedImage(sun.awt.image.MultiResolutionCachedImage)

Aggregations

MultiResolutionImage (java.awt.image.MultiResolutionImage)2 MultiResolutionCachedImage (sun.awt.image.MultiResolutionCachedImage)2 java.awt (java.awt)1 Dimension2D (java.awt.geom.Dimension2D)1 java.awt.image (java.awt.image)1 BufferedImage (java.awt.image.BufferedImage)1 Arrays (java.util.Arrays)1 List (java.util.List)1 SunWritableRaster (sun.awt.image.SunWritableRaster)1