我一直在尝试将 ImageIcon
转换为 BufferedImage
...但我没有成功。
我有一个预先存在的 ImageIcon,需要将其转换为缓冲图像以用于现有的大量 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();
关于java - 将 ImageIcon 转换为 BufferedImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15053214/