/** * Creates a gray version from an input image. Usually gray icon indicates disabled. If input image is null, a blank * ImageIcon will be returned. * * @param image image * @return gray version of the image */ public static ImageIcon createNegativeImage(Image image) { if (image == null) return EMPTY_ICON; return new ImageIcon(MaskFilter.createNegativeImage(image)); }
/** * Creates a negative version from an input black image which basically replaces black pixel with white pixel. * * @param c The component to get properties useful for painting, e.g. the foreground or background color. * @param icon icon * @return the negative version of the image */ public static ImageIcon createNegativeImage(Component c, Icon icon) { BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); icon.paintIcon(c, image.getGraphics(), 0, 0); return new ImageIcon(MaskFilter.createNegativeImage(image)); }