mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Tolerate missing resources
This commit is contained in:
@@ -2456,17 +2456,19 @@ public class UIUtil {
|
||||
|
||||
@Nullable
|
||||
public static Color getColorAt(final Icon icon, final int x, final int y) {
|
||||
BufferedImage image = new BufferedImage(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 ignore) {
|
||||
if (0 <= x && x < icon.getIconWidth() && 0 <= y && y < icon.getIconHeight()) {
|
||||
final BufferedImage image = new BufferedImage(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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user