現在、Windows Phone 8.1 アプリで Code128 のバーコード スキャナーを開発中です。ライブラリ ZXing.Net 14.0.1.0 を試しましたが、私の実装では QR コードしか認識されません。私の問題を経験した人、または Windows Phone 8.1 でのバーコード スキャナーのベスト プラクティスを知っている人はいますか? 利用可能な他のライブラリはありますか?
MediaCapture captureManager = new MediaCapture();
async private void Capture_Photo_Click(object sender, RoutedEventArgs e)
{
//Create JPEG image Encoding format for storing image in JPEG type
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
// create storage file in local app storage
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("Photo" + counter + ".jpg", CreationCollisionOption.ReplaceExisting);
// take photo and store it on file location.
await captureManager.CapturePhotoToStorageFileAsync(imgFormat, file);
//// create storage file in Picture Library
//StorageFile file = await KnownFolders.PicturesLibrary.CreateFileAsync("Photo.jpg",CreationCollisionOption.GenerateUniqueName);
// Get photo as a BitmapImage using storage file path.
BitmapImage bmpImage = new BitmapImage(new Uri(file.Path));
// show captured image on Image UIElement.
imagePreivew.Source = bmpImage;
var stream = await file.OpenReadAsync();
var writeableBmp = new WriteableBitmap(1, 1);
writeableBmp.SetSource(stream);
writeableBmp = new WriteableBitmap(writeableBmp.PixelWidth, writeableBmp.PixelHeight);
stream.Seek(0);
writeableBmp.SetSource(stream);
ZXing.IBarcodeReader reader = new BarcodeReader
{
AutoRotate = true
};
reader.Options.TryHarder = true;
var result = reader.Decode(writeableBmp);
}