详谈C# 图片与byte[]之间以及byte[]与string之间的转换
程序员文章站
2023-11-09 17:59:58
实例如下:
//主要通过stream作为中间桥梁
public static image bytearraytoimage(byte[] iamgebytes)...
实例如下:
//主要通过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之间的转换就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
上一篇: git 取消文件跟踪
推荐阅读
-
详谈C# 图片与byte[]之间以及byte[]与string之间的转换
-
C#中Byte[]和String之间转换的方法
-
C#中string与byte[]的转换帮助类-.NET教程,C#语言
-
C# char[]与string byte[]与string之间的转换详解
-
详谈C# 图片与byte[]之间以及byte[]与string之间的转换
-
C#中string与byte[]的转换帮助类-.NET教程,C#语言
-
C#中Byte[]和String之间转换的方法
-
C#中String类型与json之间相互转换的实现方法
-
InputStream,int,shot,long与byte数组之间的互相转换
-
InputStream,int,shot,long与byte数组之间的互相转换