コード例 #1
0
ファイル: BinaryImageConverter.cs プロジェクト: Kayomani/FAP
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value != null && value is byte[] )
     {
         try
         {
             byte[] ByteArray = value as byte[];
             if (ByteArray.Length == 0)
                 return null;
             BitmapImage bmp = new BitmapImage();
             bmp.BeginInit();
             bmp.StreamSource = new MemoryStream(ByteArray);
             bmp.EndInit();
             return bmp;
         }
         catch
         {
             return null;
         }
     }
     else if (value is string)
     {
         Base64Converter c = new Base64Converter();
         return Convert(c.Convert(value, targetType, parameter, culture), targetType, parameter, culture);
     }
     return null;
 }
コード例 #2
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value != null && value is byte[])
     {
         try
         {
             byte[] ByteArray = value as byte[];
             if (ByteArray.Length == 0)
             {
                 return(null);
             }
             BitmapImage bmp = new BitmapImage();
             bmp.BeginInit();
             bmp.StreamSource = new MemoryStream(ByteArray);
             bmp.EndInit();
             return(bmp);
         }
         catch
         {
             return(null);
         }
     }
     else if (value is string)
     {
         Base64Converter c = new Base64Converter();
         return(Convert(c.Convert(value, targetType, parameter, culture), targetType, parameter, culture));
     }
     return(null);
 }