将图像转换为二进制 [英] Convert image to binary

查看:147
本文介绍了将图像转换为二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个图像路径和数据库中包含图像列的表格

我如何获取图像并将其转换为二进制文件,所以我可以将它存储在数据库中吗?

Hello all,
I have a image path and a table in database that contains image column
How can I get the image and convert it to binary, so I can store it in database??

推荐答案

参考:

1. C#从数据库保存和加载图像 [ ^ ]

2. 使用BinaryFormatter将类分类/反序列化为SQL Server图像列 [ ^ ]
Refer:
1. C# Save and Load Image from Database[^]
2. Serialize/Deserialize Classes into SQL Server Image Columns using the BinaryFormatter[^]


您可以使用File.ReadAllBytes [ ^ ]方法然后将它们存储在您的数据库中。

You can read the bytes from the file using the File.ReadAllBytes[^] method and then store those in your database.
byte[] imageData = File.ReadAllBytes(filePath);
// store imageData in database

< br>

C#中的图像:保存,调整大小并转换为二进制 [ ^ ]



http://startcoding.in/2012/03/06/save-retrieve-image-from-binary-data-database-asp -net / [ ^ ]


这篇关于将图像转换为二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆