हर बार जब मैं अपने SoftwareBitmap
को WriteableBitmap
में कनवर्ट करना चाहता हूं तो मुझे निम्न अपवाद मिलता है: System.Runtime.InteropServices.COMException
।सॉफ़्टवेयर बिटमैप को लिखित करने योग्य बिटमैप
private async void Start(object sender, RoutedEventArgs e)
{
_MediaCapture = new MediaCapture();
await _MediaCapture.InitializeAsync();
mediaElement.Source = _MediaCapture;
await _MediaCapture.StartPreviewAsync();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 1);
timer.Tick += HandleTimerTick;
timer.Start();
}
private async void HandleTimerTick(object Sender, object E)
{
var frame = await _MediaCapture.GetPreviewFrameAsync();
SoftwareBitmap frameBitmap = frame.SoftwareBitmap;
WriteableBitmap bitmap = new WriteableBitmap(frameBitmap.PixelWidth, frameBitmap.PixelHeight);
try
{
frameBitmap.CopyToBuffer(bitmap.PixelBuffer);
}
catch (Exception)
{
Debug.WriteLine("Exception ");
}
}
लाइन
frameBitmap.CopyToBuffer(bitmap.PixelBuffer);
अपवाद फेंक है:
यहाँ उस के लिए मेरे कोड का टुकड़ा है।
मैं इसे x64 रिमोटडिवाइस पर डिबग कर रहा हूं।
अपवाद क्या फेंक दिया जाता है:
आप के रूप में निम्नलिखित कोड का उपयोग करके इस समस्या को हल कर सकते हैं? –
@Dmitry Bychenko ऊपर देखो: System.Runtime.InteropServices.COMException – TheTanic
साइड नोट: * निगलने * अपवाद जैसे 'पकड़ (अपवाद) {डीबग। राइटलाइन ("अपवाद"); } 'एक * बहुत बुरा अभ्यास * है। –