示例#1
0
        public static MapHeader ReadFromFile(BinaryReader reader, FileInfo info, int2 headerlessSliceDims, long headerlessOffset, Type headerlessType)
        {
            MapHeader Header = null;

            if (info.Extension.ToLower() == ".mrc" || info.Extension.ToLower() == ".mrcs" || info.Extension.ToLower() == ".ali" || info.Extension.ToLower() == ".rec" || info.Extension.ToLower() == ".st")
            {
                Header = new HeaderMRC(reader);
            }
            else if (info.Extension.ToLower() == ".em")
            {
                Header = new HeaderEM(reader);
            }
            else if (info.Extension.ToLower() == ".tif" || info.Extension.ToLower() == ".tiff")
            {
                Header = new HeaderTiff(info.FullName);
            }
            else if (info.Extension.ToLower() == ".dat")
            {
                long SliceElements = headerlessSliceDims.Elements() * ImageFormatsHelper.SizeOf(headerlessType);
                long Slices        = (info.Length - headerlessOffset) / SliceElements;
                int3 Dims3         = new int3(headerlessSliceDims.X, headerlessSliceDims.Y, (int)Slices);
                Header = new HeaderRaw(Dims3, headerlessOffset, headerlessType);
            }
            else
            {
                throw new Exception("File type not supported.");
            }

            return(Header);
        }
示例#2
0
        public static MapHeader ReadFromFile(BinaryReader reader, string path, int2 headerlessSliceDims, long headerlessOffset, Type headerlessType, Stream stream = null)
        {
            MapHeader Header = null;
            string Extension = Helper.PathToExtension(path).ToLower();

            if (Extension == ".mrc" || Extension == ".mrcs" || Extension == ".rec" || Extension == ".st")
                Header = new HeaderMRC(reader);
            else if (Extension == ".em")
                Header = new HeaderEM(reader);
            else if (Extension == ".dm4" || Extension == ".dm3")
                Header = new HeaderDM4(reader);
            else if (Extension == ".tif" || Extension == ".tiff")
                Header = new HeaderTiff(path, stream);
            else if (Extension == ".eer")
                Header = new HeaderEER(path, stream);
            else if (Extension == ".dat")
            {
                FileInfo info = new FileInfo(path);

                long SliceElements = headerlessSliceDims.Elements() * ImageFormatsHelper.SizeOf(headerlessType);
                long Slices = (info.Length - headerlessOffset) / SliceElements;
                int3 Dims3 = new int3(headerlessSliceDims.X, headerlessSliceDims.Y, (int)Slices);
                Header = new HeaderRaw(Dims3, headerlessOffset, headerlessType);
            }
            else
                throw new Exception("File type not supported.");

            return Header;
        }
示例#3
0
文件: IOHelper.cs 项目: dtegunov/warp
        public static int3 GetMapDimensions(string path)
        {
            int3 Dims = new int3(1, 1, 1);
            FileInfo Info = new FileInfo(path);

            using (BinaryReader Reader = new BinaryReader(OpenWithBigBuffer(path)))
            {
                if (Info.Extension.ToLower() == ".mrc" || Info.Extension.ToLower() == ".mrcs")
                {
                    HeaderMRC Header = new HeaderMRC(Reader);
                    Dims = Header.Dimensions;
                }
                else if (Info.Extension.ToLower() == ".em")
                {
                    HeaderEM Header = new HeaderEM(Reader);
                    Dims = Header.Dimensions;
                }
                else
                    throw new Exception("Format not supported.");
            }

            return Dims;
        }
示例#4
0
文件: Headers.cs 项目: dtegunov/warp
        public static MapHeader ReadFromFile(BinaryReader reader, FileInfo info, int2 headerlessSliceDims, long headerlessOffset, Type headerlessType)
        {
            MapHeader Header = null;

            if (info.Extension.ToLower() == ".mrc" || info.Extension.ToLower() == ".mrcs" || info.Extension.ToLower() == ".ali" || info.Extension.ToLower() == ".rec" || info.Extension.ToLower() == ".st")
                Header = new HeaderMRC(reader);
            else if (info.Extension.ToLower() == ".em")
                Header = new HeaderEM(reader);
            else if (info.Extension.ToLower() == ".tif" || info.Extension.ToLower() == ".tiff")
                Header = new HeaderTiff(info.FullName);
            else if (info.Extension.ToLower() == ".dat")
            {
                long SliceElements = headerlessSliceDims.Elements() * ImageFormatsHelper.SizeOf(headerlessType);
                long Slices = (info.Length - headerlessOffset) / SliceElements;
                int3 Dims3 = new int3(headerlessSliceDims.X, headerlessSliceDims.Y, (int)Slices);
                Header = new HeaderRaw(Dims3, headerlessOffset, headerlessType);
            }
            else
                throw new Exception("File type not supported.");

            return Header;
        }