Dr Super Good
Spell Reviewer
- Joined
- Jan 18, 2005
- Messages
- 27,285
Finally got around to finishing my Java IIO ImageReader and ImageWriter plugin for BLP files.
One can check out the source on GitHub.
This is by far the most compatible BLP0/1 reader and writer for Java one can get at the moment.
Both ImageReader and ImageWriter exist. As this is a plugin all one needs is to place the JAR file somewhere in the path and it will automatically be used by the standard Image IO API. Outside of some implementation specific features the ImageReader can be used without needing to link to any of the implementation classes.
Performance is pretty reasonable from rough tests performed. It can read every mipmap level of every image in Warcraft III in less than a minute.
With a JAR of the plugin placed anywhere along the Java path one can read a BufferedImage from a BLP file as simply as...
Reading of mipmap levels from appropriate BLP files is also supported...
It supports both BLP0 (Warcraft III Reign of Chaos beta) and BLP1 (all release versions of Warcraft III). BLP0 files have to be read from either a File or Path due requiring accompanying files.
Like wise one can write images using it. It will automatically generate mipmaps by default. All one has to do to write a usable BLP version 1 file is...
One can check out the source on GitHub.
This is by far the most compatible BLP0/1 reader and writer for Java one can get at the moment.
Both ImageReader and ImageWriter exist. As this is a plugin all one needs is to place the JAR file somewhere in the path and it will automatically be used by the standard Image IO API. Outside of some implementation specific features the ImageReader can be used without needing to link to any of the implementation classes.
Performance is pretty reasonable from rough tests performed. It can read every mipmap level of every image in Warcraft III in less than a minute.
With a JAR of the plugin placed anywhere along the Java path one can read a BufferedImage from a BLP file as simply as...
Code:
File blpFile = new File(...);
BufferedImage img = ImageIO.read(blpFile);
Code:
ImageReader reader = ImageIO.getImageReadersByFormatName("blp").next();
File blpFile = new File(...);
ImageInputStream iis = ImageIO.createImageInputStream(blpFile)
reader.setInput(iis, true, true);
final int imageNum = reader.getNumImages(true);
for (int i = 0; i < imageNum; i += 1) {
BufferedImage img = reader.read(i);
}
Code:
ImageReader reader = ImageIO.getImageReadersByFormatName("blp").next();
File blp0File = new File(...);
reader.setInput(blp0File, true, true);
BufferedImage img = reader.read(0);
Code:
BufferedImage img = ...;
File blpFile = new File(...);
ImageIO.write(img, "blp", blpFile);
Last edited: