Ejemplo n.º 1
0
        internal void LoadImageAsync(FileRenameInfo data, bool applyExifRotation = true)
        {
            Dispatcher.Invoke((Action)(() =>
            {
                var filename = data.GetFileName();
                var rotation = applyExifRotation ? GetRotation(data.Exif) : 0.0;

                // load image
                var image = new BitmapImage();
                try
                {
                    using (var stream = File.OpenRead(filename))
                    {
                        image.BeginInit();
                        image.StreamSource = stream;
                        image.CacheOption = BitmapCacheOption.OnLoad;
                        image.EndInit(); // load the image from the stream
                    }

                    SetValue(ImageProperty, image);
                    SetValue(RotationProperty, rotation);
                }
                catch (Exception ex)
                {
                    // An error occurred while loading the image file (maybe it does not exist any more...)
                    // Let's make an image indicating the problem.
                    SetValue(ImageProperty, CreateErrorImage(ex));
                }
            }));
        }
Ejemplo n.º 2
0
        internal void LoadImageAsync(FileRenameInfo data, bool applyExifRotation = true)
        {
            Dispatcher.Invoke((Action)(() =>
            {
                var filename = data.GetFileName();
                var rotation = applyExifRotation ? GetRotation(data.Exif) : 0.0;

                // load image
                var image = new BitmapImage();
                using (var stream = File.OpenRead(filename))
                {
                    image.BeginInit();
                    image.StreamSource = stream;
                    image.CacheOption = BitmapCacheOption.OnLoad;
                    image.EndInit(); // load the image from the stream
                }

                SetValue(ImageProperty, image); //WpfHelper.ReadBitmapSource(filename));
                SetValue(RotationProperty, rotation);
            }));
        }
Ejemplo n.º 3
0
        internal void LoadImageAsync(FileRenameInfo data, bool applyExifRotation = true)
        {
            Dispatcher.Invoke((Action)(() =>
            {
                var filename = data.GetFileName();
                var rotation = applyExifRotation ? GetRotation(data.Exif) : 0.0;

                // load image
                var image = new BitmapImage();
                using (var stream = File.OpenRead(filename))
                {
                    image.BeginInit();
                    image.StreamSource = stream;
                    image.CacheOption = BitmapCacheOption.OnLoad;
                    image.EndInit(); // load the image from the stream
                }

                SetValue(ImageProperty, image); //WpfHelper.ReadBitmapSource(filename));
                SetValue(RotationProperty, rotation);
            }));
        }