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

Discussion in 'Android Questions' started by tigrot, May 5, 2015.

  1. tigrot

    tigrot Well-Known Member Licensed 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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There are several ways to do it. The simplest is to create a temporary file and write the new bytes with RandomAccessFile.WriteBytes.
     
  3. tigrot

    tigrot Well-Known Member Licensed User

    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: May 6, 2015
  4. tigrot

    tigrot Well-Known Member Licensed User

    Ops Phil is his name..
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Performance will not be an issue in this case.
     
  6. tigrot

    tigrot Well-Known Member Licensed 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...
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice