/// <summary> /// Bitmap save routine, bridges Bitmap saving to BinaryWriter /// </summary> public static Why Save(Bitmap b, BinaryWriter s) { // validate inputs if (s == null) { return(Why.FalseBecause("Save(Bitmap b, BinaryWriter s), BinaryWriter was null", true)); } // Save b into s return(Why.FromTry(delegate() { bool notNull = b != null; s.Write(notNull); if (notNull) { using (MemoryStream ms = new MemoryStream()) { b.Save(ms, ImageFormat.Bmp); byte[] data = ms.ToArray(); s.Write(data.Length); s.Write(data); } } ; })); }
public Why Save(BinaryWriter s) { return(Why.FromTry(delegate() { s.Write(Dots); s.Write(MesuredDistance.Metres); })); }
public static Why Save(Bitmap b, BinaryWriter s) { return(Why.FromTry(delegate() { bool notNull = b != null; s.Write(notNull); if (notNull) { using (MemoryStream ms = new MemoryStream()) { b.Save(ms, ImageFormat.Bmp); byte[] data = ms.ToArray(); s.Write(data.Length); s.Write(data); } } ; })); }