title: Error" Parameter is not valid " while converting Bytes into Image
body: <p>I am converting bytes into an image but I get an error </p>
  
  <blockquote>
    <p>Parameter is not valid </p>
  </blockquote>
  
  <p>I am pasting my code. Kindly check the code and suggested that was I am doing right or wrong.</p>
  
  <pre><code>Image arr1 = byteArrayToImage(Bytess);
  </code></pre>
  
  <p>This is the function.</p>
  
  <pre><code>public static Image byteArrayToImage(byte[] byteArrayIn)
  {
          if (null == byteArrayIn || byteArrayIn.Length == 0)
              return null;
  
          MemoryStream ms = new MemoryStream(byteArrayIn);
          try
            {
              Process currentProcess1 = Process.GetCurrentProcess();
              Image returnImage = Image.FromStream(ms);
              return returnImage;
            }
          catch (Exception ex)
            {
              MessageBox.Show(ex.Message);
            }
      }
  </code></pre>
  
  <p>I applied many techniques and solutions but it did not work for me  </p>
  
  <p>Your answer would be appreciated.</p>
  
  <p>Thanks</p>