Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<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>
Posted

1 solution

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
C#
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);
    }
}



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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900