Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Send a BufferedImage object with Netty

 
keith nope
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2685
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2685
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic