如何使用Silverlight Webcam Application存储图像 [英] How to store an image using Silverlight Webcam Application

查看:37
本文介绍了如何使用Silverlight Webcam Application存储图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<Grid x:Name="LayoutRoot" Background="White">

         <Rectangle Name="Rectangle1" Margin="23,10,0,0"  Width="313" Height="229" HorizontalAlignment="Left" Stroke="Black" StrokeThickness="2" VerticalAlignment="Top"/>
        <Button Content="StartCapture" HorizontalAlignment="Left" Margin="66,242,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
        <Button Content="StopCapture" HorizontalAlignment="Left" Margin="221,242,0,0" VerticalAlignment="Top" Width="93" Click="Button_Click_2"/>



    </Grid>

推荐答案

你好身体

开始按钮点击活动

创建一个OpenFileDialoge的实例

然后showDialoge实例。

如果实例有值,实例有File属性,你必须打开并读取它。

如果OpenRead文件,结果是FileStream

我建议你将图片存储在Database中作为varbinary(byte [])

现在将FileStream转换为byte数组

请创建一个BinaryReader和Read Bytes的实例。

跟着我写了一段代码

Hi Body
in start button click event
create an instance of OpenFileDialoge
then showDialoge the instance.
if instance has value, the instance has "File" property which u must open and read it.
If you OpenRead the file, the result is a FileStream
I suggest you to store picture in Database as varbinary (byte[])
Now to convert FileStream to byte array
Please create an instance of BinaryReader and Read Bytes.
following i wrote a piece of code
private void uxStartButton_Click(object sender, RoutedEventArgs e)
{
    OpenFileDialog imageDialog = new OpenFileDialog();
    imageDialog.Filter = "Sample Pictures (.png)|*.png";
    bool? dialogResult = imageDialog.ShowDialog();
    if (dialogResult.HasValue && dialogResult.Value)
    {
        BinaryReader binary = new BinaryReader(imageDialog.File.OpenRead());
        byte[] _resultBytes = binary.ReadBytes((int)imageDialog.File.OpenRead().Length);
    }
}







从网上获取图片Cam,创建CaptureSource的实例,然后你需要检测存在的设备。所以在静态类捕获设备配置中,使用获取可用的设备方法。

制作捕获源的完成处理程序。

此事件的结果是图像,

现在与上面提到的相同,将图像存储到数据库




To get Picture from Web Cam, create an instance of CaptureSource, then u need to detect exist device. so in static class capture device config, use get available device method.
make completion handler of capture source.
Result of this event is an image,
now the same as up-mentioned , store image to Database


这篇关于如何使用Silverlight Webcam Application存储图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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