Cae*_*lum 10 java bufferedimage imageicon
我一直试图将一个转换ImageIcon为BufferedImage...而且我没有运气.
我有一个预先存在的ImageIcon,需要转换为缓冲图像,用于存在的大量BufferedImage操作.
我找到了几种方法,但所有方法都是CPU密集型的.
Wer*_*rås 33
有什么不对:
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();
Run Code Online (Sandbox Code Playgroud)
请参见ImageIcon,Image和BufferedImage:
ImageIcon yourImage;
Image image = yourImage.getImage();
BufferedImage buffered = (BufferedImage) image;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24332 次 |
| 最近记录: |