sun.awt.image.MultiResolutionImage Java Examples

The following examples show how to use sun.awt.image.MultiResolutionImage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiResolutionImageTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #2
Source File: MultiResolutionImageTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #3
Source File: MultiResolutionImageTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #4
Source File: MultiResolutionImageTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #5
Source File: MultiResolutionImageTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #6
Source File: MultiResolutionImageTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #7
Source File: MultiResolutionImageTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #8
Source File: MultiResolutionImageTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #9
Source File: MultiResolutionImageTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #10
Source File: MultiResolutionImageTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #11
Source File: MultiResolutionImageTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #12
Source File: MultiResolutionImageTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #13
Source File: MultiResolutionImageTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #14
Source File: MultiResolutionImageTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #15
Source File: MultiResolutionImageTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #16
Source File: MultiResolutionImageTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #17
Source File: MultiResolutionImageTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
Example #18
Source File: MultiResolutionImageTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
Example #19
Source File: NSImageToMultiResolutionImageTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        String icon = "NSImage://NSApplicationIcon";
        final Image image = Toolkit.getDefaultToolkit().getImage(icon);

        if (!(image instanceof MultiResolutionImage)) {
            throw new RuntimeException("Icon does not have resolution variants!");
        }

        MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

        int width = 0;
        int height = 0;

        for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
            int rvWidth = resolutionVariant.getWidth(null);
            int rvHeight = resolutionVariant.getHeight(null);
            if (rvWidth < width || rvHeight < height) {
                throw new RuntimeException("Resolution variants are not sorted!");
            }
            width = rvWidth;
            height = rvHeight;
        }
    }
 
Example #20
Source File: CImage.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private CImage createFromImage(final Image image, final boolean prepareImage) {
    if (image instanceof MultiResolutionImage) {
        List<Image> resolutionVariants
                = ((MultiResolutionImage) image).getResolutionVariants();
        return createFromImages(resolutionVariants, prepareImage);
    }

    int[] buffer = imageToArray(image, prepareImage);
    if (buffer == null) {
        return null;
    }
    return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
}
 
Example #21
Source File: CImage.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private CImage createFromImage(final Image image, final boolean prepareImage) {
    if (image instanceof MultiResolutionImage) {
        List<Image> resolutionVariants
                = ((MultiResolutionImage) image).getResolutionVariants();
        return createFromImages(resolutionVariants, prepareImage);
    }

    int[] buffer = imageToArray(image, prepareImage);
    if (buffer == null) {
        return null;
    }
    return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
}
 
Example #22
Source File: NSImageToMultiResolutionImageTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        String icon = "NSImage://NSApplicationIcon";
        final Image image = Toolkit.getDefaultToolkit().getImage(icon);

        if (!(image instanceof MultiResolutionImage)) {
            throw new RuntimeException("Icon does not have resolution variants!");
        }

        MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

        int width = 0;
        int height = 0;

        for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
            int rvWidth = resolutionVariant.getWidth(null);
            int rvHeight = resolutionVariant.getHeight(null);
            if (rvWidth < width || rvHeight < height) {
                throw new RuntimeException("Resolution variants are not sorted!");
            }
            width = rvWidth;
            height = rvHeight;
        }
    }
 
Example #23
Source File: NSImageToMultiResolutionImageTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        String icon = "NSImage://NSApplicationIcon";
        final Image image = Toolkit.getDefaultToolkit().getImage(icon);

        if (!(image instanceof MultiResolutionImage)) {
            throw new RuntimeException("Icon does not have resolution variants!");
        }

        MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

        int width = 0;
        int height = 0;

        for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
            int rvWidth = resolutionVariant.getWidth(null);
            int rvHeight = resolutionVariant.getHeight(null);
            if (rvWidth < width || rvHeight < height) {
                throw new RuntimeException("Resolution variants are not sorted!");
            }
            width = rvWidth;
            height = rvHeight;
        }
    }
 
Example #24
Source File: CImage.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private CImage createFromImage(final Image image, final boolean prepareImage) {
    if (image instanceof MultiResolutionImage) {
        List<Image> resolutionVariants
                = ((MultiResolutionImage) image).getResolutionVariants();
        return createFromImages(resolutionVariants, prepareImage);
    }

    int[] buffer = imageToArray(image, prepareImage);
    if (buffer == null) {
        return null;
    }
    return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
}
 
Example #25
Source File: NSImageToMultiResolutionImageTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        String icon = "NSImage://NSApplicationIcon";
        final Image image = Toolkit.getDefaultToolkit().getImage(icon);

        if (!(image instanceof MultiResolutionImage)) {
            throw new RuntimeException("Icon does not have resolution variants!");
        }

        MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

        int width = 0;
        int height = 0;

        for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
            int rvWidth = resolutionVariant.getWidth(null);
            int rvHeight = resolutionVariant.getHeight(null);
            if (rvWidth < width || rvHeight < height) {
                throw new RuntimeException("Resolution variants are not sorted!");
            }
            width = rvWidth;
            height = rvHeight;
        }
    }
 
Example #26
Source File: CImage.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private CImage createFromImage(final Image image, final boolean prepareImage) {
    if (image instanceof MultiResolutionImage) {
        List<Image> resolutionVariants
                = ((MultiResolutionImage) image).getResolutionVariants();
        return createFromImages(resolutionVariants, prepareImage);
    }

    int[] buffer = imageToArray(image, prepareImage);
    if (buffer == null) {
        return null;
    }
    return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
}
 
Example #27
Source File: NSImageToMultiResolutionImageTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        String icon = "NSImage://NSApplicationIcon";
        final Image image = Toolkit.getDefaultToolkit().getImage(icon);

        if (!(image instanceof MultiResolutionImage)) {
            throw new RuntimeException("Icon does not have resolution variants!");
        }

        MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

        int width = 0;
        int height = 0;

        for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
            int rvWidth = resolutionVariant.getWidth(null);
            int rvHeight = resolutionVariant.getHeight(null);
            if (rvWidth < width || rvHeight < height) {
                throw new RuntimeException("Resolution variants are not sorted!");
            }
            width = rvWidth;
            height = rvHeight;
        }
    }
 
Example #28
Source File: CImage.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public CImage createFromImage(final Image image) {
    if (image instanceof MultiResolutionImage) {
        List<Image> resolutionVariants
                = ((MultiResolutionImage) image).getResolutionVariants();
        return createFromImages(resolutionVariants);
    }

    int[] buffer = imageToArray(image, true);
    if (buffer == null) {
        return null;
    }
    return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
}
 
Example #29
Source File: NSImageToMultiResolutionImageTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        String icon = "NSImage://NSApplicationIcon";
        final Image image = Toolkit.getDefaultToolkit().getImage(icon);

        if (!(image instanceof MultiResolutionImage)) {
            throw new RuntimeException("Icon does not have resolution variants!");
        }

        MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

        int width = 0;
        int height = 0;

        for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
            int rvWidth = resolutionVariant.getWidth(null);
            int rvHeight = resolutionVariant.getHeight(null);
            if (rvWidth < width || rvHeight < height) {
                throw new RuntimeException("Resolution variants are not sorted!");
            }
            width = rvWidth;
            height = rvHeight;
        }
    }
 
Example #30
Source File: CImage.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public CImage createFromImage(final Image image) {
    if (image instanceof MultiResolutionImage) {
        List<Image> resolutionVariants
                = ((MultiResolutionImage) image).getResolutionVariants();
        return createFromImages(resolutionVariants);
    }

    int[] buffer = imageToArray(image, true);
    if (buffer == null) {
        return null;
    }
    return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
}