ReadImage() public static method

public static ReadImage ( Disposable stream, string file_name ) : Image
stream Disposable
file_name string
return Image
示例#1
1
        public static string DescribeAssemblyRuntime(string assemblyFile)
        {
            using (Stream stream = File.OpenRead(assemblyFile))
              {
            try
            {
              var reader = new ImageReader(stream);
              reader.ReadImage();
              Image img = reader.Image;

              var sb = new StringBuilder();
              sb.Append(img.Runtime);
              sb.Append(", ");
              if (img.Architecture == TargetArchitecture.AMD64 || img.Architecture == TargetArchitecture.IA64)
              {
            sb.Append("x64");
              }
              else if ((img.Attributes & ModuleAttributes.Required32Bit) != 0)
              {
            sb.Append("x86");
              }
              else
              {
            sb.Append("MSIL");
              }

              return sb.ToString();
            }
            catch (Exception e)
            {
              return "???";
            }
              }
        }
示例#2
0
 public static Image ReadImageFrom(Stream stream)
 {
     try {
         var reader = new ImageReader(stream);
         reader.ReadImage();
         return(reader.image);
     } catch (EndOfStreamException e) {
         throw new BadImageFormatException(stream.GetFullyQualifiedName(), e);
     }
 }
示例#3
0
 public static Image ReadImageFrom(Stream stream)
 {
     try {
         var reader = new ImageReader (stream);
         reader.ReadImage ();
         return reader.image;
     } catch (EndOfStreamException e) {
         throw new BadImageFormatException (stream.GetFullyQualifiedName (), e);
     }
 }
示例#4
0
 public static Image ReadImage(Disposable <Stream> stream, string file_name)
 {
     try {
         var reader = new ImageReader(stream, file_name);
         reader.ReadImage();
         return(reader.image);
     } catch (EndOfStreamException e) {
         throw new BadImageFormatException(stream.value.GetFileName(), e);
     }
 }
示例#5
0
 public static Image ReadImage(Disposable<Stream> stream, string file_name)
 {
     try {
         var reader = new ImageReader (stream, file_name);
         reader.ReadImage ();
         return reader.image;
     } catch (EndOfStreamException e) {
         throw new BadImageFormatException (stream.value.GetFileName (), e);
     }
 }
示例#6
0
        public static Image ReadImage(Disposable <Stream> stream, string file_name)
        {
            try {
                var reader = new ImageReader(stream, file_name);
                reader.ReadImage();
                return(reader.image);
            } catch (EndOfStreamException e) {
#if NET20 || NET35 // TestCentric
                throw new BadImageFormatException((stream.value as FileStream)?.Name, e);
#else
                throw new BadImageFormatException(stream.value.GetFileName(), e);
#endif
            }
        }
示例#7
0
        public static Image ReadImageFrom(Stream stream)
        {
            Image image;

            try
            {
                ImageReader reader = new ImageReader(stream);
                reader.ReadImage();
                image = reader.image;
            }
            catch (EndOfStreamException exception)
            {
                throw new BadImageFormatException(stream.GetFullyQualifiedName(), exception);
            }
            return(image);
        }