本文整理汇总了Java中java.awt.image.BufferedImage.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.getSource方法的具体用法?Java BufferedImage.getSource怎么用?Java BufferedImage.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.BufferedImage
的用法示例。
在下文中一共展示了BufferedImage.getSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGrayscaledImage
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
public BufferedImage getGrayscaledImage(BufferedImage coloredImage) {
ImageFilter filter = new ImageFilter(){
public final int filterRGB(int x, int y, int rgb)
{
//TODO - optimization? Bit shifts, not this shits
Color currentColor = new Color(rgb);
if(currentColor.getRed() < 2 && currentColor.getGreen() < 2 && currentColor.getBlue() < 2) {
return new Color(rgb).darker().getRGB();
}
return Color.WHITE.getRGB();
}
};
ImageProducer producer = new FilteredImageSource(coloredImage.getSource(), filter);
Image image = Toolkit.getDefaultToolkit().createImage(producer);
return toBufferedImage(image);
}
示例2: getDisabledIcon
import java.awt.image.BufferedImage; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}