-
C# Image与Base64编码互转函数
- public Bitmap GetImageFromBase64(string base64string)
- {
- byte[] b = Convert.FromBase64String(base64string);
- MemoryStream ms = new MemoryStream(b);
- Bitmap bitmap = new Bitmap(ms);
- return bitmap;
- }
- public string GetBase64FromImage(string imagefile)
- {
- string strbaser64 = "";
- try
- {
- Bitmap bmp = new Bitmap(imagefile);
- MemoryStream ms = new MemoryStream();
- bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
- byte[] arr = new byte[ms.Length];
- ms.Position = 0;
- ms.Read(arr, 0, (int)ms.Length);
- ms.Close();
- strbaser64 = Convert.ToBase64String(arr);
- }
- catch (Exception)
- {
- throw new Exception("Something wrong during convert!");
- }
- return strbaser64;
- }
-
相关阅读:
Vue源码学习之双向绑定
Vue源码学习之数据初始化
JavaScript跨域资源请求(CORS)解决方案
Vue学习笔记
MongoDB学习笔记
实现一个类似bootstrap的多级下拉菜单
bootstrap栅格系统的实现
滑动效果的标签页切换
一个简单的类似Vue的双向绑定
元素垂直居中的常见方法
-
原文地址:https://www.cnblogs.com/ztf20/p/11821405.html
Copyright © 2020-2023
润新知