Reputation: 2516
I am working on windows phone 8 App development..My requirement is to scan a QR code & Barcode and get the value embedded to it..
I have tried a lot with Zxing library.. please provide me with susitable solution
Upvotes: 2
Views: 3572
Reputation: 6590
Include you ZXing.Net
library into your project.
View.xaml
<Grid x:Name="grdCamera">
<Rectangle x:Name="_previewRect"
Margin="0"
Height="800"
Width="600"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Rectangle.Fill>
<VideoBrush x:Name="_previewVideo">
<VideoBrush.RelativeTransform>
<CompositeTransform
x:Name="_previewTransform" CenterX=".5" CenterY=".5" />
</VideoBrush.RelativeTransform>
</VideoBrush>
</Rectangle.Fill>
</Rectangle>
C# code
private readonly DispatcherTimer _timer;
private PhotoCameraLuminanceSource _luminance;
private QRCodeReader _reader;
private PhotoCamera _photoCamera;
//Constructor
public ScanPage()
{
InitializeComponent();
_timer = new DispatcherTimer();
_timer.Interval = TimeSpan.FromMilliseconds(250);
_timer.Tick += (o, arg) => ScanPreviewBuffer();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
_photoCamera = new PhotoCamera();
_photoCamera.Initialized += OnPhotoCameraInitialized;
_previewVideo.SetSource(_photoCamera);
CameraButtons.ShutterKeyHalfPressed += (o, arg) => _photoCamera.Focus();
base.OnNavigatedTo(e);
}
private void OnPhotoCameraInitialized(object sender, CameraOperationCompletedEventArgs e)
{
int width = Convert.ToInt32(_photoCamera.PreviewResolution.Width);
int height = Convert.ToInt32(_photoCamera.PreviewResolution.Height);
_luminance = new PhotoCameraLuminanceSource(width, height);
_reader = new QRCodeReader();
Dispatcher.BeginInvoke(() =>
{
_previewTransform.Rotation = _photoCamera.Orientation;
_timer.Start();
});
}
private void ScanPreviewBuffer()
{
try
{
_photoCamera.GetPreviewBufferY(_luminance.PreviewBufferY);
var binarizer = new HybridBinarizer(_luminance);
var binBitmap = new BinaryBitmap(binarizer);
var result = _reader.decode(binBitmap);
Dispatcher.BeginInvoke(() => MessageBox.Show(result.Text));
}
catch
{
}
}
Following links may helps you
http://jonas.follesoe.no/2011/07/22/qr-code-scanning-on-windows-phone-75-using-zxlib/
Upvotes: 1
Reputation: 2516
finally ..I have implemented this method..
Include following namespace on your sample
xmlns:jwqr="clr-namespace:JeffWilcox.Controls;assembly=JeffWilcox.Controls.QR"
in XAml file.. include the following control
<jwqr:QRCodeScanner
ScanComplete="QRCodeScanner_ScanComplete"
Error="QRCodeScanner_Error"
Width="400"
Height="400"/>
In code behing..include the event handlers.
private void QRCodeScanner_ScanComplete(object sender, JeffWilcox.Controls.ScanCompleteEventArgs e)
{
ApplicationTitle.Text = e.Result;
}
private void QRCodeScanner_Error(object sender, JeffWilcox.Controls.ScanFailureEventArgs e)
{
throw e.Exception;
}
for complete reference.. click here
Upvotes: 1
Reputation: 399
For example this solution. RadBarCode Here is the full set of features.
Upvotes: 0