我一直在试图将ImageIcon
转换为BufferedImage
......而且我没有运气。将ImageIcon转换为BufferedImage
我有一个预先存在的ImageIcon需要转换为BufferedImage操作存在的大量BufferedImage。
我发现了一些方法,但它们都是CPU密集型的。
我一直在试图将ImageIcon
转换为BufferedImage
......而且我没有运气。将ImageIcon转换为BufferedImage
我有一个预先存在的ImageIcon需要转换为BufferedImage操作存在的大量BufferedImage。
我发现了一些方法,但它们都是CPU密集型的。
出了什么问题:
BufferedImage bi = new BufferedImage(
icon.getIconWidth(),
icon.getIconHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics g = bi.createGraphics();
// paint the Icon to the BufferedImage.
icon.paintIcon(null, g, 0,0);
g.dispose();
我尝试一些所谓Scalr,查看下面
Scalr.resize((BufferedImage) ImageIO.read(file), Method.SPEED, 250, OP_ANTIALIAS, OP_BRIGHTER);
干杯的代码。
你真的读过这个问题吗? – 2013-02-24 15:30:21
见ImageIcon,Image和BufferedImage:
ImageIcon yourImage;
Image image = yourImage.getImage();
BufferedImage buffered = (BufferedImage) image;
非常有帮助非常感谢你,我以前就翻过这个方法,但很快其击落由于我immiediet假设,它会表现不佳,但后试试你的方式,这一切似乎工作正常。 – Caelum 2013-02-24 15:53:04
'BufferedImage.TYPE_INT_ARGB'如果图标中有透明像素。 – Matthieu 2017-02-23 16:47:19