BinaryImageConverter.cs #1

  • //
  • guest/
  • christoph_leithner/
  • piper/
  • main/
  • windows/
  • R1.1/
  • Perforce/
  • View/
  • BinaryImageConverter.cs
  • View
  • Commits
  • Open Download .zip Download (1 KB)
//
// Copyright 2014 Perforce Software Inc.
//

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace Perforce.View {
    sealed class BinaryImageConverter : IValueConverter {
        object IValueConverter.Convert(object value,
            Type targetType,
            object parameter,
            System.Globalization.CultureInfo culture) {
            if (value != null && value is byte[]) {
                byte[] bytes = value as byte[];

                MemoryStream stream = new MemoryStream(bytes);

                BitmapImage image = new BitmapImage();
                image.BeginInit();
                image.StreamSource = stream;
                image.EndInit();

                return image;
            }

            return null;
        }

        object IValueConverter.ConvertBack(object value,
            Type targetType,
            object parameter,
            System.Globalization.CultureInfo culture) {
            throw new Exception("The method or operation is not implemented.");
        }
    }
}
# Change User Description Committed
#1 16817 christoph_leithner "Forking branch Main of perforce-software-piper to christoph_leithner-piper."
//guest/perforce_software/piper/main/windows/R1.1/Perforce/View/BinaryImageConverter.cs
#1 16507 perforce_software Move to main branch.
//guest/perforce_software/piper/windows/R1.1/Perforce/View/BinaryImageConverter.cs
#1 11256 alan_petersen Populate //guest/perforce_software/piper/windows/R1.1/...
from //guest/perforce_software/piper/windows/main/....
//guest/perforce_software/piper/windows/main/Perforce/View/BinaryImageConverter.cs
#1 11255 alan_petersen Rename/move file(s)
//guest/perforce_software/piper/windows/Perforce/View/BinaryImageConverter.cs
#1 10761 alan_petersen initial drop of Piper for Windows....

this version still has _many_ bugs (er... i mean "unintended features") but I will be updating it over the next week as more stability is added.