[英]Converting System.Drawing.Image to System.Data.Linq.Binary
I'm working on a application storing images in DB. 我正在研究在DB中存储图像的应用程序。 The images are related to an object and I have to use Linq for this.
图像与一个对象有关,我必须使用Linq。 When I insert the object in database, its image is a System.Drawing.Image, which needs to be converted in System.Data.Linq.Binary.
当我在数据库中插入对象时,它的图像是System.Drawing.Image,需要在System.Data.Linq.Binary中进行转换。
I found tutos for the other way but not for this one. 我找到了另一种方式的tutos,但不是这个。
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
var binary = new System.Data.Linq.Binary(ms.GetBuffer());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.