title: Generating thumbnail images in WPF
body: <p>How do I generate a thumbnail image in WPF in the following scenario? </p>
  
  <pre><code>       using (MemoryStream mem = new MemoryStream(imgbytes))
              {
                  BitmapImage jpgimage = new BitmapImage();
                  jpgimage.BeginInit();
  
                  jpgimage.CacheOption = BitmapCacheOption.OnLoad;
  
                  jpgimage.StreamSource = mem;
  
                  jpgimage.EndInit();
  
                  Image wpfimage = new Image();
                  wpfimage.Source = jpgimage.Clone();
  
                  lbx.Items.Add(wpfimage);
                  lbx.UpdateLayout();
                  Thread.Sleep(1000);
              }
  </code></pre>