I don't need to write the png to disk -- I can just read the size direct from
the buffer. Here's why:
The big picture is
1. (Server) Create a BufferedImage, size 256x256
2. (Server) Instantiate a Graphics from the image and draw into it
3. (Server) Serialise the BufferedImage (using ImageIO) to send the data to a
client
4. (Client) Un-serialise the data (using ImageIO) back into a BufferedImage
5. (Client) Apply local changes to the BufferedImage
6. (Client) Blit BufferedImage onto user's screen
I've tried to describe steps 3+4. Obviously, I want this to be lossless.
The streams I'm providing to the ImageIO are backed by a ByteBuffer (which is
trivially serialisable).
I'm finding the data copied out of the buffer is between 5KB and 30KB, which
seems reasonable.
If BufferedImage implemented Serialisable, I would (probably) just use that.
My alternative is to hand-serialise BufferedImage, but I'm not very happy doing
that.
The problem appears at step 4, where the reconstructed BufferedImage is 4 times
the size it needs to be and my attempts to coerce ImageIO into doing The Right
Thing meet only exceptions.
Neil.
[Message sent by forum member 'nrg' (nrg)]
http://forums.java.net/jive/thread.jspa?messageID=261358