Exemple #1
0
        /// <summary>
        /// Open file for reading.
        /// </summary>
        /// <returns>The opened file.</returns>
        /// <param name="Path">Path to the file.</param>
        /// <param name="numberGetter">Delegate that generates the image numbers in a MEF FITS.</param>
        public static MMapFitsFile OpenReadFile(string Path, MEFImageNumberGetter numberGetter = null)
        {
            FileInfo         info = new FileInfo(Path);
            MemoryMappedFile mmap = MemoryMappedFile.CreateFromFile(Path, FileMode.Open, Guid.NewGuid().ToString(), 0, MemoryMappedFileAccess.Read);

            Stream          stream  = mmap.CreateViewStream(0, 0, MemoryMappedFileAccess.Read);
            FitsFileBuilder builder = HeaderIO.ReadFileHeaders(stream, info.Length, numberGetter);

            stream.Dispose();

            return(new MMapFitsFile(Path, false, numberGetter, builder, mmap, MemoryMappedFileAccess.Read));
        }
        /// <summary>
        /// Opens a file from the given stream.
        /// </summary>
        /// <returns>The opened file.</returns>
        /// <param name="str">Input stream.</param>
        /// <param name="Length">Data length.</param>
        /// <param name="Path">Path to the data.</param>
        /// <param name="numberGetter">MEF naming policy.</param>
        public static NSStreamFitsFile OpenFile(Stream str, int Length, string Path, MEFImageNumberGetter numberGetter = null)
        {
            byte[] Data = new byte[Length];
            str.Read(Data, 0, Data.Length);

            FitsFileBuilder Headers;

            using (MemoryStream ms = new MemoryStream(Data))
                Headers = HeaderIO.ReadFileHeaders(ms, Length, numberGetter);

            return(new NSStreamFitsFile(Data, Path, false, numberGetter, Headers));
        }