我正在尝试读取一个名为的 .bmp 文件circle1.bmp
。它位于我已导入以下文件的包中。
到目前为止,我有以下代码,但是当我运行以下代码时,我得到:
javax.imageio.llOException:无法读取输入文件!
public void setUp() throws IOException
{
BufferedImage image = ImageIO.read(new File("circle1.bmp"));
byte[][] greenInputData = new byte[30][40];
for (int x = 0; x < inputData.length; x++)
{
for (int y = 0; y < inputData[x].length; y++)
{
int color = image.getRGB(x, y);
//alpha[x][y] = (byte)(color>>24);
//red[x][y] = (byte)(color>>16);
greenInputData[x][y] = (byte)(color>>8);
//blue[x][y] = (byte)(color);
}
}
this.inputData = greenInputData;
System.out.println(this.inputData);
}
你应该尝试类似的东西
image = ImageIO.read(getClass().getResourceAsStream("path/to/your/file.bmp"));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)