Class BarcodeResult
Result from reading a barcode using IronBarCode
Inheritance
Namespace: IronBarCode
Assembly: IronBarCode.dll
Syntax
public class BarcodeResult : Object
BarcodeResult is the record a developer reads after a scan succeeds: one decoded barcode, with its text, its symbology, and where it sat in the source. A BarcodeReader.Read call returns a BarcodeResults collection of these, one per code found, so this is the type whose properties a developer actually consumes once the read is done. It answers "how do I get the value of a scanned barcode in C#" and the follow-ups about type and position.
A developer does not construct BarcodeResult for a normal read; the reader produces it. After calling Read or ReadAsync, iterate the returned BarcodeResults and inspect each BarcodeResult in turn. Because one image or PDF page can hold several codes, treat the result as one entry among possibly many rather than assuming a single hit.
The decoded payload is the first thing to read. Value and Text give the decoded string, BinaryValue exposes the raw bytes for non-text payloads, and Url parses the value as a Uri when the code holds a link. The symbology is BarcodeType, a BarcodeEncoding that names the format detected, such as QR, Code 128, or Code 39. The location and geometry are Points, the corner coordinates as a PointF array, plus Rotation, Width, and Height, which describe how the symbol was oriented and sized in the image. For multi-page sources, PageNumber and PageOrientation report which page the code came from and how that page was turned. BarcodeImage exposes the cropped image of the detected code itself. Read Value for the common case, and reach for the geometry and page properties when a job needs to locate or annotate the code.
using IronBarCode;
foreach (BarcodeResult result in BarcodeReader.Read("barcode.png"))
Console.WriteLine($"{result.BarcodeType}: {result.Value}");The read barcodes from images how-to reads codes and consumes the results, the read multiple barcodes how-to iterates several results, and the reading barcodes tutorial covers the end-to-end read.
Constructors
BarcodeResult()
Initializes a new instance of the BarcodeResults class.
Declaration
public BarcodeResult()
BarcodeResult(PointF[], String)
Initializes a new instance of the BarcodeResults class.
Declaration
public BarcodeResult(PointF[] points, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Drawing.PointF[] | points | |
| System.String | value |
Properties
BarcodeImage
An image of the scanned barcode image as a IronSoftware.Drawing.AnyBitmap.
This IronSoftware.Drawing.AnyBitmap will be disposed when the BarcodeResult finalizes. If you wish to keep a permanent copy of the BarcodeImage use the (Bitmap)BarcodeResult.BarcodeImage.Clone() method.
Declaration
public AnyBitmap BarcodeImage { get; }
Property Value
| Type | Description |
|---|---|
| IronSoftware.Drawing.AnyBitmap | An image of the barcode which was read. |
BarcodeType
The BarcodeEncoding (barcode type) which was detected
Declaration
public BarcodeEncoding BarcodeType { get; }
Property Value
| Type | Description |
|---|---|
| BarcodeEncoding |
BinaryValue
The binary value of the barcode as a byte array.
Declaration
public byte[] BinaryValue { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte[] |
Height
A Barcode Height
Declaration
public Nullable<int> Height { get; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Int32> |
PageNumber
The page number of the PDF or Image in which the barcode was discovered.
Declaration
public int PageNumber { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
PageOrientation
A Page orientation of input image.
Declaration
public PageOrientation PageOrientation { get; }
Property Value
| Type | Description |
|---|---|
| PageOrientation |
Points
Points defining the corners of the detected barcode code.
Declaration
public PointF[] Points { get; }
Property Value
| Type | Description |
|---|---|
| IronSoftware.Drawing.PointF[] |
Rotation
Clockwise rotation of the barcode from a horizontal position. Setting AutoRotate to true in BarcodeReaderOptions gives the angle in multiples of 15, while setting it to false gives it in multiples of 90. Null signifies the orientation was not found.
Declaration
public Nullable<int> Rotation { get; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Int32> |
Text
The value of the barcode as a string. Synonym for BarcodeResult.Value
Declaration
public string Text { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Url
Gets the URI if the Value is a valid URI.
Declaration
public Uri Url { get; }
Property Value
| Type | Description |
|---|---|
| System.Uri |
Value
The value of the barcode as a string.
Declaration
public string Value { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Width
A Barcode Width
Declaration
public Nullable<int> Width { get; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Int32> |
Methods
ToString()
Returns a System.String that represents the value of the barcode as a string;
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |