title: How Can I Convert My new Byte Array To an Image
body: <p>i have write this code for extracting bitplane1 of my image . but i have exceptions.
  actually i get an image and convert it to a byte array so after i change this byte array i want to convert this new byte array to image ? could you please give me some advice ? best regards 
  (actually i want extract bitplane1 of my image)
  any suggestion ?</p>
  
  <p>my code is :</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using System.IO;
  using System.Collections;
  
  
  namespace bitplane
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
  
      {
        //  Image grayImage;
          OpenFileDialog o = new OpenFileDialog();
          o.ShowDialog();
  
          byte[] x = File.ReadAllBytes(o.FileName);
  
          byte maskbyte1 = 2;
          int [] newpix= new int [x.Length];
      for (int i = 0; i &lt; x.Length; i++)
         {
  
  
             newpix[i] = x[i] &amp; maskbyte1;
  
             string px=newpix[i].ToString();
  
  
            x[i] = Convert.ToByte(px);
  
      }
          MemoryStream ms = new MemoryStream(x);
          Image myImage = Image.FromStream(ms);
  
      myImage.Save(@"C:\Users\Public\Pictures\Sample Pictures\New folder\fgh.jpg");
      }
      }
  }
  </code></pre>
  
  <hr>
  
  <p>my exception is for this line :</p>
  
  <p>Image myImage = Image.FromStream(ms);</p>
  
  <p>System.ArgumentException was unhandled
   Parameter is not valid.</p>