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);
}
ImagePreProcessor.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:mtgo-best-bot
作者:
评论列表
文章目录