rendered paste bodyimport java.io.*;
import javax.imageio.*;
import java.awt.image.*;
import java.awt.*;
public class Clip {
public static void main(String args[]) {
new Clip().clip();
}
public Clip() {}
public void clip() {
try {
FileInputStream in = new FileInputStream("Sprites.bmp");
BufferedImage fullImg = ImageIO.read(in);
/*for(int i = 0; i < fullImg.getWidth(); i++) {
for(int x = 0; x < fullImg.getHeight(); x++) {
if(isBlack(fullImg.getRGB(i, x)))
fullImg.setRGB(i, x, 0x00FFFFFF);
}
}*/
BufferedImage[][] images = new BufferedImage[fullImg.getHeight() / 32][(fullImg.getWidth() / 32) - 1];
for(int x = 0; x < images.length; x++) {
for(int i = 0; i < images[x].length; i++){
images[x][i] = fullImg.getSubimage(i * 32, x * 32, 32, 32);
}
}
byte[] buffer = new byte[(fullImg.getWidth() * fullImg.getHeight()) * 3];
int offset = 0;
for(int i = 0; i < images.length; i++) {
for(int x = 0; x < images[i].length - 1; x++) {
for(int p = 0; p < 32; p++) {
for(int l = 0; l < 32; l++) {
buffer[offset++] = (byte)((images[i][x].getRGB(p, l) >> 16) & 0xff);
buffer[offset++] = (byte)((images[i][x].getRGB(p, l) >> 8) & 0xff);
buffer[offset++] = (byte)(images[i][x].getRGB(p, l) & 0xff);
}
}
}
}
FileOutputStream out = new FileOutputStream("sprites.data");
out.write(buffer, 0, offset);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean isBlack(int argb) {
if(new Color(argb).equals(Color.BLACK))
return true;
return false;
}
}