示例#1
0
 public void SetImages(Bitmap [] images)
 {
     frames = new CMSSerializedImage[images.Length];
     for (int i = 0; i < images.Length; i++)
     {
         frames[i] = new CMSSerializedImage();
         frames[i].SetImage(images[i]);
     }
 }
示例#2
0
        /*
         * public static void Test()
         * {
         *
         *  XmlElement[] dummies = new XmlElement[2];
         *
         *  XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
         *  ns.Add("", "");
         *
         *  XmlSerializer xmSer = new XmlSerializer(typeof(Dummy1));
         *  MemoryStream ms = new MemoryStream();
         *  xmSer.Serialize(ms, new Dummy1(), ns);
         *  XmlDocument xDoc1 = new XmlDocument();
         *
         *  ms.Position = 0;
         *  xDoc1.Load(ms);
         *  dummies[0] = xDoc1.LastChild as XmlElement;
         *
         *  XmlSerializerNamespaces ns2 = new XmlSerializerNamespaces();
         *  ns2.Add("", "");
         *
         *  XmlSerializer xmSer2 = new XmlSerializer(typeof(Dummy2));
         *  MemoryStream ms2 = new MemoryStream();
         *  xmSer2.Serialize(ms2, new Dummy2(), ns2);
         *  ms2.Position = 0;
         *  XmlDocument xDoc2 = new XmlDocument();
         *  xDoc2.Load(ms2);
         *  dummies[1] = xDoc2.LastChild as XmlElement;
         *
         *  Dummy3 d3 = new Dummy3();
         *  d3.Dummies = dummies;
         *
         *  XmlSerializerNamespaces ns3 = new XmlSerializerNamespaces();
         *  ns3.Add("", "");
         *  XmlSerializer xmSer3 = new XmlSerializer(typeof(Dummy3));
         *  TextWriter tw = new StreamWriter("C:/temp/d3.xml");
         *  xmSer3.Serialize(tw, d3, ns3);
         * }
         *
         * public static void Test2()
         * {
         *  StringBuilder sb = new StringBuilder();
         *  StringWriter sw = new StringWriter();
         *  foreach (Process p in Process.GetProcesses("."))
         *  {
         *      try
         *      {
         *          if (p.MainWindowTitle.Length > 0)
         *          {
         *              sw.Write("\r\n");
         *              sw.Write("\r\n Process Name:" + p.ProcessName.ToString());
         *          }
         *      }
         *      catch { }
         *  }
         * }
         *
         * public static void Test3()
         * {
         *  DirectoryInfo di = new DirectoryInfo("c:/temp");
         *  FileInfo[] fis = di.GetFiles();
         *  int g = 0;
         *  g++;
         * }
         *
         * public static void Test4()
         * {
         *  TestDate t = new TestDate();
         *  //t.Tester = "This is my String";
         *  using (FileStream fs = new FileStream("C:/temp/out.xml", FileMode.Create))
         *  {
         *      XmlSerializer xmSer = new XmlSerializer(typeof(TestDate));
         *      xmSer.Serialize(fs,t);
         *  }
         * }
         */

        public static void Test5()
        {
            Bitmap b = new Bitmap(200, 200);

            for (int x = 0; x < 200; x++)
            {
                for (int y = 0; y < 200; y++)
                {
                    if (((x + y) % 2) == 0)
                    {
                        b.SetPixel(x, y, Color.White);
                    }
                    else
                    {
                        b.SetPixel(x, y, Color.Black);
                    }
                }
            }
            b.Save("C:/temp/b.bmp");
            CMSSerializedImage img = new CMSSerializedImage();

            img.SetImage(b);
            XmlSerializer xmSer = new XmlSerializer(typeof(CMSSerializedImage));

            using (FileStream f = new FileStream("C:/temp/out2.xml", FileMode.Create))
            {
                xmSer.Serialize(f, img);
            }

            Bitmap b2;

            using (FileStream f = new FileStream("C:/temp/out2.xml", FileMode.Open))
            {
                CMSSerializedImage img2 = xmSer.Deserialize(f) as CMSSerializedImage;
                b2 = img2.GetImage();
            }

            b2.Save("C:/temp/b2.bmp");
        }