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); }
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; }
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; }