Android Question Recompose a picture from a TCP/IP stream...

tigrot

Well-Known Member
Licensed User
Longtime User
Hi everybody,
I'm struggling to recompose a picture sent from a server to the Android phone. The connection is established and I get each chunch of the buffer in _NewData event as a byte array.
Which is the most efficient way to reconstruct the image and show on phone's screen?
Thank you in advance.
Mauro Zanin
 

tigrot

Well-Known Member
Licensed User
Longtime User
There are several ways to do it. The simplest is to create a temporary file and write the new bytes with RandomAccessFile.WriteBytes.
Thank you Erel. My idea is to load the image in a bigger array till the image is over. I have seen a growing kind of array(name took from Peter Collins' "A growin' kind of love"), maybe it's faster than a temp file??!!
SLByteArrayBuffer could be the answer, let's try...
Mauro
 
Last edited:
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
I have sutisfied my needs using a fixed length byte array(the image is never bigger than 64000bytes). I have loaded the bytes received in it using persistent counters, then when the buffer is filled, serialize it in a inputstream then assign to a bitmap. A few instructions and no need for SSD space.

Ciao...
 
Upvote 0
Top