Ejemplo n.º 1
0
        private void Calc(string name)
        {
            ImgFormat imgFormat = new ImgFormat();

            using (Image img = Image.FromFile(name))
            {
                string extension = name.Substring(name.LastIndexOf('.'));
                // MessageBox.Show(ImageFormat.Jpeg.ToString());
                using (MemoryStream ms = new MemoryStream())
                {
                    img.Save(ms, imgFormat[extension]);
                    textBox2.Text = Convert.ToBase64String(ms.GetBuffer());
                }
            }
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            button2.Enabled = !button2.Enabled;
            ImgFormat imgFormat = new ImgFormat();
            string    name      = txtImagePath.Text;

            //using (Image img = Image.FromFile(name))
            //{
            //    string extension = name.Substring(name.LastIndexOf('.'));
            //    // MessageBox.Show(ImageFormat.Jpeg.ToString());
            //    using (MemoryStream ms = new MemoryStream())
            //    {
            //        img.Save(ms, imgFormat[extension]);
            //        textBox2.Text = Convert.ToBase64String(ms.GetBuffer());
            //    }
            //}
            Calc(name);
        }