0

我目前正在我的 Windows Phone 8.1 应用程序中为 Code128 开发条形码扫描仪。我尝试了 Libary 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);
  }
4

0 回答 0