Ejemplo n.º 1
0
        /// <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);
                    }
                }
                ;
            }));
        }
Ejemplo n.º 2
0
 public Why Save(BinaryWriter s)
 {
     return(Why.FromTry(delegate()
     {
         s.Write(Dots);
         s.Write(MesuredDistance.Metres);
     }));
 }
Ejemplo n.º 3
0
        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);
                    }
                }
                ;
            }));
        }