0

我正在尝试将 myBufferedImage转换为整数数组,但出现以下错误:“java.awt.image.DataBufferByte无法转换为java.awt.image.DataBufferInt

这是我的一段代码:

public class Test {
  public static void main (String []  args) { 
    BufferedImage img = null;
    try {
      img = ImageIO.read(new File("G.bmp"));
    } catch (IOException e) { }

    int[] imgarray = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
  }
}
4

1 回答 1

3

试试这个:

byte[] imgarray = ((DataBufferByte)img.getRaster().getDataBuffer()).getData();
于 2012-05-03T00:29:38.590 回答