Taking Photo with Flash not working but Torch is Ok.


  • Hi , I used below code to take photo.

    1) The code work when I used the Torch light

    2) problem:

     The same code cannot work when I used the Flashcontrol ( this is supported by the device).

     The Image is shown a brief moment , then the camera back to preview mode. But I have already disabled.

    The code:

    These are used:

       <Capture Element x:name="camera" />

       <image x:Name="preview">

     private async void TakePhoto(object sender, RoutedEventArgs e)
                    var bounds = Window.Current.Bounds;
                    double height = bounds.Height;
                    double width = bounds.Width;

                    //-- create the source
                    streamimage = new InMemoryRandomAccessStream();
                    ImageEncodingProperties imageProperties = ImageEncodingProperties.CreateJpeg();

                    //--capture the image
                     await m_mediaCaptureMgr.CapturePhotoToStreamAsync(imageProperties, streamimage);

                    //-- <Capture Element x:name="camera" />

                    camera.Visibility = Visibility.Collapsed;

                    await m_mediaCaptureMgr.StopPreviewAsync();


                    //--- create pic
                    _bitmap = new BitmapImage();

                    await _bitmap.SetSourceAsync(streamimage);

                    double d_imgW = _bitmap.PixelWidth;
                    double d_imgH = _bitmap.PixelHeight;               

                    //-- <image x:Name="preview">

                    preview.Source = _bitmap;
                    preview.Visibility = Visibility.Visible;
                    preview.RenderTransform = new ScaleTransform() { ScaleX = zoom.ScaleX, ScaleY = zoom.ScaleY, CenterX = zoom.CenterX, CenterY = zoom.CenterY };

                catch (Exception ex)

    Please help.


    Monday, April 20, 2015 8:24 AM

All replies