Ah yes, if you're sending to a server, you will need to encode it as some format. Note, however, that the PNG encoder code you have does not compress the image. It only encodes it. It will not make the data smaller.
You can create the four byte arrays like:
Code:
// get pixel data
int width = img.getWidth();
int height = img.getHeight();
int[] pixels = new int[width * height];
img.getRGB(pixels, 0, width, 0, 0, width, height);
// separate channels
byte[] red = new byte[pixels.length];
byte[] green = new byte[pixels.length];
byte[] blue = new byte[pixels.length];
byte[] alpha = new byte[pixels.length];
for (int i = 0; i < pixels.length; i++) {
int argb = pixels[i];
alpha[i] = (byte) (argb >> 24);
red[i] = (byte) (argb >> 16);
green[i] = (byte) (argb >> 8);
blue[i] = (byte) (argb);
}
Graham.