I am currently working on a barcode scanner for Code128 in my Windows Phone 8.1 App. I tried the Libary ZXing.Net 14.0.1.0, but my implementation only recognizes QR-Codes. Has somebody experience with my problem or knows the best practice for barcode scanners on Windows Phone 8.1? Are there other Libarys available?
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);
}