2013-02-05 18 views
0

所以我試圖開發一個利用Microsoft TAG技術的Windows Phone移動應用程序。AutoFocusComplete event windows phone

我從使用Microsoft TAG SDK提供的TagSdkSample項目的基礎開始。

當調試時(我正在調試Windows 8手機),我無法讓程序吐出任何東西,我假設它與自動對焦功能有關(它可以識別TAG,但在之前變得非常模糊)圖片被捕捉)。在代碼中有註釋提如何,這是一個糟糕的方式進行自動對焦的工作:

private void GetImageAndDecode() 
    { 
     // This is not a good way to auto focus. It is better to have an AutoFocusCompleted event 
     // handler to start capturing after focus is made. This sample code is not for 
     // full application demonstration. 
     camera.Focus(); 
     camera.GetPreviewBufferArgb32(previewPixels); 
     imageToDecode = new ImageToDecode(previewPixels, ImageFormat.ARGB32, previewWidth, previewHeight); 
     TagContext.Current.ScanFromFrame(imageToDecode); 
    } 

我將如何實現此代碼內的事件處理程序?

回答

1

下面的行添加到PhotoCamera對象初始化:

camera.AutoFocusCompleted += new EventHandler<CameraOperationCompletedEventArgs>(Camera_AutoFocusCompleted); 

然後添加以下方法:

void cam_AutoFocusCompleted(object sender, CameraOperationCompletedEventArgs e) 
{ 
    // Do what you want here 
}