コード例 #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);
                    }
                }
                ;
            }));
        }
コード例 #2
0
ファイル: Resolution.cs プロジェクト: busyDuckman/WDLibCore
 public Why Save(BinaryWriter s)
 {
     return(Why.FromTry(delegate()
     {
         s.Write(Dots);
         s.Write(MesuredDistance.Metres);
     }));
 }
コード例 #3
0
ファイル: BitmapHelpers.cs プロジェクト: busyDuckman/WDLib
        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);
                    }
                }
                ;
            }));
        }