java.awt.image.MultiResolutionImage Java Examples

The following examples show how to use java.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 openjdk-jdk9 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: MultiResultionImageUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void baseMultiResImageTest() {
    int baseIndex = 1;
    int length = 4;
    BufferedImage[] resolutionVariants = new BufferedImage[length];
    for (int i = 0; i < length; i++) {
        resolutionVariants[i] = createImage(i);
    }
    MultiResolutionImage bmrImage = new BaseMultiResolutionImage(baseIndex, resolutionVariants);
    List<Image> rvImageList = bmrImage.getResolutionVariants();
    assertEquals("MultiResoltion Image shoudl contain the same number of resolution variants!", rvImageList.size(), length);

    for (int i = 0; i < length; i++) {
        int imageSize = getSize(i);
        Image testRVImage = bmrImage.getResolutionVariant(imageSize, imageSize);
        assertSame("Images should be the same", testRVImage, resolutionVariants[i]);
    }

}
 
Example #3
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 #4
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 #5
Source File: MultiResolutionImageTest.java    From openjdk-jdk9 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: MultiResolutionImageSupport.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
public List<Image> getResolutionVariants() {
	List<Image> variants = ((MultiResolutionImage)mrImage).getResolutionVariants();
	List<Image> mappedVariants = new ArrayList<>();
	for( Image image : variants )
		mappedVariants.add( mapAndCacheImage( image ) );
	return mappedVariants;
}
 
Example #7
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 #8
Source File: SunToolkit.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected Image getImageWithResolutionVariant(URL url,
        URL resolutionVariantURL) {
    synchronized (urlImgCache) {
        Image image = getImageFromHash(this, url);
        if (image instanceof MultiResolutionImage) {
            return image;
        }
        Image resolutionVariant = getImageFromHash(this, resolutionVariantURL);
        image = createImageWithResolutionVariant(image, resolutionVariant);
        String key = url.toString();
        urlImgCache.put(key, image);
        return image;
    }
}
 
Example #9
Source File: SunToolkit.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected Image getImageWithResolutionVariant(String fileName,
        String resolutionVariantName) {
    synchronized (fileImgCache) {
        Image image = getImageFromHash(this, fileName);
        if (image instanceof MultiResolutionImage) {
            return image;
        }
        Image resolutionVariant = getImageFromHash(this, resolutionVariantName);
        image = createImageWithResolutionVariant(image, resolutionVariant);
        fileImgCache.put(fileName, image);
        return image;
    }
}
 
Example #10
Source File: BadHiDPIIcon.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static BufferedImage getBufferedImage(Image image) {
    if (image instanceof MultiResolutionImage) {
        MultiResolutionImage mrImage = (MultiResolutionImage) image;
        return (BufferedImage) mrImage.getResolutionVariant(32, 32);
    }
    return (BufferedImage) image;
}
 
Example #11
Source File: BaseMultiResolutionImageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testRVSizes() {

        int imageSize = getSize(1);

        double[][] sizeArray = {
            {-imageSize, imageSize},
            {2 * imageSize, -2 * imageSize},
            {Double.POSITIVE_INFINITY, imageSize},
            {Double.POSITIVE_INFINITY, -imageSize},
            {imageSize, Double.NEGATIVE_INFINITY},
            {-imageSize, Double.NEGATIVE_INFINITY},
            {Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY},
            {Double.NaN, imageSize},
            {imageSize, Double.NaN},
            {Double.NaN, Double.NaN},
            {Double.POSITIVE_INFINITY, Double.NaN}
        };

        for (double[] sizes : sizeArray) {
            try {
                MultiResolutionImage mrImage = new BaseMultiResolutionImage(
                        0, createRVImage(0), createRVImage(1));
                mrImage.getResolutionVariant(sizes[0], sizes[1]);
            } catch (IllegalArgumentException ignored) {
                continue;
            }

            throw new RuntimeException("IllegalArgumentException is not thrown!");
        }
    }
 
Example #12
Source File: NSImageToMultiResolutionImageTest.java    From openjdk-jdk9 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 #13
Source File: MultiResolutionDisabledImageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        Image baseMRImage = new BaseMultiResolutionImage(createImage(1),
                                                         createImage(2));
        testMRDisabledImage(baseMRImage);

        saveImages();
        Image toolkitMRImage = Toolkit.getDefaultToolkit().getImage(IMAGE_NAME_1X);

        if (toolkitMRImage instanceof MultiResolutionImage) {
            testMRDisabledImage(toolkitMRImage);
        }
    }
 
Example #14
Source File: MultiResolutionDisabledImageTest.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 {

        Image baseMRImage = new BaseMultiResolutionImage(createImage(1),
                                                         createImage(2));
        testMRDisabledImage(baseMRImage);

        saveImages();
        Image toolkitMRImage = Toolkit.getDefaultToolkit().getImage(IMAGE_NAME_1X);

        if (toolkitMRImage instanceof MultiResolutionImage) {
            testMRDisabledImage(toolkitMRImage);
        }
    }
 
Example #15
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 #16
Source File: BaseMultiResolutionImageTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testRVSizes() {

        int imageSize = getSize(1);

        double[][] sizeArray = {
            {-imageSize, imageSize},
            {2 * imageSize, -2 * imageSize},
            {Double.POSITIVE_INFINITY, imageSize},
            {Double.POSITIVE_INFINITY, -imageSize},
            {imageSize, Double.NEGATIVE_INFINITY},
            {-imageSize, Double.NEGATIVE_INFINITY},
            {Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY},
            {Double.NaN, imageSize},
            {imageSize, Double.NaN},
            {Double.NaN, Double.NaN},
            {Double.POSITIVE_INFINITY, Double.NaN}
        };

        for (double[] sizes : sizeArray) {
            try {
                MultiResolutionImage mrImage = new BaseMultiResolutionImage(
                        0, createRVImage(0), createRVImage(1));
                mrImage.getResolutionVariant(sizes[0], sizes[1]);
            } catch (IllegalArgumentException ignored) {
                continue;
            }

            throw new RuntimeException("IllegalArgumentException is not thrown!");
        }
    }
 
Example #17
Source File: Images.java    From demo-java-x with MIT License 5 votes vote down vote up
public static void main(String[] args) throws IOException {
	MultiResolutionImage tokio = loadTokio();
	int desiredImageWidth = ThreadLocalRandom.current().nextInt(1500);
	Image variant = tokio.getResolutionVariant(desiredImageWidth, 1);

	System.out.printf("Width of image for %d: %d%n", desiredImageWidth, variant.getWidth(null));
}
 
Example #18
Source File: CImage.java    From openjdk-jdk9 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 #19
Source File: MultiResolutionCachedImage.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static Image map(MultiResolutionImage mrImage,
                        Function<Image, Image> mapper) {

    if (mrImage instanceof MultiResolutionToolkitImage) {
        MultiResolutionToolkitImage mrtImage =
                (MultiResolutionToolkitImage) mrImage;
        return MultiResolutionToolkitImage.map(mrtImage, mapper);
    }

    BiFunction<Integer, Integer, Image> sizeMapper
            = (w, h) -> mapper.apply(mrImage.getResolutionVariant(w, h));

    if (mrImage instanceof MultiResolutionCachedImage) {
        MultiResolutionCachedImage mrcImage
                = (MultiResolutionCachedImage) mrImage;

        return new MultiResolutionCachedImage(mrcImage.baseImageWidth,
                                              mrcImage.baseImageHeight,
                                              mrcImage.sizes,
                                              sizeMapper,
                                              false);
    }

    Image image = (Image) mrImage;
    int width = image.getWidth(null);
    int height = image.getHeight(null);
    return new MultiResolutionCachedImage(width, height, sizeMapper);
}
 
Example #20
Source File: SunToolkit.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected Image getImageWithResolutionVariant(URL url,
        URL resolutionVariantURL) {
    synchronized (urlImgCache) {
        Image image = getImageFromHash(this, url);
        if (image instanceof MultiResolutionImage) {
            return image;
        }
        Image resolutionVariant = getImageFromHash(this, resolutionVariantURL);
        image = createImageWithResolutionVariant(image, resolutionVariant);
        String key = url.toString();
        urlImgCache.put(key, image);
        return image;
    }
}
 
Example #21
Source File: SunToolkit.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected Image getImageWithResolutionVariant(String fileName,
        String resolutionVariantName) {
    synchronized (fileImgCache) {
        Image image = getImageFromHash(this, fileName);
        if (image instanceof MultiResolutionImage) {
            return image;
        }
        Image resolutionVariant = getImageFromHash(this, resolutionVariantName);
        image = createImageWithResolutionVariant(image, resolutionVariant);
        fileImgCache.put(fileName, image);
        return image;
    }
}
 
Example #22
Source File: Images.java    From demo-java-x with MIT License 5 votes vote down vote up
private static MultiResolutionImage loadTokio() throws IOException {
	List<Image> tokios = new ArrayList<>();
	for (String url : IMAGE_URLS) {
		tokios.add(ImageIO.read(new URL(url)));
	}
	return new BaseMultiResolutionImage(tokios.toArray(new Image[0]));
}
 
Example #23
Source File: MultiResolutionCachedImage.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static Image map(MultiResolutionImage mrImage,
                        Function<Image, Image> mapper) {

    if (mrImage instanceof MultiResolutionToolkitImage) {
        MultiResolutionToolkitImage mrtImage =
                (MultiResolutionToolkitImage) mrImage;
        return MultiResolutionToolkitImage.map(mrtImage, mapper);
    }

    BiFunction<Integer, Integer, Image> sizeMapper
            = (w, h) -> mapper.apply(mrImage.getResolutionVariant(w, h));

    if (mrImage instanceof MultiResolutionCachedImage) {
        MultiResolutionCachedImage mrcImage
                = (MultiResolutionCachedImage) mrImage;

        return new MultiResolutionCachedImage(mrcImage.baseImageWidth,
                                              mrcImage.baseImageHeight,
                                              mrcImage.sizes,
                                              sizeMapper,
                                              false);
    }

    Image image = (Image) mrImage;
    int width = image.getWidth(null);
    int height = image.getHeight(null);
    return new MultiResolutionCachedImage(width, height, sizeMapper);
}
 
Example #24
Source File: SunToolkit.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected Image getImageWithResolutionVariant(URL url,
        URL resolutionVariantURL) {
    synchronized (urlImgCache) {
        Image image = getImageFromHash(this, url);
        if (image instanceof MultiResolutionImage) {
            return image;
        }
        Image resolutionVariant = getImageFromHash(this, resolutionVariantURL);
        image = createImageWithResolutionVariant(image, resolutionVariant);
        String key = url.toString();
        urlImgCache.put(key, image);
        return image;
    }
}
 
Example #25
Source File: SunToolkit.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected Image getImageWithResolutionVariant(String fileName,
        String resolutionVariantName) {
    synchronized (fileImgCache) {
        Image image = getImageFromHash(this, fileName);
        if (image instanceof MultiResolutionImage) {
            return image;
        }
        Image resolutionVariant = getImageFromHash(this, resolutionVariantName);
        image = createImageWithResolutionVariant(image, resolutionVariant);
        fileImgCache.put(fileName, image);
        return image;
    }
}
 
Example #26
Source File: MultiResolutionImageSupport.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
public static Image map( Image image, Function<Image, Image> mapper ) {
	return image instanceof MultiResolutionImage
		? new MappedMultiResolutionImage( image, mapper )
		: mapper.apply( image );
}
 
Example #27
Source File: MultiResolutionImageTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static void testToolkitMultiResolutionImage(Image image,
    boolean enableImageScaling) 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");
    }

    final BufferedImage bufferedImage1x = new BufferedImage(IMAGE_WIDTH,
        IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics2D g1x = (Graphics2D) bufferedImage1x.getGraphics();
    setImageScalingHint(g1x, false);
    g1x.drawImage(image, 0, 0, null);
    checkColor(bufferedImage1x.getRGB(3 * IMAGE_WIDTH / 4,
        3 * IMAGE_HEIGHT / 4), false);

    Image resolutionVariant = ((MultiResolutionImage) image).
        getResolutionVariant(2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT);

    if (resolutionVariant == null) {
        throw new RuntimeException("Resolution variant is null");
    }

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

    final BufferedImage bufferedImage2x = new BufferedImage(2 * IMAGE_WIDTH,
        2 * IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2x = (Graphics2D) bufferedImage2x.getGraphics();
    setImageScalingHint(g2x, enableImageScaling);
    g2x.drawImage(image, 0, 0, 2 * IMAGE_WIDTH,
        2 * IMAGE_HEIGHT, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, null);
    checkColor(bufferedImage2x.getRGB(3 * IMAGE_WIDTH / 2,
        3 * IMAGE_HEIGHT / 2), enableImageScaling);

    if (!(image instanceof MultiResolutionImage)) {
        throw new RuntimeException("Not a MultiResolutionImage");
    }

    MultiResolutionImage multiResolutionImage
        = (MultiResolutionImage) image;

    Image image1x = multiResolutionImage.getResolutionVariant(
        IMAGE_WIDTH, IMAGE_HEIGHT);
    Image image2x = multiResolutionImage.getResolutionVariant(
        2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT);

    if (image1x.getWidth(null) * 2 != image2x.getWidth(null)
        || image1x.getHeight(null) * 2 != image2x.getHeight(null)) {
        throw new RuntimeException("Wrong resolution variant size");
    }
}
 
Example #28
Source File: MultiResolutionImageSupport.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
public static Image getResolutionVariant( Image image, int destImageWidth, int destImageHeight ) {
	return (image instanceof MultiResolutionImage)
		? ((MultiResolutionImage)image).getResolutionVariant( destImageWidth, destImageHeight )
		: image;
}
 
Example #29
Source File: MultiResolutionImageSupport.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
public static List<Image> getResolutionVariants( Image image ) {
	return (image instanceof MultiResolutionImage)
		? ((MultiResolutionImage)image).getResolutionVariants()
		: Collections.singletonList( image );
}
 
Example #30
Source File: MultiResolutionImageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static void testToolkitMultiResolutionImage(Image image,
    boolean enableImageScaling) 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");
    }

    final BufferedImage bufferedImage1x = new BufferedImage(IMAGE_WIDTH,
        IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics2D g1x = (Graphics2D) bufferedImage1x.getGraphics();
    setImageScalingHint(g1x, false);
    g1x.drawImage(image, 0, 0, null);
    checkColor(bufferedImage1x.getRGB(3 * IMAGE_WIDTH / 4,
        3 * IMAGE_HEIGHT / 4), false);

    Image resolutionVariant = ((MultiResolutionImage) image).
        getResolutionVariant(2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT);

    if (resolutionVariant == null) {
        throw new RuntimeException("Resolution variant is null");
    }

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

    final BufferedImage bufferedImage2x = new BufferedImage(2 * IMAGE_WIDTH,
        2 * IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2x = (Graphics2D) bufferedImage2x.getGraphics();
    setImageScalingHint(g2x, enableImageScaling);
    g2x.drawImage(image, 0, 0, 2 * IMAGE_WIDTH,
        2 * IMAGE_HEIGHT, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, null);
    checkColor(bufferedImage2x.getRGB(3 * IMAGE_WIDTH / 2,
        3 * IMAGE_HEIGHT / 2), enableImageScaling);

    if (!(image instanceof MultiResolutionImage)) {
        throw new RuntimeException("Not a MultiResolutionImage");
    }

    MultiResolutionImage multiResolutionImage
        = (MultiResolutionImage) image;

    Image image1x = multiResolutionImage.getResolutionVariant(
        IMAGE_WIDTH, IMAGE_HEIGHT);
    Image image2x = multiResolutionImage.getResolutionVariant(
        2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT);

    if (image1x.getWidth(null) * 2 != image2x.getWidth(null)
        || image1x.getHeight(null) * 2 != image2x.getHeight(null)) {
        throw new RuntimeException("Wrong resolution variant size");
    }
}