title: Converting varbinary to image in silverlight (part 2)
body: <p>I am trying to convert a varbinary to an image in my silverlight project.</p>
  
  <p>First I get the Binary from my database in my service.</p>
  
  <pre><code>    [OperationContract]
      public byte[] getAfbeelding(int id)
      {
  
          var query = (from p in dc.Afbeeldings
                       where p.id == id
                       select p.source).Single();
  
          byte[] source = query.ToArray();
  </code></pre>
  
  <p>Then I try to convert the varbinary to an image, using code found on StackOverflow: </p>
  
  <pre><code>    public static string convertToImage(byte[] source)
      {
          MemoryStream ms = new MemoryStream(source);
          Image img = Image.FromStream(ms);
          return img.Source.ToString();
      }
  </code></pre>
  
  <p>But as it turns out, the silverlight <code>Image</code> does not have a <code>.FromStream</code>, I tried all the examples found in <a href="https://stackoverflow.com/questions/5623264/how-to-convert-varbinary-into-image-or-video-when-retrieved-from-database-in-c-s">this thread</a> but NONE of them work in silverlight. </p>
  
  <pre><code>'System.Windows.Controls.Image' does not contain a definition for 'FromStream'
  </code></pre>
  
  <p>So yeah, I'm kinda lost and am not sure what to do.
  Any ideas on how to do this in silverlight?</p>