[英]save a image as byte[] from graphic object in c#
I will get image in byte from database and using system.drawing.graphic to add some necessary stuff , and after this i need to save this image in byte[] and send to front end (silver light 4) to print. 我将从数据库中获取图像并使用system.drawing.graphic添加一些必要的东西,然后我需要将此图像保存在byte []并发送到前端(银灯4)进行打印。
note(I am not going to save this in physical file). 注意(我不会将其保存在物理文件中)。
I appreciate every help or you guys and provide example code if possible. 我感谢您的每一个帮助,如果可能的话,我会提供示例代码。
byte[] result;
using (Image newImage = new Bitmap(origImage))
{
using (Graphics graphics = Graphics.FromImage(newImage))
{
// do some drawing
}
using (MemoryStream ms = new MemoryStream())
{
newImage.Save(ms, ImageFormat.Png);
result = ms.ToArray();
}
}
To restore the image from the byte[]
: 要从
byte[]
恢复图像:
Image restored = Image.FromStream(new MemoryStream(result));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.