如何保存从网络摄像头拍摄的图像 [英] how to save image taken from web camera

查看:89
本文介绍了如何保存从网络摄像头拍摄的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim ms As New MemoryStream()
            PictureBox1.BackgroundImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
            Dim imgdata = ms.ToArray
            Dim data As Byte()
            Dim br As New BinaryReader(ms)
            data = br.ReadBytes(Int(ms.Length))

            Dim para22 As New SqlParameter
            para22.ParameterName = "@S_PICTURE"
            para22.Value = data
            para22.DbType = SqlDbType.binary
           cmd.Parameters.Add(para22)





它给出了一个错误对象引用没有设置实例对象



it gives an error object refrence not set an instance of an object

推荐答案

请参阅我对该问题的评论。您展示的代码看起来与问题完全无关,与应该起作用的内容无关。 :-)



如果你想保存图像,唯一相关的是保存方法:http://msdn.microsoft.com/en-us/library/9t4syfhh%28v=vs.110%29.aspx [ ^ ]。







你甚至不知道你想要保存什么哪里。如果你想将图像保存在数据库中(不是文件名,图像本身),它将与你所做的,阅读相反,而不是比那更难。另请参阅: http://www.codeproject.com/search.aspx?q=C%23+database+%28image+OR+images+OR+bitmap+OR+bitmaps%29&doctypeid=5 [ ^ ]。



-SA
Please see my comment to the question. The code you show looks totally irrelevant to the question, and irrelevant to something which should work. :-)

If you want to save an image, the only relevant is the method for saving: http://msdn.microsoft.com/en-us/library/9t4syfhh%28v=vs.110%29.aspx[^].



You are not even telling what do you want to save where. If you want to save an image in a database (not file name, the image itself), it will be opposite to what you do, the reading, and no harder than that. See also: http://www.codeproject.com/search.aspx?q=C%23+database+%28image+OR+images+OR+bitmap+OR+bitmaps%29&doctypeid=5[^].

—SA


这篇关于如何保存从网络摄像头拍摄的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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