我是Windows Phone应用程序中的新蜜蜂。我目前在我的模拟器和设备中使用Windows Phone 7.1操作系统。我有一个包含数字的贴纸。我想通过使用相机扫描此代码并将数字保存到我的数据库中。我没有一个关于从相机扫描价值的线索。
我使用相机获得了扫描条形码和qr码的代码 我试过的代码如下: -
void cam_Initialized(object sender, Microsoft.Devices.CameraOperationCompletedEventArgs e)
{
if (e.Succeeded)
{
this.Dispatcher.BeginInvoke(delegate()
{
// Write message.
txtDebug.Text = "Camera initialized.";
// Set flash button text.
});
}
}
void CaptureImage(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
MessageBox.Show(e.ChosenPhoto.Length.ToString());
//Code to display the photo on the page in an image control named myImage.
//System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
//bmp.SetSource(e.ChosenPhoto);
//myImage.Source = bmp;
}
}
private void ShutterButton_Click(object sender, RoutedEventArgs e)
{
WP7.ScanBarCode.BarCodeManager.StartScan(
// on success
(b) => Dispatcher.BeginInvoke(() =>
{
txtDebug.Text = b;
NavigationService.GoBack();
}),
// on error
(ex) => Dispatcher.BeginInvoke(() =>
{
txtDebug.Text = ex.Message;
NavigationService.GoBack();
})
// Default : please, decode any bar-code
);
//if (cam != null)
//{
// try
// {
// // Start image capture.
// cam.CaptureImage();
// txtDebug.Text = "Image Taken";
// }
// catch (Exception ex)
// {
// this.Dispatcher.BeginInvoke(delegate()
// {
// // Cannot capture an image until the previous capture has completed.
// txtDebug.Text = ex.Message;
// });
// }
//}
}
private int photoCounter = 0;
void cam_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
{
photoCounter++;
string fileName = photoCounter + ".jpg";
Deployment.Current.Dispatcher.BeginInvoke(delegate()
{
txtDebug.Text = "Captured image available, saving picture.";
});
Deployment.Current.Dispatcher.BeginInvoke(delegate()
{
txtDebug.Text = "Picture has been saved to camera roll.";
});
}