2017-11-06 16 views
0

を保存しないようにどのように、私はコードのこのセットを研究している、
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CameraStarterKitUWPアプリケーションでMediaCaptureを行うが、私はカメラ機能でUWPアプリケーションを開発していますローカルマシンに

に成功は私の上のカメラ機能を開発応用。しかし、私のアプリケーションでは、はローカルマシンに画像を保存しないようにしたいと考えています。アプリケーションは実際にキオスクシステムのようなものなので、誰もが同じマシンを使って画像を撮ることになります。

実際には、ユーザーがキオスクシステムを通じて自分のメールアドレスに撮影した画像を送信できるようにする予定です。彼らは写真を撮影しているときに、プレビューが表示され、ユーザーが画像を送信する場合にのみ、その絵は私のテイク写真用コード

take picture

を「保存」になります機能は次のようなものです:

rivate async Task TakePhotoAsync() 
    { 

     var stream = new InMemoryRandomAccessStream(); 

     Debug.WriteLine("Taking photo..."); 
     await _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream); 

     try 
     { 
      var file = await _captureFolder.CreateFileAsync("SimplePhoto.jpg", CreationCollisionOption.GenerateUniqueName); 
      Debug.WriteLine("Photo taken! Saving to " + file.Path); 

      var photoOrientation = CameraRotationHelper.ConvertSimpleOrientationToPhotoOrientation(_rotationHelper.GetCameraCaptureOrientation()); 

      await ReencodeAndSavePhotoAsync(stream, file, photoOrientation); 
      Debug.WriteLine("Photo saved!"); 


     } 
     catch (Exception ex) 
     { 
      // File I/O errors are reported as exceptions 
      Debug.WriteLine("Exception when taking a photo: " + ex.ToString()); 
     } 

    } 

と画像のプレビューを取得するために、次のようになります。

private async Task GetPreviewFrameAsSoftwareBitmapAsync() 
    { 
     // Get information about the preview 
     var previewProperties = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties; 

     // Create the video frame to request a SoftwareBitmap preview frame 
     var videoFrame = new VideoFrame(BitmapPixelFormat.Bgra8, (int)previewProperties.Width, (int)previewProperties.Height); 

     // Capture the preview frame 
     using (var currentFrame = await _mediaCapture.GetPreviewFrameAsync(videoFrame)) 
     { 
      // Collect the resulting frame 
      SoftwareBitmap previewFrame = currentFrame.SoftwareBitmap; 

      // Show the frame information 
      FrameInfoTextBlock.Text = String.Format("{0}x{1} {2}", previewFrame.PixelWidth, previewFrame.PixelHeight, previewFrame.BitmapPixelFormat); 


      // Create a SoftwareBitmapSource to display the SoftwareBitmap to the user 
      var sbSource = new SoftwareBitmapSource(); 
      await sbSource.SetBitmapAsync(previewFrame); 

      // Display it in the Image control 
      PreviewFrameImage.Source = sbSource; 

     } 
    } 

答えて

0

は、(少なくとも)2つの方法があります。

1) "より良い" 1:

  • UWPからSmtpClient

  • ポストあなたの画像を使用して電子メールを送信するバックエンドを作成します。バックエンドを使用してHttpClient

2)「Easie r "one:launch Mail app

ユーザーがメッセージや受信者などを編集できるという欠点があります。

また、SmtpClientをUWPクライアントから直接使用することもできます(現在は.Net Standard 2.0でも可能ですが、まだ試したことはありません)またはthird-party open-source replacement(これは、 Windows 8)、あるいはクライアントマシン上でWindowsサービスとしてバックエンドを起動しようとすることさえあります。

+0

こんにちは、私はまだ学生のUWPを学んでいるので、私は非常にSmtpClientが何であるかはわかりません...そして、もし私が最初の選択肢に行きたいのであれば、絵はまだありますか?ローカルマシンに保存されていますか? – thalassophile

+0

SmtpClientはSMTPサーバー(電子メールを送受信するもの)に接続します。参考になるサンプルがある場合は... – thalassophile

+0

SmtpClientがSMTPサーバーに接続します。 – cherepets