Click to See Complete Forum and Search --> : Raster/DataBuffer via network ?


Oceansoul
April 8th, 2008, 08:47 AM
Hi there,

I got the following problem.
I created a small client-server architecture. The server reads images from a webcam. Now a client can open a connection to the server and request an actual image to be sent his way. So far this works all right. Only that, at the moment, I am using object streams to do that (sending an Image object).

But what Iīd like to do is converting the Image to a BufferedImage (which also works already) and then send the raw data via the network (Raster->DataBuffer). But I sincerely have now idea how to do that. How do I go about writing and reading such files/data?

I actually donīt know if that will be faster or better. Or if there is an even better way to do that.

Any help is greatly appreciated. I am pretty new to Java.

Oceansoul

Dash_Riprock
April 9th, 2008, 06:22 PM
Well... have you tried just calling BufferedImage.getData() , sending the returned Raster object the same way you are sending the Image object now, then calling the setData() method on the BufferedImage on the client side?

Oceansoul
April 10th, 2008, 07:41 AM
Hm, actually no. Iīll give that a try.
While searching for info in the web I came acrosse several code snippets regarding similar topics. And those seemed to suggest to do the streaming byte-wise (stream.writeByte() ...). So I assumed that was the way to go. Only I couldnīt adapt it to my specific problem (as described above).

Thanks.

Oceansoul