public Stream GetStream(string pathPrefix, string plateName, int level, int x, int y) { if (string.IsNullOrEmpty(pathPrefix)) { throw new System.ArgumentException($"'{nameof(pathPrefix)}' cannot be null or empty", nameof(pathPrefix)); } return(PlateTilePyramid.GetFileStream(Path.Combine(pathPrefix, plateName), level, x, y)); }
public PlateTilePyramid createPTP(string dotPlateFile) { /* * Creates a .plate file with the name dotPlateFile (which should include path info) * from the current image pyramid. Adds ".plate" extension if not present. * Assumes that the current image pyramid is full i.e. has all levels * Returns the PlateTilePyramid object created, though this function will * often be called without any return value. * * */ if (!valid) { return null; } /* CAUTION: IF this stuff is added, then an exception is thrown * if it is unable to create a full pyramid to work from. if (maxLevel != levels.Length - 1) { if (FillPyramid()) { throw new System.ArgumentException("Need a full pyramid to work off "); } } * */ // dotPlateFile has name of .plate file, with or without extension if (Path.GetExtension(dotPlateFile).Length == 0 && dotPlateFile.IndexOf(".") < 0) { dotPlateFile = dotPlateFile + ".plate"; } // dotPlateFile has name of .plate file, with extension string dotPlateDir = Path.GetDirectoryName(dotPlateFile); if (Directory.Exists(dotPlateDir)) { Directory.CreateDirectory(dotPlateDir); } PlateTilePyramid ptp = new PlateTilePyramid(dotPlateFile, maxLevel+1); ptp.Create(); for (int level = maxLevel; level >=0; level--) { int count = (int)Math.Pow(2, level); for (int y = 0; y < count; y++) { for (int x = 0; x < count; x++) { string tileFileName = string.Format("{0}{1}\\{3}\\{3}_{2}.png", origPath, level, x, y); if (File.Exists(tileFileName)) { ptp.AddFile(tileFileName, level, x, y); } } } } ptp.UpdateHeaderAndClose(); return ptp; }