public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var bytes = value as byte[];

            if (bytes == null || bytes.Length == 0)
                return DependencyProperty.UnsetValue;

            var image = new BitmapImage();

            using (Stream stream = new MemoryStream(bytes))
            {
                image.BeginInit();
                image.StreamSource = stream;
                image.CacheOption = BitmapCacheOption.OnLoad;
                image.EndInit();
            }

            if (!image.IsFrozen)
            {
                image.AddMemoryPressure();
                image.Freeze();
            }

            return image;
        }