简体   繁体   English

如何从sql server数据库中读取图像数据的内容

[英]how can I read content of image data from sql server database

I have a ArcSDE SQL server database . 我有一个ArcSDE SQL server database according to arcSDE schema CodedValues for domains in geodatabase stored in GDB_CODEDDOMAINS table in IMAGE format . 根据arcSDE架构的 CodedValues,以IMAGE format存储在GDB_CODEDDOMAINS table中的地理数据库中的域。 how can I convert this image data type of coded values to string that can be human understandable. 如何将这种编码值的图像数据类型转换为易于理解的字符串。 In other word I want to convert this data type to string and extract each code value of domain in separate string variable. 换句话说,我想将此数据类型转换为字符串,并在单独的字符串变量中提取domain的每个代码值。 please give me idea to do this work. 请给我个主意做这项工作。

If the question is unclear pleas tell me to explain more! 如果问题不清楚,请告诉我解释更多!

The contents of an IMAGE type column come back to C# as a byte[] . IMAGE类型列的内容作为byte[]返回C#。 You can basically do anything with it. 您基本上可以执行任何操作。 My first guess would be to try to convert it to a string using 我的第一个猜测是尝试使用转换为string

string content = Encoding.UTF8.GetString(buffer);
public Image byteArrayToImage(byte[] byteArrayIn)
{
     MemoryStream ms = new MemoryStream(byteArrayIn);
     Image returnImage = Image.FromStream(ms);
     return returnImage;
}

http://www.codeproject.com/Articles/15460/C-Image-to-Byte-Array-and-Byte-Array-to-Image-Conv http://www.codeproject.com/Articles/15460/C-Image-to-Byte-Array-and-Byte-Array-to-Image-Conv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM