//=========== READING ============ #region Reading /**<summary>Saves the palette image to the specified file path.</summary>*/ public void Save(string path) { BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)); ImageDirectory imageDirectory = new ImageDirectory(); GraphicsData graphicsData = new GraphicsData(imageDirectory); graphicsData.Add(this); long imageDirectoryPosition = writer.BaseStream.Position; imageDirectory.Write(writer); graphicsData.Write(writer); writer.BaseStream.Position = imageDirectoryPosition; imageDirectory.Write(writer); writer.Close(); }
//============ SAVING ============ #region Saving /**<summary>Saves the palette to the specified stream.</summary>*/ public void Save(Stream stream) { BinaryWriter writer = new BinaryWriter(stream); ImageDirectory imageDirectory = new ImageDirectory(); GraphicsData graphicsData = new GraphicsData(imageDirectory); graphicsData.Add(this); long imageDirectoryPosition = writer.BaseStream.Position; imageDirectory.Write(writer); graphicsData.Write(writer); long endPosition = stream.Position; writer.BaseStream.Position = imageDirectoryPosition; imageDirectory.Write(writer); stream.Position = endPosition; }