how can i decode the QrCode Or barcode With zxing library .
for test project i generate QrCode my self . now i want decode this with same library and fill the result in text block .
let me i explain with my code
public WriteableBitmap GenerateQRCode(string phoneNumber)
{
var _writer = new BarcodeWriter();
_writer.Renderer = new WriteableBitmapRenderer()
{
Foreground = Color.FromArgb(255, 0, 0, 255)
};
_writer.Format = BarcodeFormat.QR_CODE;
_writer.Options.Height = 244;
_writer.Options.Width = 446;
_writer.Options.Margin = 1;
_writer.Options.PureBarcode = true;
var barc = _writer.Write("tel:" + phoneNumber);
ImageGenrate.Source = barc;
var ss = Decode(barc);
return barc;
}
public void Decode( WriteableBitmap sImage)
{
var br = new BarcodeReader();
br.Decode(sImage);
}
in GenerateQRCode Method i generate QrCode and in Decode method I decode QrCode. how Can i see the Decode Result ?
I'll assume you are using ZXing.Net (NuGet package).
BarcodeReader.Decode(WritableBitmap)
returns an object of type Result
. This object has properties string Text
and byte[] RawBytes
.
public string Decode(WriteableBitmap sImage)
{
var br = new BarcodeReader();
var result = br.Decode(sImage);
if (result != null)
{
return result.Text;
}
return null;
}