我想使用 xaml C# 读取 Windows 8 应用程序中的 QR 码/条形码,有什么指示吗?
我尝试使用 ZXing.Net
var openPicker = new FileOpenPicker { ViewMode = PickerViewMode.Thumbnail, SuggestedStartLocation = PickerLocationId.PicturesLibrary };
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
BitmapImage bmp = new BitmapImage();
IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
bmp.SetSource(stream);
BarCodeImage.Source = bmp;
IBarcodeReader reader = new BarcodeReader();
WriteableBitmap barcodeBitmap = new WriteableBitmap(1,1);
barcodeBitmap.SetSource(stream);
var result = reader.Decode(barcodeBitmap);
}
但是在加载结果时,我收到“值不能为空”的异常。请帮助它应该是什么代码