title: Still SkImageDecoder::Factory returned null after read all of inputstream
body: <p>I am trying to sent a screenshot from desktop to android, and display on android. As I know returned null maybe cause I did not inputStream.read() read all of inputstream, therefore I  made a while loop to read all of them then to display. The desktop also sent the size of byte array, in order to let android set the size of byte array, here is the code:</p>
  
  <pre><code>public class connection extends AsyncTask {
      private byte[] data;
  
      public void setByteSize(int size) {
          data = new byte[size];
  
      }
  
      public byte[] getByteSize() {
          return data;
  
      }
  
      @Override
      protected Object doInBackground(Object... arg0) {
  
          try {
              clientSocket = new Socket("134.129.125.126", 8080);
              System.out.println("client connect to server");
              input = clientSocket.getInputStream();
              System.out.println("getinputstream");
          } catch (UnknownHostException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          } catch (IOException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          }
  
          while (true) {
              int totalBytesRead = 0;
              int chunkSize = 0;
              int tempRead = 0;
              String msg = null;
              // byte[] data = null;
  
              byte[] tempByte = new byte[1024 * 1024 * 4];
              try {
                  // read from the inputstream
                  tempRead = input.read(tempByte);
                  // tempbyte has x+4 byte
  
                  System.out.println("Fist time read:" + tempRead);
                  // convert x+4 byte into String
  
                  String message = new String(tempByte, 0, tempRead);
                  msg = message.substring(0, 4);
                  // cut the header into imageMsg
                  String imageMsg = new String(tempByte, 4, tempRead - 4);
                  // convert string into byte
                  System.out.println("message head:" + msg);
                  byteSize = Integer.parseInt(msg);
                  System.out.println("ByteSize:" + byteSize);
                  data = imageMsg.getBytes();
                  setByteSize(byteSize);
  
                  totalBytesRead = tempRead - 4;
                  System.out.println("total Byte Read=" + totalBytesRead);
  
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              }
  
              // get string for the size of image
  
              try {
                  int tmp = 0;
  
                  while (chunkSize &gt; -1) {
                      System.out.println("data length:"
                              + getByteSize().length);
                      chunkSize = input.read(getByteSize(), totalBytesRead,
                              getByteSize().length - totalBytesRead);
                      System.out.println("chunkSize is " + chunkSize);
                      System.out.println("iteration id = " + tmp);
                      tmp++;
                      totalBytesRead += chunkSize;
                      // System.out.println("Total byte read "
                      // + totalBytesRead);
                      if (totalBytesRead == getByteSize().length) {
                          break;
  
                      }
                  }
  
                  System.out.println("Complete reading - total read = "
                          + totalBytesRead);
              } catch (Exception e) {
  
              }
  
              bitmap = BitmapFactory.decodeByteArray(getByteSize(), 0,
                      getByteSize().length);
  
              System.out.println("deco");
  
              runOnUiThread(new Runnable() {
                  public void run() {
  
                      image.setImageBitmap(bitmap);
                      System.out.println("setImage at less than 500");
  
                  }
              });
          }
  
      }
  
  }
  </code></pre>
  
  <p>This is my decode result, I think I already read all of them, but it still do not allow me return a image</p>
  
  <pre><code>10-21 23:25:15.203: I/System.out(7222): Fist time read:1452
  10-21 23:25:15.203: I/System.out(7222): message head:3359
  10-21 23:25:15.203: I/System.out(7222): ByteSize:3359
  10-21 23:25:15.203: I/System.out(7222): total Byte Read=1448
  10-21 23:25:15.203: I/System.out(7222): data length:3359
  10-21 23:25:15.203: I/System.out(7222): chunkSize is 1911
  10-21 23:25:15.203: I/System.out(7222): iteration id = 0
  10-21 23:25:15.213: I/System.out(7222): Complete reading - total read = 3359
  10-21 23:25:15.213: D/skia(7222): --- SkImageDecoder::Factory returned null
  </code></pre>