实例如下:
//主要通过stream作为中间桥梁 public static image bytearraytoimage(byte[] iamgebytes) { memorystream ms = new memorystream(iamgebytes); image image = image.fromstream(ms); return image; } public static byte[] imagetobytearray(image image) { memorystream ms = new memorystream(); image.save(ms, image.rawformat); return ms.toarray(); } public static string bytearraytostring(byte[] bytes) { return convert.tobase64string(bytes); } public static string stringtobytearray(string image) { return convert.frombase64string(image); }
以上这篇详谈c# 图片与byte[]之间以及byte[]与string之间的转换就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论