Results 1 to 6 of 6
- 06-18-2012, 12:10 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 61
- Rep Power
- 0
- 06-18-2012, 05:34 PM #2
Re: How to send imagebuffer over socket?
What have you tried? How about writeObject()
What does the receiving side want? A java object or the bytes of an image?If you don't understand my response, don't ignore it, ask a question.
- 06-18-2012, 06:15 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: How to send imagebuffer over socket?
I'm not sure BufferedImage is serializable, so writeObject() won't work.
Please do not ask for code as refusal often offends.
- 06-18-2012, 06:29 PM #4
Re: How to send imagebuffer over socket?
Good point.
If you don't understand my response, don't ignore it, ask a question.
- 06-18-2012, 06:41 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
Re: How to send imagebuffer over socket?
Send over the RGB data (just an int array) and the type of the BufferedImage and its dimensions (just three single ints) and construct a new BufferedImage on the other side.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 06-19-2012, 01:31 AM #6
Re: How to send imagebuffer over socket?
yeah, and those could be stored in a object and send it, instead of sending four objects.
Java Code:public class BufferedImageInformation implements java.io.Serializable { private static final long serialVersionUID = 1L; private byte[] pixels; private int height; private int width; private int type; private BufferedImageInformation () {} public static BufferedImageInformation createInstance (BufferedImage image) { BufferedImageInformation bii = new BufferedImageInformation (); bii.pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData(); bii.height = image.getHeigth(); bii.width ... //You get the rest } public static BufferedImage decode (BufferedImageInformation bii) { ... //Decode it into a BufferedImage } }
Similar Threads
-
How to send a file over socket?
By ludo0777 in forum NetworkingReplies: 1Last Post: 06-06-2012, 05:53 PM -
How to send an object over a socket?
By nousername in forum New To JavaReplies: 3Last Post: 05-31-2011, 06:18 AM -
to send float array with TCP socket
By zeyneqp in forum NetworkingReplies: 6Last Post: 08-30-2008, 03:48 AM -
Send an array via Socket
By lene in forum NetworkingReplies: 0Last Post: 04-23-2008, 04:29 PM -
send files through socket
By bbq in forum Advanced JavaReplies: 1Last Post: 06-05-2007, 02:08 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks