title: Byte Array to Bitmap Image
body: <p>I made this code to receive an image and convert it to bitmap image but it doesn't work.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>public void ReceiveImage()
  {
      NetworkStream stream = new NetworkStream(socket);
      byte[] data = new byte[4];
      stream.read(data,0,data.length,0)
      int size = BitConverter.ToInt32(data,0);
      data = new byte[size];
      stream.read(data,0,data.length)
      MemoryStream imagestream = new MemoryStream(data);
      Bitmap bmp = new Bitmap(imagestream);
      picturebox1.Image = bmp;
  }
  </code></pre>
  
  <p>It gets to:</p>
  
  <pre><code>Bitmap bmp = new Bitmap(imagestream);
  </code></pre>
  
  <p>And gives me this error:</p>
  
  <blockquote>
    <p>Parameter is not valid</p>
  </blockquote>