Convert pictures to BASE64 code in C#

大家讲道理
Release: 2016-11-10 09:52:31
Original
2536 people have browsed it

//The image is converted to base64 encoded text
                                                                              using using using using          out out out through '' out's ’   ’     through ‐ through off‐line ‐‐‐‐‐ off to base64 encoded text
                                                   dlg.Title = "Select the picture you want to convert" ;
             dlg.Filter = "Image files (*.jpg;*.bmp;*.gif;*.png)|*.jpg*.jpeg;*.gif;*.bmp|AllFiles (*.*)|* .*";
              if (DialogResult.OK == dlg.ShowDialog())
                                                                                                                                   ToString());
                                                                                                                                                     .
             try
                                                                                                                                                                                                                                                                       Image = bmp; MemoryStream ms = new MemoryStream();
                       bmp.Save(ms , System.Drawing.Imaging.ImageFormat.Jpeg);                    byte[] arr = new byte[ms.Length]; Length); ​sw.Close();
                                                                                                                                                                                                                                                                                 . Conversion successful!");
          }
                                                                                                     catch (Exception                                                                                                                                                                                                                                                             
           private void button2_Click(object sender, EventArgs e)
                                                                                                                                                                                                                                            viadlg.Title = "Select base64-encoded text to convert";
           dlg.Filter = "txt files|*.txt";
                                                                                                       for (int i = 0; i                                                                                                                                                                                                                                              Base64StringToImage(string txtFileName)
                                                                                                                                                          StreamReader sr = new StreamReader(ifs);

StreamReader sr = sr.ReadToEnd() ;
           byte[] arr = Convert.FromBase64String(inputStr);                      //bmp.Save(txtFileName + ".jpg", (System.Drawing.Imaging.ImageFormat.Jpeg); //bmp.Save(txtFileName + ".png", ImageFormat.Png); This.pictureBox2.Image = bmp;
if (File.exists (txtFilename)) {
File.delete (txtFilename);
}
//messageBox.show ("Converted success! "); }
}

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!