ImageIO.write is dangerously slow and I guess that’s because it’s compressing the image to another format.
So how do I go about doing this, when size isn’t a factor?
The fastest method of writing an image. Do I grab all pixels and write them?
ImageIO.write is dangerously slow and I guess that’s because it’s compressing the image to another format.
So how do I go about doing this, when size isn’t a factor?
The fastest method of writing an image. Do I grab all pixels and write them?
TGA
it’s basically a header + dump of the pixels
Is there a faster way of getting all the pixels or do I just have to use
BufferedImage img = region.images[i];
int[] ARGB = new int[w * h];
img.getRGB(0, 0, w, h, ARGB, 0, w);
is there a way to avoid the integer array all together and write info directly to a byte array?
about a zillion times faster:
public static int[] accessRasterIntArray(BufferedImage src)
{
return ((DataBufferInt) src.getRaster().getDataBuffer()).getData();
}
public static byte[] accessRasterByteArray(BufferedImage src)
{
return ((DataBufferByte) src.getRaster().getDataBuffer()).getData();
}
public static byte[] accessRasterByteArray(BufferedImage src)
{
return ((DataBufferByte) src.getRaster().getDataBuffer()).getData();
}
I think that was exactly what I was looking for
thanks
btw: you can use BufferedImage().getType() to pick the correct backing DataBuffer
EDIT: Alright everything’s working