Originally Posted by
ISAI
That's pretty damn cool, nice job Seven
Thanks
Just posted an example
Example dumping interface child sprites (group 5)
Code:
for(int index = 0; index < Widget.widgets.length; index++) {
Widget widget = Widget.widgets[index];
if (widget == null) {
continue;
}
if (widget.defaultSprite != null) {
FileUtils.writeSprite(widget.defaultSprite, "./interfaces/default_sprites", widget.id + "_" + widget.group);
}
if (widget.secondarySprite != null) {
FileUtils.writeSprite(widget.secondarySprite, "./interfaces/secondary_sprites", widget.id + "_" + widget.group);
}
}
You can also write an image of the current producing raster and output that as well.
Code:
FileUtils.writeImage(Raster.raster, "./test", "test");
Code:
public static void writeImage(int[] raster, String directory, String output) {
final File dir = new File(directory);
if (!dir.exists()) {
dir.mkdirs();
}
if (raster == null) {
return;
}
if (Raster.width <= 0 || Raster.height <= 0) {
return;
}
final int[] data = raster;
if (data != null && data.length > 0) {
final BufferedImage image = new BufferedImage(Raster.width, Raster.height,
BufferedImage.TYPE_INT_RGB);
if (image != null) {
final int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
System.arraycopy(data, 0, pixels, 0, data.length);
try {
ImageIO.write(image, "png", new File(dir.toString() + File.separator + output + ".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
}