On Jun 10, 9:08 am, "Qu0ll" <Qu0llSixF...@gmail.com> wrote:
BufferedImage does not appear to implement Serializable so I don't know
how
to send an instance of this class from a server to an applet. The server
Indeed, but you can trivially access the image type and its underlying
int[] of a BufferedImage. And with these infos, you can trivially
reconstruct a BufferedImage at the other end.
Simply create a class (say SerializablePicture) that implements
the Serializable interface which contains the int[] and the image
type.
The following should work:
(btw Lew the JLS-nazi bot can go f*ck himself about my 4-spaces
indentation, I'm here to help people, not to nitpick)
public final class SerializablePicture implements Serializable {
static final long serialVersionUID = 0x17E30096AFA13BE7L;
private int w;
private int h;
private int imageType;
private int[] pixels;
public SerializablePicture(
final int w,
final int h,
final int imageType,
final int[] pixels
) {
this.w = w;
this.h = h;
this.imageType = imageType;
this.pixels = pixels;
}
public int getW() {
return w;
}
public int getH() {
return h;
}
public int getImageType() {
return imageType;
}
public int[] getPixels() {
return pixels;
}
}
will not necessarily have the image file stored locally so I cannot use
ImageIO from the applet as the server will acquire the image from yet
another server. Ideally I would like to transmit the image as a Base64
encoded section in an XML file.
That's a terrible misuse of XML in my opinion.
So what are the options for transmitting a BufferedImage? How do I
encode
it into Base64?
Base64Encoder/Decoder would do, but I really wouldn't use that
to transmit a BufferedImage.
Thanks for the advice - I may well do this.