/// <summary> /// Saves <see cref="IndexedImage"/> object to stream. /// </summary> /// <param name="image">Image object to save.</param> /// <param name="stream">The destination stream.</param> public static void SaveToStream(this CodedImage image, Stream stream) { using (GZipStream zipStream = new GZipStream(stream, CompressionMode.Compress)) using (XmlWriter xmlWriter = XmlWriter.Create(zipStream)) { image.WriteToXml(xmlWriter); } }
/// <summary> /// Writes <see cref="IndexedImage"/> object to string. /// </summary> /// <param name="image">Image object to serialize.</param> /// <returns>String containing serialized image.</returns> public static string WriteToString(this CodedImage image) { using (var stringWriter = new StringWriter()) { using (var xmlWriter = XmlWriter.Create(stringWriter)) { image.WriteToXml(xmlWriter); } stringWriter.Flush(); return(stringWriter.ToString()); } }