Path: blob/master/test/jdk/sun/awt/shell/BadHiDPIIcon.java
41149 views
/*1* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 815138526* @summary JOptionPane icons are cropped on Windows 10 with HiDPI display27* @author Hendrik Schreiber28* @requires os.family == "windows"29* @modules java.desktop/sun.awt.shell30* @run main BadHiDPIIcon31*/32import java.awt.Image;33import java.awt.image.BufferedImage;34import java.awt.image.MultiResolutionImage;35import sun.awt.shell.ShellFolder;3637public class BadHiDPIIcon {3839public static void main(String[] args) {40// the error icon is round and in all four corner transparent41// we check that all corners are identical42Image icon = (Image) ShellFolder.get("optionPaneIcon Error");43final BufferedImage image = getBufferedImage(icon);44final int upperLeft = image.getRGB(0, 0);45final int upperRight = image.getRGB(image.getWidth() - 1, 0);46final int lowerLeft = image.getRGB(0, image.getHeight() - 1);47final int lowerRight = image.getRGB(image.getWidth() - 1, image.getHeight() - 1);48if (upperLeft != upperRight || upperLeft != lowerLeft || upperLeft != lowerRight) {49throw new RuntimeException("optionPaneIcon Error is not a round icon with transparent background.");50}51}5253private static BufferedImage getBufferedImage(Image image) {54if (image instanceof MultiResolutionImage) {55MultiResolutionImage mrImage = (MultiResolutionImage) image;56return (BufferedImage) mrImage.getResolutionVariant(32, 32);57}58return (BufferedImage) image;59}60}616263