如何将不同类型的图像存储到数据库中 [英] how store different type of image into database

查看:104
本文介绍了如何将不同类型的图像存储到数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将彩色图像转换为黑白图像后,我想检测图像的形状,如何将不同类型的形状存储到数据库中

用什么方法从每个图像中识别出不同的形状
由于图像无法存储到数据库中,如何将每个检测到的形状存储在数据库中以及如何将图像数据存储到数据库中?

After converting a color image to black and white, I want to detect the shape of the image how i store different type of shape in to database

what are the method use identify different shape from each image
how can I store each detected shape in a database since image can not store to the database and how can i store image data to database

推荐答案

sql作为Varbinary(Max)数据类型并将图像保存在数据库中.首先将图像保存在特定路径(而不是该图像的readallbyte)中,然后按照以下代码中的描述将这些字节保存在数据库表中:
you can save image in database of sql as Varbinary(Max) datatype and saving image in database. First save image at particular path than readallbyte from this image and save these byte in your database table as describe in this code:-

using System.IO;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;

private void saveImageFile(string FileNameWithPath)
        {
            byte[] bt = null;
            if (System.IO.File.Exists(FileNameWithPath))
            {
                bt = System.IO.File.ReadAllBytes(FileNameWithPath);
            }

            Database DbCon = "connectionString"; 
            //Get Data from Database
            DbCommand Cmd = DbCon.GetStoredProcCommand("storeProcedureName");
            DbCon.AddInParameter(Cmd, "@ImageFile", DbType.Binary, bt);
            int a=DbCon.ExecuteNonQuery(Cmd);
        }


这篇关于如何将不同类型的图像存储到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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