title: Retrieve Image (byte array) from sql database and show the Image
body: <p>In my wpf mvvm application I write a code for image upload and save to database.
  The code is working fine and the image save to the data base.
  Here I need to retrieve the image from the database and show in a Image box.Here is my Insert code</p>
  
  <pre><code>public void Upload(object obj)
  {
      try
      {
          Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
          dlg.DefaultExt = ".png";
          dlg.Filter = "Image files (*.png;*.jpg)|*.png;*.jpg";
          Nullable&lt;bool&gt; result = dlg.ShowDialog();
          if (result == true)
          {
              string filename = dlg.FileName;
              UploadText = filename;
              FileStream FS = new FileStream(filename, FileMode.Open, FileAccess.Read);
              byte[] img = new byte[FS.Length];
              FS.Read(img, 0, Convert.ToInt32(FS.Length));
              UploadLogo = img;
              Stream reader = File.OpenRead(filename);
              System.Drawing.Image photo = System.Drawing.Image.FromStream((Stream)reader);
              MemoryStream finalStream = new MemoryStream();
              photo.Save(finalStream, ImageFormat.Png);
              // translate to image source
              PngBitmapDecoder decoder = new PngBitmapDecoder(finalStream, BitmapCreateOptions.PreservePixelFormat,
                                                  BitmapCacheOption.Default);
              ClientLogo = decoder.Frames[0]; ;
          }
      }
  
      catch (Exception ex)
      {
          throw ex;
      }
  }
  </code></pre>
  
  <p>how can I convert this byte data to image </p>
  
  <p>Thanks in advance</p>