Ejemplo n.º 1
0
        private static ImageSource _GetImageFromPhoto(Photo photo)
        {
            Stream stm = photo.ResolveToStream();

            if (null == stm)
            {
                // No Value and no useful Url.
                // Just return null and let the caller deal with it.
                return null;
            }

            var image = new BitmapImage();
            image.BeginInit();

            // CONSIDER: Don't need to load all of a giant image...
            //    (even though we already have the stream in memory)
            //
            // To keep aspect ratio don't set both width and height.
            // This doesn't guarantee a square, this is facebook behavior.
            //image.DecodePixelWidth = (int)size.Width;

            stm.Position = 0;
            image.StreamSource = stm;
            image.EndInit();

            return image;
        }