示例#1
0
文件: Form1.cs 项目: songsangsu/ProHW
        private void button3_Click(object sender, EventArgs e)
        {
            if (openFileDialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(imageData));
                StreamReader fs = new StreamReader(openFileDialog2.FileName, Encoding.GetEncoding("euc-kr"));
                XmlReader reader = XmlReader.Create(fs);
                imageData joongil = new imageData();
                joongil = (imageData)serializer.Deserialize(reader);
                fs.Close();
                Bitmap bmp = new Bitmap(joongil.width, joongil.height);
                for (int i = 0; i < joongil.height; i++)
                    for (int j = 0; j < joongil.width; j++)
                        bmp.SetPixel(j, i, Color.FromArgb(joongil.pixel[i*joongil.width + j]));
                pictureBox1.Image = bmp;

            }
        }
示例#2
0
文件: Form1.cs 项目: songsangsu/ProHW
 private void button2_Click(object sender, EventArgs e)
 {
     Bitmap bmp = new Bitmap(pictureBox1.Image);
     imageData joongil = new imageData();
     joongil.SetSize(bmp.Width, bmp.Height);
     for(int i = 0; i < joongil.height; i++)
     {
         for (int j = 0; j < joongil.width; j++)
         {
             joongil.pixel[i*joongil.width + j] = bmp.GetPixel(j,i).ToArgb();
         }
     }
         if (!(saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK))
             return;
         {
             XmlSerializer xs = new XmlSerializer(typeof(imageData));
             StreamWriter sw = new StreamWriter(saveFileDialog1.FileName, false);
             xs.Serialize(sw, joongil);
             sw.Close();
         }
 }