用C# 如何将一张图像转换成一个字符串,然后将该字符串又转换成图像?
如何将一张图像转换成一个字符串,然后将该字符串又转换成图像?请各位大侠指教,最好是能提供源代码,小弟谢过了!
FileStream photo = new FileStream("test.jpg", FileMode.Open); byte[] buffer = new byte[65000]; photo.Read(buffer, 0, buffer.Length); Console.WriteLine("这里将图片转成String:"); string photoStr = Encoding.ASCII.GetString(buffer); Console.Write("转换成功!"); photo.Close(); Console.WriteLine("以下是讲String转换成图片:"); FileStream newPhoto = new FileStream("newPhoto.jpg", FileMode.Create); newPhoto.Write(buffer, 0, buffer.Length); //Image ima = Image.FromStream(newPhoto); newPhoto.Close(); Console.WriteLine("转换成功!"); Console.ReadKey();