/// <summary> /// Saves to the specified file name. /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns>This</returns> public SwiftBitmap Save(string fileName) { Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(fileName)); Contract.Requires <NullReferenceException>(InternalBitmap != null); Unlock(); InternalBitmap.Save(fileName, GetImageFormat(fileName)); return(this); }
/// <summary> /// Converts an SwiftBitmap to a base64 string and returns it /// </summary> /// <param name="desiredFormat">Desired SwiftBitmap format (defaults to Jpeg)</param> /// <returns>The SwiftBitmap in base64 string format</returns> public string ToString(ImageFormat desiredFormat) { Contract.Requires <NullReferenceException>(InternalBitmap != null); desiredFormat = desiredFormat.Check(ImageFormat.Jpeg); using (MemoryStream Stream = new MemoryStream()) { InternalBitmap.Save(Stream, desiredFormat); return(Stream.ToArray().ToString(Base64FormattingOptions.None)); } }