java.awt.image.BaseMultiResolutionImage Java Examples

The following examples show how to use java.awt.image.BaseMultiResolutionImage. 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: 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 #2
Source File: MultiResolutionCursorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new BaseMultiResolutionImage(
            createResolutionVariant(0),
            createResolutionVariant(1),
            createResolutionVariant(2),
            createResolutionVariant(3)
    );

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
Example #3
Source File: PressedIconTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void createAndShowGUI() {
    frame = new JFrame();
    frame.setSize(IMAGE_SIZE, IMAGE_SIZE);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel(new BorderLayout());

    BufferedImage img1x = generateImage(1, COLOR_1X);

    BufferedImage img2x = generateImage(2, COLOR_2X);
    BaseMultiResolutionImage mri = new BaseMultiResolutionImage(
            new BufferedImage[]{img1x, img2x});
    Icon mrIcon = new ImageIcon(mri);

    JToggleButton button = new JToggleButton();
    button.setIcon(mrIcon);
    panel.add(button, BorderLayout.CENTER);

    frame.getContentPane().add(panel);
    frame.setVisible(true);
}
 
Example #4
Source File: RepaintManagerFPUIScaleTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static Image createTestImage(int width, int height, int colorindex) {

        Color color = COLORS[colorindex % COLORS.length];

        AffineTransform tx = GraphicsEnvironment
                .getLocalGraphicsEnvironment()
                .getDefaultScreenDevice()
                .getDefaultConfiguration()
                .getDefaultTransform();

        Image baseImage = createTestImage(width, height, 1, 1, color);
        Image rvImage = createTestImage(width, height, tx.getScaleX(), tx.getScaleY(), color);

        return new BaseMultiResolutionImage(baseImage, rvImage);
    }
 
Example #5
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 #6
Source File: RepaintManagerFPUIScaleTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Image createTestImage(int width, int height, int colorindex) {

        Color color = COLORS[colorindex % COLORS.length];

        AffineTransform tx = GraphicsEnvironment
                .getLocalGraphicsEnvironment()
                .getDefaultScreenDevice()
                .getDefaultConfiguration()
                .getDefaultTransform();

        Image baseImage = createTestImage(width, height, 1, 1, color);
        Image rvImage = createTestImage(width, height, tx.getScaleX(), tx.getScaleY(), color);

        return new BaseMultiResolutionImage(baseImage, rvImage);
    }
 
Example #7
Source File: MultiResolutionRenderingHintsTest.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 {

        int length = COLORS.length;
        BufferedImage[] resolutionVariants = new BufferedImage[length];
        for (int i = 0; i < length; i++) {
            resolutionVariants[i] = createRVImage(getSize(i), COLORS[i]);
        }

        BaseMultiResolutionImage mrImage = new BaseMultiResolutionImage(
                resolutionVariants);

        // base
        Color color = getImageColor(VALUE_RESOLUTION_VARIANT_BASE, mrImage, 2, 3);
        if (!getColorForScale(1).equals(color)) {
            throw new RuntimeException("Wrong base resolution variant!");
        }

        // dpi fit
        color = getImageColor(VALUE_RESOLUTION_VARIANT_DPI_FIT, mrImage, 2, 3);
        if (!getColorForScale(2).equals(color)) {
            throw new RuntimeException("Resolution variant is not based on dpi!");
        }

        // size fit
        color = getImageColor(VALUE_RESOLUTION_VARIANT_SIZE_FIT, mrImage, 2, 3);
        if (!getColorForScale(6).equals(color)) {
            throw new RuntimeException("Resolution variant is not based on"
                    + " rendered size!");
        }

        // default
        // depends on the policies of the platform
        // just check that exception is not thrown
        getImageColor(VALUE_RESOLUTION_VARIANT_DEFAULT, mrImage, 2, 3);
    }
 
Example #8
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 #9
Source File: BaseMultiResolutionImageTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testIOOBException() {

        for (int baseImageIndex : new int[]{-3, 2, 4}) {
            try {
                new BaseMultiResolutionImage(baseImageIndex,
                        createRVImage(0), createRVImage(1));
            } catch (IndexOutOfBoundsException ignored) {
                continue;
            }

            throw new RuntimeException("IndexOutOfBoundsException is not thrown!");
        }
    }
 
Example #10
Source File: BaseMultiResolutionImageTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testNullRVIMage() {

        Image baseImage = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);

        try {
            new BaseMultiResolutionImage(baseImage, null);
        } catch (NullPointerException ignored) {
            return;
        }
        throw new RuntimeException("NullPointerException is not thrown!");
    }
 
Example #11
Source File: BaseMultiResolutionImageTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testNullRVIMages() {
    try {
        new BaseMultiResolutionImage(null);
    } catch (IllegalArgumentException ignored) {
        return;
    }
    throw new RuntimeException("IllegalArgumentException is not thrown!");
}
 
Example #12
Source File: BaseMultiResolutionImageTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testZeroRVIMages() {
    try {
        new BaseMultiResolutionImage();
    } catch (IllegalArgumentException ignored) {
        return;
    }
    throw new RuntimeException("IllegalArgumentException is not thrown!");
}
 
Example #13
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 #14
Source File: MultiResolutionDrawImageWithTransformTest.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 {

        int length = COLORS.length;
        BufferedImage[] resolutionVariants = new BufferedImage[length];
        for (int i = 0; i < length; i++) {
            resolutionVariants[i] = createRVImage(getSize(i), COLORS[i]);
        }

        BaseMultiResolutionImage mrImage = new BaseMultiResolutionImage(
                resolutionVariants);

        // scale 1, transform 1, resolution variant 1
        Color color = getImageColor(mrImage, 1, 1);
        if (!getColorForScale(1).equals(color)) {
            throw new RuntimeException("Wrong resolution variant!");
        }

        // scale 1, transform 2, resolution variant 2
        color = getImageColor(mrImage, 1, 2);
        if (!getColorForScale(2).equals(color)) {
            throw new RuntimeException("Wrong resolution variant!");
        }

        // scale 2, transform 1, resolution variant 2
        color = getImageColor(mrImage, 2, 1);
        if (!getColorForScale(2).equals(color)) {
            throw new RuntimeException("Wrong resolution variant!");
        }

        // scale 2, transform 2, resolution variant 4
        color = getImageColor(mrImage, 2, 2);
        if (!getColorForScale(4).equals(color)) {
            throw new RuntimeException("Wrong resolution variant!");
        }
    }
 
Example #15
Source File: PaintShop.java    From Carcassonne with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns a custom colored highlight image.
 * @param player determines the color of the highlight.
 * @param size is the edge length in pixels of the image.
 * @return the highlighted tile.
 */
public static ImageIcon getColoredHighlight(Player player, int size) {
    ImageIcon coloredImage = colorMaskBased(highlightBaseImage, highlightImage, player.getColor());

    Image small = coloredImage.getImage().getScaledInstance(size, size, Image.SCALE_SMOOTH);
    int largeSize = Math.min(size * 2, GameSettings.TILE_RESOLUTION);
    Image large = coloredImage.getImage().getScaledInstance(largeSize, largeSize, Image.SCALE_SMOOTH);

    return new ImageIcon(new BaseMultiResolutionImage(small, large));
}
 
Example #16
Source File: MultiResolutionRenderingHintsTest.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 {

        int length = COLORS.length;
        BufferedImage[] resolutionVariants = new BufferedImage[length];
        for (int i = 0; i < length; i++) {
            resolutionVariants[i] = createRVImage(getSize(i), COLORS[i]);
        }

        BaseMultiResolutionImage mrImage = new BaseMultiResolutionImage(
                resolutionVariants);

        // base
        Color color = getImageColor(VALUE_RESOLUTION_VARIANT_BASE, mrImage, 2, 3);
        if (!getColorForScale(1).equals(color)) {
            throw new RuntimeException("Wrong base resolution variant!");
        }

        // dpi fit
        color = getImageColor(VALUE_RESOLUTION_VARIANT_DPI_FIT, mrImage, 2, 3);
        if (!getColorForScale(2).equals(color)) {
            throw new RuntimeException("Resolution variant is not based on dpi!");
        }

        // size fit
        color = getImageColor(VALUE_RESOLUTION_VARIANT_SIZE_FIT, mrImage, 2, 3);
        if (!getColorForScale(6).equals(color)) {
            throw new RuntimeException("Resolution variant is not based on"
                    + " rendered size!");
        }

        // default
        // depends on the policies of the platform
        // just check that exception is not thrown
        getImageColor(VALUE_RESOLUTION_VARIANT_DEFAULT, mrImage, 2, 3);
    }
 
Example #17
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 #18
Source File: BaseMultiResolutionImageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testIOOBException() {

        for (int baseImageIndex : new int[]{-3, 2, 4}) {
            try {
                new BaseMultiResolutionImage(baseImageIndex,
                        createRVImage(0), createRVImage(1));
            } catch (IndexOutOfBoundsException ignored) {
                continue;
            }

            throw new RuntimeException("IndexOutOfBoundsException is not thrown!");
        }
    }
 
Example #19
Source File: BaseMultiResolutionImageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testNullRVIMage() {

        Image baseImage = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);

        try {
            new BaseMultiResolutionImage(baseImage, null);
        } catch (NullPointerException ignored) {
            return;
        }
        throw new RuntimeException("NullPointerException is not thrown!");
    }
 
Example #20
Source File: BaseMultiResolutionImageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testNullRVIMages() {
    try {
        new BaseMultiResolutionImage(null);
    } catch (IllegalArgumentException ignored) {
        return;
    }
    throw new RuntimeException("IllegalArgumentException is not thrown!");
}
 
Example #21
Source File: BaseMultiResolutionImageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testZeroRVIMages() {
    try {
        new BaseMultiResolutionImage();
    } catch (IllegalArgumentException ignored) {
        return;
    }
    throw new RuntimeException("IllegalArgumentException is not thrown!");
}
 
Example #22
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 #23
Source File: MultiResolutionDrawImageWithTransformTest.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 {

        int length = COLORS.length;
        BufferedImage[] resolutionVariants = new BufferedImage[length];
        for (int i = 0; i < length; i++) {
            resolutionVariants[i] = createRVImage(getSize(i), COLORS[i]);
        }

        BaseMultiResolutionImage mrImage = new BaseMultiResolutionImage(
                resolutionVariants);

        // scale 1, transform 1, resolution variant 1
        Color color = getImageColor(mrImage, 1, 1);
        if (!getColorForScale(1).equals(color)) {
            throw new RuntimeException("Wrong resolution variant!");
        }

        // scale 1, transform 2, resolution variant 2
        color = getImageColor(mrImage, 1, 2);
        if (!getColorForScale(2).equals(color)) {
            throw new RuntimeException("Wrong resolution variant!");
        }

        // scale 2, transform 1, resolution variant 2
        color = getImageColor(mrImage, 2, 1);
        if (!getColorForScale(2).equals(color)) {
            throw new RuntimeException("Wrong resolution variant!");
        }

        // scale 2, transform 2, resolution variant 4
        color = getImageColor(mrImage, 2, 2);
        if (!getColorForScale(4).equals(color)) {
            throw new RuntimeException("Wrong resolution variant!");
        }
    }
 
Example #24
Source File: MultiResolutionImageSupport.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
public static Image create( int baseImageIndex, Image... resolutionVariants ) {
	return new BaseMultiResolutionImage( baseImageIndex, resolutionVariants );
}
 
Example #25
Source File: MultiresolutionIconTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void UI() {

        setUndecorated(true);

        BufferedImage img1x = generateImage(SZ / 2, C1X);
        BufferedImage img2x = generateImage(SZ, C2X);
        BaseMultiResolutionImage mri = new BaseMultiResolutionImage(
            new BufferedImage[]{img1x, img2x});
        Icon icon = new ImageIcon(mri);

        // hardcoded icon size for OS X (Mac OS X L&F) - see JDK-8151060
        BufferedImage tab1x = generateImage(16, C1X);
        BufferedImage tab2x = generateImage(32, C2X);
        BaseMultiResolutionImage tabMRI = new BaseMultiResolutionImage(
            new BufferedImage[]{tab1x, tab2x});
        Icon tabIcon = new ImageIcon(tabMRI);

        setSize((N + 1) * SZ, SZ);
        setLocation(50, 50);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        getContentPane().setLayout(new GridLayout(1, 1));

        JPanel p = new JPanel();
        p.setLayout(new GridLayout(1, N));

        JButton btn = new JButton(icon);
        p.add(btn);

        JToggleButton tbn = new JToggleButton(icon);
        p.add(tbn);

        JRadioButton rbn = new JRadioButton(icon);
        rbn.setHorizontalAlignment(SwingConstants.CENTER);
        p.add(rbn);

        JCheckBox cbx = new JCheckBox(icon);
        cbx.setHorizontalAlignment(SwingConstants.CENTER);
        p.add(cbx);

        lbl = new JLabel(icon);
        p.add(lbl);

        tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
        tabbedPane.addTab("", tabIcon, p);
        getContentPane().add(tabbedPane);

        setResizable(false);
        setVisible(true);
    }
 
Example #26
Source File: MultiResolutionTrayIconTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static BaseMultiResolutionImage createIcon(int w, int h) {
    return new BaseMultiResolutionImage(
            new BufferedImage[]{generateImage(w, h, 1, Color.RED),
                generateImage(w, h, 2, Color.GREEN)});
}
 
Example #27
Source File: MultiResolutionTrayIconTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static BaseMultiResolutionImage createIcon(int w, int h) {
    return new BaseMultiResolutionImage(
            new BufferedImage[]{generateImage(w, h, 1, Color.RED),
                generateImage(w, h, 2, Color.GREEN)});
}
 
Example #28
Source File: MultiresolutionIconTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void UI() {

        setUndecorated(true);

        BufferedImage img1x = generateImage(SZ / 2, C1X);
        BufferedImage img2x = generateImage(SZ, C2X);
        BaseMultiResolutionImage mri = new BaseMultiResolutionImage(
            new BufferedImage[]{img1x, img2x});
        Icon icon = new ImageIcon(mri);

        // hardcoded icon size for OS X (Mac OS X L&F) - see JDK-8151060
        BufferedImage tab1x = generateImage(16, C1X);
        BufferedImage tab2x = generateImage(32, C2X);
        BaseMultiResolutionImage tabMRI = new BaseMultiResolutionImage(
            new BufferedImage[]{tab1x, tab2x});
        Icon tabIcon = new ImageIcon(tabMRI);

        setSize((N + 1) * SZ, SZ);
        setLocation(50, 50);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        getContentPane().setLayout(new GridLayout(1, 1));

        JPanel p = new JPanel();
        p.setLayout(new GridLayout(1, N));

        JButton btn = new JButton(icon);
        p.add(btn);

        JToggleButton tbn = new JToggleButton(icon);
        p.add(tbn);

        JRadioButton rbn = new JRadioButton(icon);
        rbn.setHorizontalAlignment(SwingConstants.CENTER);
        p.add(rbn);

        JCheckBox cbx = new JCheckBox(icon);
        cbx.setHorizontalAlignment(SwingConstants.CENTER);
        p.add(cbx);

        lbl = new JLabel(icon);
        p.add(lbl);

        tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
        tabbedPane.addTab("", tabIcon, p);
        getContentPane().add(tabbedPane);

        setResizable(false);
        setVisible(true);
    }
 
Example #29
Source File: ConcurrentTileImageScaler.java    From Carcassonne with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Returns the scaled multi-resolution image of a tile. This image therefore supports HighDPI graphics such as Retina on
 * Mac OS. This method is thread safe and leverages caching.
 * @param tile is the tile whose image is required.
 * @param size is the edge length of the (quadratic) image in pixels.
 * @param fastScaling specifies whether a fast scaling algorithm should be used.
 * @return the scaled multi-resolution {@link Image}.
 */
public static Image getScaledMultiResolutionImage(Tile tile, int size, boolean fastScaling) {
    int highDpiSize = Math.min(size * GameSettings.HIGH_DPI_FACTOR, GameSettings.TILE_RESOLUTION);
    Image defaultImage = getScaledImage(tile, size, fastScaling);
    Image highDpiImage = getScaledImage(tile, highDpiSize, fastScaling);
    return new BaseMultiResolutionImage(defaultImage, highDpiImage);
}
 
Example #30
Source File: Robot.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates an image containing pixels read from the screen.
 * This image does not include the mouse cursor.
 * This method can be used in case there is a scaling transform
 * from user space to screen (device) space.
 * Typically this means that the display is a high resolution screen,
 * although strictly it means any case in which there is such a transform.
 * Returns a {@link java.awt.image.MultiResolutionImage}.
 * <p>
 * For a non-scaled display, the {@code MultiResolutionImage}
 * will have one image variant:
 * <ul>
 * <li> Base Image with user specified size.
 * </ul>
 * <p>
 * For a high resolution display where there is a scaling transform,
 * the {@code MultiResolutionImage} will have two image variants:
 * <ul>
 * <li> Base Image with user specified size. This is scaled from the screen.
 * <li> Native device resolution image with device size pixels.
 * </ul>
 * <p>
 * Example:
 * <pre>{@code
 *      Image nativeResImage;
 *      MultiResolutionImage mrImage = robot.createMultiResolutionScreenCapture(frame.getBounds());
 *      List<Image> resolutionVariants = mrImage.getResolutionVariants();
 *      if (resolutionVariants.size() > 1) {
 *          nativeResImage = resolutionVariants.get(1);
 *      } else {
 *          nativeResImage = resolutionVariants.get(0);
 *      }
 * }</pre>
 * @param   screenRect     Rect to capture in screen coordinates
 * @return  The captured image
 * @throws  IllegalArgumentException if {@code screenRect} width and height are not greater than zero
 * @throws  SecurityException if {@code readDisplayPixels} permission is not granted
 * @see     SecurityManager#checkPermission
 * @see     AWTPermission
 *
 * @since 9
 */
public synchronized MultiResolutionImage
        createMultiResolutionScreenCapture(Rectangle screenRect) {

    return new BaseMultiResolutionImage(
            createCompatibleImage(screenRect, true));
}