zxing-cpp v3.0
Loading...
Searching...
No Matches
ZXing::Barcode Class Reference

#include <Barcode.h>

Public Member Functions

 Barcode ()
 Barcode (Barcode::Data &&data)
bool isValid () const
const Errorerror () const
BarcodeFormat format () const
BarcodeFormat symbology () const
const std::vector< uint8_t > & bytes () const
std::vector< uint8_t > bytesECI () const
std::string text (TextMode mode) const
std::string text () const
ContentType contentType () const
bool hasECI () const
const Positionposition () const
int orientation () const
bool isMirrored () const
bool isInverted () const
std::string symbologyIdentifier () const
int sequenceSize () const
int sequenceIndex () const
std::string sequenceId () const
bool isLastInSequence () const
bool isPartOfSequence () const
int lineCount () const
ImageView symbol () const
std::string extra (std::string_view key="") const
bool operator== (const Barcode &o) const

Friends

Barcode MergeStructuredAppendSequence (const Barcodes &barcodes)
Barcodes ReadBarcodes (const ImageView &image, const ReaderOptions &options={})
Barcode CreateBarcode (const void *, int, int, const CreatorOptions &)
Image WriteBarcodeToImage (const Barcode &barcode, const WriterOptions &options={})
std::string WriteBarcodeToSVG (const Barcode &barcode, const WriterOptions &options={})

Detailed Description

The Barcode class encapsulates a decoded or created barcode symbol.

Barcode represents a decoded or created barcode symbol, providing access to its content, format, position, and other metadata. It serves as the primary interface for working with barcodes in the library.

Barcode objects are obtained from the ReadBarcodes function when scanning an image, or from the CreateBarcodeFrom... functions when generating a new barcode. To convert a Barcode to an image or SVG, use the WriteBarcodeTo... functions.

See also
ReadBarcodes, CreateBarcodeFromText, CreateBarcodeFromBytes, WriteBarcodeToImage, WriteBarcodeToSVG

Constructor & Destructor Documentation

◆ Barcode() [1/2]

ZXing::Barcode::Barcode ( )

◆ Barcode() [2/2]

ZXing::Barcode::Barcode ( Barcode::Data && data)

Member Function Documentation

◆ isValid()

bool ZXing::Barcode::isValid ( ) const

Returns whether the barcode is valid, i.e. it contains a successfully decoded or created symbol.

◆ error()

const Error & ZXing::Barcode::error ( ) const

Returns the error associated with the barcode, if any.

◆ format()

BarcodeFormat ZXing::Barcode::format ( ) const

Returns the BarcodeFormat of the barcode.

◆ symbology()

BarcodeFormat ZXing::Barcode::symbology ( ) const
inline

Returns the symbology of the barcode format (e.g. EAN/UPC for EAN13, EAN8, UPCA, etc.).

◆ bytes()

const std::vector< uint8_t > & ZXing::Barcode::bytes ( ) const

Returns the raw / standard content without any modifications like character set conversions.

◆ bytesECI()

std::vector< uint8_t > ZXing::Barcode::bytesECI ( ) const

Returns the raw / standard content following the ECI protocol.

◆ text() [1/2]

std::string ZXing::Barcode::text ( TextMode mode) const

Returns the bytes() content rendered to unicode/utf8 text according to specified TextMode.

◆ text() [2/2]

std::string ZXing::Barcode::text ( ) const

Returns the bytes() content rendered to unicode/utf8 text according to the TextMode set in the ReaderOptions.

◆ contentType()

ContentType ZXing::Barcode::contentType ( ) const

Returns the content type, giving a hint to the type of content found (Text/Binary/GS1/etc.).

◆ hasECI()

bool ZXing::Barcode::hasECI ( ) const

Returns whether or not an ECI tag was found.

◆ position()

const Position & ZXing::Barcode::position ( ) const

Returns the position of the barcode in the image as a quadrilateral of 4 points (topLeft, topRight, bottomRight, bottomLeft).

◆ orientation()

int ZXing::Barcode::orientation ( ) const

Returns the orientation of the barcode in degrees, see also Position::orientation().

◆ isMirrored()

bool ZXing::Barcode::isMirrored ( ) const

Returns whether the symbol is mirrored (currently only supported by QRCode and DataMatrix).

◆ isInverted()

bool ZXing::Barcode::isInverted ( ) const

Returns whether the symbol is inverted / has reversed reflectance (see ReaderOptions::tryInvert).

◆ symbologyIdentifier()

std::string ZXing::Barcode::symbologyIdentifier ( ) const

Returns the symbology identifier "]cm" where "c" is symbology code character, "m" the modifier.

◆ sequenceSize()

int ZXing::Barcode::sequenceSize ( ) const

Returns the number of symbols in a structured append sequence.

If this is not part of a structured append sequence, the returned value is -1. If it is a structured append symbol but the total number of symbols is unknown, the returned value is 0 (see PDF417 if optional "Segment Count" not given).

◆ sequenceIndex()

int ZXing::Barcode::sequenceIndex ( ) const

Returns the 0-based index of this symbol in a structured append sequence.

◆ sequenceId()

std::string ZXing::Barcode::sequenceId ( ) const

Returns the sequenceId to check if a set of symbols belongs to the same structured append sequence.

If the symbology does not support this feature, the returned value is empty (see MaxiCode). For QR Code, this is the parity integer converted to a string. For PDF417 and DataMatrix, this is the "fileId".

◆ isLastInSequence()

bool ZXing::Barcode::isLastInSequence ( ) const
inline

Returns whether this symbol is the last in a structured append sequence.

◆ isPartOfSequence()

bool ZXing::Barcode::isPartOfSequence ( ) const
inline

Returns whether this symbol is part of a structured append sequence.

◆ lineCount()

int ZXing::Barcode::lineCount ( ) const

Returns how many lines have been detected with this code (applies only to linear symbologies).

◆ symbol()

ImageView ZXing::Barcode::symbol ( ) const

Returns the bit matrix of the symbol as an ImageView.

◆ extra()

std::string ZXing::Barcode::extra ( std::string_view key = "") const

Retrieve supplementary metadata associated with this barcode.

Returns a string containing additional and symbology specific information. In form of a JSON object serialization. The optional parameter key can be used to retrieve a specific item only. Key values are case insensitive. See BarcodeExtra namespace for valid keys. If the key is not found or there is no info available, an empty string is returned.

◆ operator==()

bool ZXing::Barcode::operator== ( const Barcode & o) const

◆ MergeStructuredAppendSequence

Barcode MergeStructuredAppendSequence ( const Barcodes & barcodes)
friend

Merge a list of Barcodes from one Structured Append sequence to a single barcode.

◆ ReadBarcodes

Barcodes ReadBarcodes ( const ImageView & image,
const ReaderOptions & options = {} )
friend

Read barcodes from an ImageView

Parameters
imageview of the image data including layout and format
optionsoptional ReaderOptions to parameterize / speed up detection
Returns
List of Barcode found, may be empty

◆ CreateBarcode

Barcode CreateBarcode ( const void * ,
int ,
int ,
const CreatorOptions &  )
friend

◆ WriteBarcodeToImage

Image WriteBarcodeToImage ( const Barcode & barcode,
const WriterOptions & options = {} )
friend

Write barcode symbol to Image (Bitmap).

◆ WriteBarcodeToSVG

std::string WriteBarcodeToSVG ( const Barcode & barcode,
const WriterOptions & options = {} )
friend

Write barcode symbol to SVG.


The documentation for this class was generated from the following file: