Reputation: 164
I'm using a sprite sheet and have it set up to get the pixel int[] of each sprite, I'm just not sure how to use that pixel int[] to make a seperate image.
my code:
i=0;
BufferedImage[] bi = new BufferedImage[];
for(y) {
for (x) {
int[] pixels = null;
Vars.TILE_SHEET_BI().getRaster().getPixels(x, y, 16, 16, pixels);
bi[i] = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
bi[i].getRaster().setPixels(0, 0, 16, 16, pixels);
i++;
}
}
Upvotes: 4
Views: 225
Reputation: 285430
Why not simply call getSubImage(...)
on the BufferedImage? I know that that is what I'd do, and in fact what I've done.
For example, please see the code for my answer to this question.
Which takes this Sprite Sheet:
and creates this GUI with it:
Upvotes: 5