title: Show image from database as byte[] in silverlight
body: <p>i get image from client convert it to byte[] and send it to server. And convert byte[] to Base64String and insert into database.</p>
  
  <p>And i do reverse to show image. But i cant see the image. Why???</p>
  
  <pre><code>//Convert to byte array
   public static byte[] ImageToByteArray(WriteableBitmap bitmap)
  
  {
              int[] p = bitmap.Pixels;
              int len = p.Length &lt;&lt; 2;
              byte[] result = new byte[len];
              Buffer.BlockCopy(p, 0, result, 0, len);
              return result;
  }
  
  //Converter
  public object Convert(object value, Type targetType, object parameter,System.Globalization.CultureInfo culture)
          {
              if (value == null)
              {
                  return null;
              }
  
              BitmapImage image = new BitmapImage();
  
              MemoryStream stream = new MemoryStream();
              stream.Write((byte[])value, 0, ((byte[])value).Length);
              image.SetSource(stream);
  
  
              return image;
          }
  
  //While writing to database
  else if (value.GetType() == typeof(byte[]))
              {
                  return "'" + Convert.ToBase64String((byte[])value) + "'";
              }
  
  else if ((type == typeof(byte[])))
              {
                  return Convert.FromBase64String((string)value);
              }
  </code></pre>