1

Windows Phone 8.1 WinRT アプリに NuGet 経由で WriteableBitmapExtension を追加しました。カメラから画像をキャプチャして画像ライブラリに保存する機能があります。保存する前にキャプチャした画像を回転しようとしましたが、ここで解決策を見つけました WriteableBitmap crashs program with no message? . エミュレーターではすべて正常に動作しますが、Nokia Lumia 630 でアプリを実行すると、デバッガー メッセージなしで写真を撮ると数秒後にクラッシュします。誰でもこの問題で私を助けることができますか? 写真を撮る私のコードは次のとおりです。

public WriteableBitmap Image
   {
        get
        {
            return this.image;
        }

        set
        {
            this.image = value;
            this.RaisePropertyChanged(() => this.Image);
        }
    }

private async void TakePhoto()
        {
            using (var stream = new InMemoryRandomAccessStream())
            {
                var imgEncodingProperties = ImageEncodingProperties.CreateJpeg();
                var img = BitmapFactory.New(640, 480);
                await this.MediaCapture.CapturePhotoToStreamAsync(imgEncodingProperties, stream);
                stream.Seek(0);
                img.SetSource(stream);
                WriteableBitmapExtensions.DrawLine(img, 10, 10, 300, 300, Colors.Black);
                this.Image = img.Rotate(90); 
                this.TurnOffCaptureMode();
            }  
        }

private void TurnOffCaptureMode()
        {
            this.MediaCapture.StopPreviewAsync();
            this.IsInCaptureMode = false;
        }
4

1 に答える 1

0

代替ソリューションはこちらです。 1 ファイルを開く Picket は内蔵カメラを使用して写真を撮ります。

 var openPicker = new FileOpenPicker();
    openPicker.ContinuationData["Action"] = "SendPicture";
    openPicker.FileTypeFilter.Add(".jpg");
    openPicker.FileTypeFilter.Add(".png");
    openPicker.PickSingleFileAndContinue();

***2. In app.xaml.cs you will get captured image. as below.***


    public void Continue(IContinuationActivatedEventArgs args)
{
    if(args.Kind == ActivationKind.PickFileContinuation)
    {
        var openPickerContinuationArgs = args as FileOpenPickerContinuationEventArgs;

        // Recover the "Action" info we stored in ContinuationData
        string action = (string) openPickerContinuationArgs.ContinuationData["Action"];

        if(openPickerContinuationArgs.Files.Count > 0)
        {
            // TODO: Get the files here
        }
        else
        {
            // TODO: Write code here to handle picker cancellation.
        }
    }
}
于 2015-05-11T18:14:25.647 に答える