Dear Stefano,
Use PixelGrabber to get an array of bytes (for IndexColorModel) or integers
(standard RGB); send the array, and use MemoryImageSource to re-assemble on
the other end. Image is not a serializable class - I can't imagine why.
If you must use object streams, wrap the pixels and red, green, blue, alpha
in a class of your own that is declared serializable. Another way to do it
is to paint the image on a Canvas (or other component) and serialize that,
since all components are serializable.
Hope this helps,
Peter Johnson
[EMAIL PROTECTED]
Stefano Fratini wrote:
> Hallo,
> I'm writing a Java server application which sends (via socket) an image
> to an applet.
> I'm trying to use
> ObjectOutputStream out = new
> ObjectOutputStream(socket.getOutputStream());
> Image img = Toolkit.getDefaultToolkit().getImage("...");
> out.writeObject(img);
> in server side and
> ObjectInputStream in = new
> ObjectInputStream(socket.getInputStream());
> Image img = (Image)in.readObject();
> in client side.
>
> When programs run on my computer (linux RH5.0, jdk1.1.5)
> they give me this error sending image:
> java.io.WriteAbortedException: Writing aborted by exception;
> java.io.NotSerializableException: sun.awt.windows.WImage
>
> What is wrong?
> Does anyone know if there is a better way to send image via socket?
>
> Thanks,
>
> stf