我想知道是否有一种方法可以将 ImageIcon[] 转换为一系列缓冲图像,我的想法是这样的:
public BufferedImage iconArrayToBufferedImage(ImageIcon[] icon){
for (int i = 0; i < icon.length; i++) {
BufferedImage screenShot = new BufferedImage(icon[i]);
}
return screenShot;
}
最佳答案
E.G.如this answer中所示.
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/12533543/