C#图片的Base64编码和解码

图片的Base64编码:

            System.IO.MemoryStream m = new System.IO.MemoryStream();
            System.Drawing.Bitmap bp = new System.Drawing.Bitmap(@“c:/demo.GIF”);
            bp.Save(m, System.Drawing.Imaging.ImageFormat.Gif);
            byte[]b= m.GetBuffer();
            string base64string=Convert.ToBase64String(b);

Base64字符串解码:

                byte[] bt = Convert.FromBase64String(base64string);
                System.IO.MemoryStream stream = new System.IO.MemoryStream(bt);
                Bitmap bitmap = new Bitmap(stream);  
展开阅读全文

没有更多推荐了,返回首页