1

I'm writing a simple game using a data driven design in which I read in the images for the various elements of the game. As such I've written a parser to read-in the files, confirm that they're an acceptable image format, and create a new Sprite (class I've written) using the files.

I read in the files using ImageIO.read() as seen in the example below.

toAdd = new Sprite(ImageIO.read(targetFile));

The stack trace for the exception is as follows:

javax.imageio.IIOException: Can't create an ImageInputStream!
    at javax.imageio.ImageIO.read(ImageIO.java:1280)
    at edu.moravian.utilities.dataParsers.GraphicsDataParser.readInSprites(GraphicsDataParser.java:53)

I've got no idea what's causing this. The application isn't multi-threaded, the images are in the correct directory and are confirmed to exist, and I have the permissions necessary to access the images.

What might I be missing?

4

1 回答 1

0

一个可能的原因可能是您正在阅读使用 CMYK 颜色模型的 jpeg。ImageIO 默认不支持这些。

不过,有可能添加该功能。例如看看这个答案:https ://stackoverflow.com/a/16149142/6276704

于 2017-10-11T00:27:10.460 回答