@Nullable
public static Color getColorAt(final Icon icon, final int x, final int y) {
if (0 <= x && x < icon.getIconWidth() && 0 <= y && y < icon.getIconHeight()) {
final BufferedImage image = createImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
icon.paintIcon(null, image.getGraphics(), 0, 0);
final int[] pixels = new int[1];
final PixelGrabber pixelGrabber = new PixelGrabber(image, x, y, 1, 1, pixels, 0, 1);
try {
pixelGrabber.grabPixels();
return new Color(pixels[0]);
}
catch (InterruptedException ignored) {
}
}
return null;
}
UIUtil.java 文件源码
java
阅读 36
收藏 0
点赞 0
评论 0
项目:intellij-ce-playground
作者:
评论列表
文章目录