aspose file tools*
The moose likes Distributed Java and the fly likes Send a BufferedImage object with Netty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Send a BufferedImage object with Netty" Watch "Send a BufferedImage object with Netty" New topic
Author

Send a BufferedImage object with Netty

keith nope
Greenhorn

Joined: Jan 14, 2012
Posts: 2
I am simply trying to send a bufferedimage object from one computer to another using Netty.

I am really having a tough time with the decoder/encoder. Mainly getting the bytes from the bufferedimage, but I have a feeling that this may not be the right way to go about it. I was looking at ChannelBufferInput/OutputStreams.

Any help is appreciated,
Thank You
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
BufferedImage is not Serializable, so you'd have to roll the code by hand. The easiest approach might be to use the javax.imageio.ImageIO class to write the image in a lossless format -like PNG- to an OutputStream (which, I assume, the I/O layer can handle).
keith nope
Greenhorn

Joined: Jan 14, 2012
Posts: 2
Thank you for the quick response!

write the image in a lossless format -like PNG-

Does this mean writing it to disk?



I've been poking around I found ObjectEncoder and ObjectDecoder, but I am starting to get very confused after looking at the different encoder/decoders.
I'm not sure how to implement this. I wish there was more example code

http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/codec/serialization/ObjectDecoder.html
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
keith nope wrote:
write the image in a lossless format -like PNG-

Does this mean writing it to disk?

No, you can write to a byte array in memory.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Send a BufferedImage object with Netty