26#include <NDEVR/Buffer.h>
27#include <NDEVR/String.h>
28#include <NDEVR/RGBColor.h>
70 static const Mode
ECI;
78 int numBitsCharCount[3];
90 Mode(
int mode,
int cc0,
int cc1,
int cc2);
259 static const char* ALPHANUMERIC_CHARSET;
302 private:
static int getFormatBits(Ecc ecl);
369 int minVersion = 1,
int maxVersion = 40,
int mask = -1,
bool boostEcl =
true);
388 Ecc errorCorrectionLevel;
464 private:
void drawFunctionPatterns();
472 private:
void drawFormatBits(
int msk);
488 void drawFinderPattern(
int x,
int y);
497 void drawAlignmentPattern(
int x,
int y);
508 void setFunctionModule(
uint04 x,
uint04 y,
bool isDark);
550 void applyMask(
int msk);
561 long getPenaltyScore()
const;
585 static int getNumRawDataModules(
int ver);
596 static int getNumDataCodewords(
int ver,
Ecc ecl);
622 static std::uint8_t reedSolomonMultiply(std::uint8_t x, std::uint8_t y);
632 uint04 finderPenaltyCountPatterns(
const std::array<int, 7>& runHistory)
const;
644 uint04 finderPenaltyTerminateAndCount(
bool currentRunColor,
int currentRunLength, std::array<int, 7>& runHistory)
const;
653 void finderPenaltyAddHistory(
int currentRunLength, std::array<int, 7>& runHistory)
const;
661 static bool getBit(
long x,
int i);
669 static const int PENALTY_N1;
670 static const int PENALTY_N2;
671 static const int PENALTY_N3;
672 static const int PENALTY_N4;
673 static const sint01 ECC_CODEWORDS_PER_BLOCK[4][41];
674 static const sint01 NUM_ERROR_CORRECTION_BLOCKS[4][41];
The equivelent of std::vector but with a bit more control.
constexpr Buffer() noexcept
void appendBits(uint04 val, uint04 len)
Appends the given number of low-order bits of the given value to this buffer.
QRBitBuffer()
Constructs an empty bit buffer.
static constexpr int MAX_VERSION
The maximum QR Code version number (40).
QrCode(int ver, Ecc ecl, const Buffer< std::uint8_t > &dataCodewords, int msk)
Creates a new QR Code with the given version number, error correction level, data codeword bytes,...
int getSize() const
Returns this QR Code's size (width and height in modules).
String toSVG(uint04 border, RGBColor color, RGBColor background=Constant< RGBColor >::Invalid) const
Generates an SVG (Scalable Vector Graphics) string representation of this QR Code.
int getVersion() const
Returns this QR Code's version number.
bool getModule(int x, int y) const
Returns the color of the module (pixel) at the given coordinates.
static QrCode encodeBinary(const uint01 *data, uint04 size, Ecc ecl)
Returns a QR Code representing the given binary data at the given error correction level.
Ecc getErrorCorrectionLevel() const
Returns this QR Code's error correction level.
static QrCode encodeSegments(const QrSegmentBuffer &segs, Ecc ecl, int minVersion=1, int maxVersion=40, int mask=-1, bool boostEcl=true)
Returns a QR Code representing the given segments with the given encoding parameters.
int getMask() const
Returns this QR Code's mask pattern index.
static constexpr int MIN_VERSION
The minimum QR Code version number (1).
static QrCode encodeText(const char *text, Ecc ecl)
Returns a QR Code representing the given Unicode text string at the given error correction level.
static QrCode encodeLink(const char *text, Ecc ecl)
Returns a QR Code representing the given link text at the given error correction level.
Ecc
The error correction level in a QR Code symbol.
Describes how a segment's data bits are interpreted.
static const Mode BYTE
Mode for encoding arbitrary binary data.
int numCharCountBits(int ver) const
Returns the bit width of the character count field for a segment in this mode at the given QR Code ve...
static const Mode ECI
Mode for Extended Channel Interpretation designators.
static const Mode NUMERIC
Mode for encoding decimal digit strings.
static const Mode ALPHANUMERIC
Mode for encoding alphanumeric text (0-9, A-Z, space, and select symbols).
static const Mode KANJI
Mode for encoding Shift JIS Kanji characters.
int getModeBits() const
Returns the mode indicator bits as an unsigned 4-bit value (range 0 to 15).
A segment of character, binary, or control data in a QR Code symbol.
const Mode & getMode() const
Returns the mode field of this segment.
static QrSegment makeAlphanumeric(const char *text)
Returns a segment representing the given text string encoded in alphanumeric mode.
static int getTotalBits(const QrSegmentBuffer &segs, int version)
Calculates the total number of bits needed to encode the given segments at the given version.
QrSegment(const Mode &md, int numCh, Buffer< bool > &&dt)
Creates a new QR Code segment with the given attributes and data (move).
static QrSegment makeBytes(const uint01 *data, uint04 size)
Returns a segment representing the given binary data encoded in byte mode.
static QrSegmentBuffer makeSegments(const char *text)
Returns a list of zero or more segments to represent the given text string.
static bool isAlphanumeric(const char *text)
Tests whether the given string can be encoded as a segment in alphanumeric mode.
const Buffer< bool > & getData() const
Returns the data bits of this segment.
int getNumChars() const
Returns the character count field of this segment.
static QrSegment makeEci(long assignVal)
Returns a segment representing an Extended Channel Interpretation (ECI) designator with the given ass...
static QrSegment makeNumeric(const char *digits)
Returns a segment representing the given string of decimal digits encoded in numeric mode.
QrSegment(const Mode &md, int numCh, const Buffer< bool > &dt)
Creates a new QR Code segment with the given attributes and data (copy).
static bool isNumeric(const char *text)
Tests whether the given string can be encoded as a segment in numeric mode.
Represents a color in the RGB space with optional alpha transparency.
The core String class for the NDEVR API.
data_too_long(const std::string &msg)
Constructs the exception with a descriptive message.
The primary namespace for the NDEVR SDK.
AlocatingAlignedBuffer< QrSegment, sizeof(void *)==4 ? 16 :32 > QrSegmentBuffer
Aligned buffer type alias for storing QrSegment objects.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
int8_t sint01
-Defines an alias representing a 1 byte, signed integer.