2
我使用PhotoCamera
API構建QR碼掃描頁面(使用ZXing)。但是,此頁面只是應用程序的一小部分,因此並不總是顯示。因此,應用程序在這個頁面和其他一些具有通用控件的頁面之間進行導航。PhotoCamera API:如何正確處置它?
問題是,有時候,掃描後,整個應用程序減速到30fps而不是60fps,沒有真正的原因。我懷疑相機仍在後臺運行,幀同步將應用程序鎖定爲30fps,這是我的問題:如何正確處理使用PhotoCamera
API的頁面?
我的XAML:
<Grid Background="Black">
<ProgressBar x:Name="PBar" IsIndeterminate="True" VerticalAlignment="Center" />
<Rectangle x:Name="ScanRect">
<Rectangle.Fill>
<VideoBrush x:Name="ScanVideoBrush" />
</Rectangle.Fill>
</Rectangle>
</Grid>
我的C#停止掃描過程:
private void StopScan() {
if (analysisTimer != null) {
analysisTimer.Stop();
analysisTimer = null;
}
if (focusTimer != null) {
focusTimer.Stop();
focusTimer = null;
}
if (camera != null) {
camera.Dispose();
camera.Initialized -= OnCameraInitialized;
camera = null;
}
// Following two lines are a try to dispose stuff
// as much as possible, but the app still lags
// sometimes after a scan...
ScanVideoBrush.SetSource(new MediaElement());
ScanRect.Fill = new SolidColorBrush(Colors.Black);
}
注:我在的Lumia 920
我知道,我也正是因爲MSDN說,但還是有一些在後臺不時。我會嘗試更深入地剖析應用程序。謝謝。 –
您是否有處置相機的成功?看起來我和你有同樣的問題 – Vovich