changing 'byte' references to 'zxing::byte'. Triggered by #90.

This commit is contained in:
favoritas37 2018-11-05 16:05:59 +02:00
parent e16429c233
commit 230a796a28
62 changed files with 272 additions and 272 deletions

View File

@ -3,7 +3,7 @@
//values based on http://entropymine.com/imageworsener/grayscale/
//round(0,2127*R)
const byte CameraImageWrapper::R_TO_GREYSCALE[256] = {
const zxing::byte CameraImageWrapper::R_TO_GREYSCALE[256] = {
0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9,
10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13,
@ -22,7 +22,7 @@ const byte CameraImageWrapper::R_TO_GREYSCALE[256] = {
//values based on http://entropymine.com/imageworsener/grayscale/
//round(0,7152*G)
const byte CameraImageWrapper::G_TO_GREYSCALE[256] = {
const zxing::byte CameraImageWrapper::G_TO_GREYSCALE[256] = {
0, 1, 1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 11, 12, 13,
14, 14, 15, 16, 16, 17, 18, 19, 19, 20, 21, 21, 22, 23, 24, 24,
25, 26, 26, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35,
@ -44,7 +44,7 @@ const byte CameraImageWrapper::G_TO_GREYSCALE[256] = {
//values based on http://entropymine.com/imageworsener/grayscale/
//round(0,0722*B)
const byte CameraImageWrapper::B_TO_GREYSCALE[256] = {
const zxing::byte CameraImageWrapper::B_TO_GREYSCALE[256] = {
0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
@ -101,12 +101,12 @@ CameraImageWrapper *CameraImageWrapper::Factory(const QImage &sourceImage, int m
return new CameraImageWrapper(sourceImage);
}
ArrayRef<ArrayRef<byte> > CameraImageWrapper::getOriginalImage()
ArrayRef<ArrayRef<zxing::byte> > CameraImageWrapper::getOriginalImage()
{
return imageBytesPerRow;
}
ArrayRef<byte> CameraImageWrapper::getRow(int y, ArrayRef<byte> row) const
ArrayRef<zxing::byte> CameraImageWrapper::getRow(int y, ArrayRef<zxing::byte> row) const
{
if(delegate)
return delegate->getRow(y, row);
@ -114,7 +114,7 @@ ArrayRef<byte> CameraImageWrapper::getRow(int y, ArrayRef<byte> row) const
return getRowP(y, row);
}
ArrayRef<byte> CameraImageWrapper::getMatrix() const
ArrayRef<zxing::byte> CameraImageWrapper::getMatrix() const
{
if(delegate)
return delegate->getMatrix();
@ -162,19 +162,19 @@ Ref<LuminanceSource> CameraImageWrapper::rotateCounterClockwise() const
return LuminanceSource::rotateCounterClockwise();
}
ArrayRef<byte> CameraImageWrapper::getRowP(int y, ArrayRef<byte> row) const
ArrayRef<zxing::byte> CameraImageWrapper::getRowP(int y, ArrayRef<zxing::byte> row) const
{
int width = getWidth();
if (row->size() != width)
row.reset(ArrayRef<byte>(width));
row.reset(ArrayRef<zxing::byte>(width));
Q_ASSERT(y >= 0 && y < getHeight());
return imageBytesPerRow[y];
}
ArrayRef<byte> CameraImageWrapper::getMatrixP() const
ArrayRef<zxing::byte> CameraImageWrapper::getMatrixP() const
{
return imageBytes;
}
@ -190,18 +190,18 @@ void CameraImageWrapper::updateImageAsGrayscale(const QImage &origin)
bool needsConvesionToGrayscale = origin.format() != QImage::Format_Grayscale8;
QRgb pixel;
byte pixelGrayscale;
zxing::byte pixelGrayscale;
const int width = getWidth();
const int height = getHeight();
imageBytes = ArrayRef<byte>(height*width);
imageBytesPerRow = ArrayRef<ArrayRef<byte>>(height);
imageBytes = ArrayRef<zxing::byte>(height*width);
imageBytesPerRow = ArrayRef<ArrayRef<zxing::byte>>(height);
byte* m = &imageBytes[0];
for(int j=0; j<height; j++)
{
ArrayRef<byte> line(width);
ArrayRef<zxing::byte> line(width);
for(int i=0; i<width; i++)
{
pixel = origin.pixel(i,j);
@ -218,7 +218,7 @@ void CameraImageWrapper::updateImageAsGrayscale(const QImage &origin)
#else
memcpy(m, &line[0], width);
#endif
m += width * sizeof(byte);
m += width * sizeof(zxing::byte);
}
}

View File

@ -33,7 +33,7 @@ public:
static CameraImageWrapper* Factory(const QImage& image, int maxWidth=-1, int maxHeight=-1, bool smoothTransformation=false);
ArrayRef<ArrayRef<byte> > getOriginalImage();
ArrayRef<ArrayRef<zxing::byte> > getOriginalImage();
Ref<GreyscaleLuminanceSource> getDelegate() { return delegate; }
ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const;
@ -45,7 +45,7 @@ public:
Ref<LuminanceSource> invert() const;
Ref<LuminanceSource> rotateCounterClockwise() const;
inline byte gray(unsigned int r, unsigned int g, unsigned int b);
inline zxing::byte gray(unsigned int r, unsigned int g, unsigned int b);
private:
ArrayRef<zxing::byte> getRowP(int y, ArrayRef<zxing::byte> row) const;
@ -53,12 +53,12 @@ private:
void updateImageAsGrayscale(const QImage &origin);
Ref<GreyscaleLuminanceSource> delegate;
ArrayRef<ArrayRef<byte>> imageBytesPerRow;
ArrayRef<byte> imageBytes;
ArrayRef<ArrayRef<zxing::byte>> imageBytesPerRow;
ArrayRef<zxing::byte> imageBytes;
static const byte B_TO_GREYSCALE[256];
static const byte G_TO_GREYSCALE[256];
static const byte R_TO_GREYSCALE[256];
static const zxing::byte B_TO_GREYSCALE[256];
static const zxing::byte G_TO_GREYSCALE[256];
static const zxing::byte R_TO_GREYSCALE[256];
};
#endif //CAMERAIMAGE_H

View File

@ -28,21 +28,21 @@ namespace zxing {
InvertedLuminanceSource::InvertedLuminanceSource(Ref<LuminanceSource> const& delegate_)
: Super(delegate_->getWidth(), delegate_->getHeight()), delegate(delegate_) {}
ArrayRef<byte> InvertedLuminanceSource::getRow(int y, ArrayRef<byte> row) const {
ArrayRef<zxing::byte> InvertedLuminanceSource::getRow(int y, ArrayRef<zxing::byte> row) const {
row = delegate->getRow(y, row);
int width = getWidth();
for (int i = 0; i < width; i++) {
row[i] = (byte) (255 - (row[i] & 0xFF));
row[i] = (zxing::byte) (255 - (row[i] & 0xFF));
}
return row;
}
ArrayRef<byte> InvertedLuminanceSource::getMatrix() const {
ArrayRef<byte> matrix = delegate->getMatrix();
ArrayRef<zxing::byte> InvertedLuminanceSource::getMatrix() const {
ArrayRef<zxing::byte> matrix = delegate->getMatrix();
int length = getWidth() * getHeight();
ArrayRef<byte> invertedMatrix(length);
ArrayRef<zxing::byte> invertedMatrix(length);
for (int i = 0; i < length; i++) {
invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF));
invertedMatrix[i] = (zxing::byte) (255 - (matrix[i] & 0xFF));
}
return invertedMatrix;
}

View File

@ -30,8 +30,8 @@ private:
public:
InvertedLuminanceSource(Ref<LuminanceSource> const&);
ArrayRef<byte> getRow(int y, ArrayRef<byte> row) const;
ArrayRef<byte> getMatrix() const;
ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const;
ArrayRef<zxing::byte> getMatrix() const;
boolean isCropSupported() const;
Ref<LuminanceSource> crop(int left, int top, int width, int height) const;

View File

@ -52,7 +52,7 @@ Ref<zxing::LuminanceSource> LuminanceSource::rotateCounterClockwise45() const
}
LuminanceSource::operator std::string() const {
ArrayRef<byte> row;
ArrayRef<zxing::byte> row;
std::ostringstream oss;
for (int y = 0; y < getHeight(); y++) {
row = getRow(y, row);

View File

@ -40,8 +40,8 @@ class LuminanceSource : public Counted {
int getHeight() const { return height; }
// Callers take ownership of the returned memory and must call delete [] on it themselves.
virtual ArrayRef<byte> getRow(int y, ArrayRef<byte> row) const = 0;
virtual ArrayRef<byte> getMatrix() const = 0;
virtual ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const = 0;
virtual ArrayRef<zxing::byte> getMatrix() const = 0;
virtual bool isCropSupported() const;
virtual Ref<LuminanceSource> crop(int left, int top, int width, int height) const;

View File

@ -33,7 +33,7 @@ using zxing::BarcodeFormat;
namespace zxing {
Result::Result(Ref<String> text,
ArrayRef<byte> rawBytes,
ArrayRef<zxing::byte> rawBytes,
ArrayRef< Ref<ResultPoint> > resultPoints,
BarcodeFormat format, std::string charSet) :
text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet) {
@ -46,7 +46,7 @@ Ref<String> Result::getText() {
return text_;
}
ArrayRef<byte> Result::getRawBytes() {
ArrayRef<zxing::byte> Result::getRawBytes() {
return rawBytes_;
}

View File

@ -33,19 +33,19 @@ namespace zxing {
class Result : public Counted {
private:
Ref<String> text_;
ArrayRef<byte> rawBytes_;
ArrayRef<zxing::byte> rawBytes_;
ArrayRef< Ref<ResultPoint> > resultPoints_;
BarcodeFormat format_;
std::string charSet_;
public:
Result(Ref<String> text,
ArrayRef<byte> rawBytes,
ArrayRef<zxing::byte> rawBytes,
ArrayRef< Ref<ResultPoint> > resultPoints,
BarcodeFormat format, std::string charSet = "");
~Result();
Ref<String> getText();
ArrayRef<byte> getRawBytes();
ArrayRef<zxing::byte> getRawBytes();
ArrayRef< Ref<ResultPoint> > const& getResultPoints() const;
ArrayRef< Ref<ResultPoint> >& getResultPoints();
BarcodeFormat getBarcodeFormat() const;

View File

@ -171,9 +171,9 @@ Ref<DecoderResult> Decoder::decode(Ref<zxing::aztec::AztecDetectorResult> detect
Ref<String> result = getEncodedData(aCorrectedBits);
// std::printf("constructing array\n");
ArrayRef<byte> arrayOut(aCorrectedBits->getSize());
ArrayRef<zxing::byte> arrayOut(aCorrectedBits->getSize());
for (int i = 0; i < aCorrectedBits->count(); i++) {
arrayOut[i] = (byte)aCorrectedBits->get(i);
arrayOut[i] = (zxing::byte)aCorrectedBits->get(i);
}
// std::printf("returning\n");

View File

@ -261,7 +261,7 @@ void BitArray::xor_(const BitArray& other)
}
}
void BitArray::toBytes(int bitOffset, std::vector<byte>& array, int offset, int numBytes) const
void BitArray::toBytes(int bitOffset, std::vector<zxing::byte>& array, int offset, int numBytes) const
{
if(array.size() < (numBytes + offset))
array.resize(numBytes + offset);
@ -274,7 +274,7 @@ void BitArray::toBytes(int bitOffset, std::vector<byte>& array, int offset, int
}
bitOffset++;
}
array[offset + i] = (byte) theByte;
array[offset + i] = (zxing::byte) theByte;
}
}

View File

@ -74,7 +74,7 @@ public:
void xor_(const BitArray& other);
void toBytes(int bitOffset, std::vector<byte>& array, int offset, int numBytes) const;
void toBytes(int bitOffset, std::vector<zxing::byte>& array, int offset, int numBytes) const;
const std::string toString() const;

View File

@ -35,7 +35,7 @@ namespace zxing {
*/
class BitSource : public Counted {
private:
ArrayRef<byte> bytes_;
ArrayRef<zxing::byte> bytes_;
int byteOffset_;
int bitOffset_;
public:
@ -43,7 +43,7 @@ public:
* @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
* Bits are read within a byte from most-significant to least-significant bit.
*/
BitSource(ArrayRef<byte> &bytes) :
BitSource(ArrayRef<zxing::byte> &bytes) :
bytes_(bytes), byteOffset_(0), bitOffset_(0) {
}

View File

@ -24,16 +24,16 @@
using namespace std;
using namespace zxing;
DecoderResult::DecoderResult(ArrayRef<byte> rawBytes,
DecoderResult::DecoderResult(ArrayRef<zxing::byte> rawBytes,
Ref<String> text,
ArrayRef< ArrayRef<byte> >& byteSegments,
ArrayRef< ArrayRef<zxing::byte> >& byteSegments,
string const& ecLevel, string charSet) :
rawBytes_(rawBytes),
text_(text),
byteSegments_(byteSegments),
ecLevel_(ecLevel), charSet_(charSet) {}
DecoderResult::DecoderResult(ArrayRef<byte> rawBytes,
DecoderResult::DecoderResult(ArrayRef<zxing::byte> rawBytes,
Ref<String> text)
: rawBytes_(rawBytes), text_(text),charSet_("") {}

View File

@ -30,22 +30,22 @@ namespace zxing {
class DecoderResult : public Counted {
private:
ArrayRef<byte> rawBytes_;
ArrayRef<zxing::byte> rawBytes_;
Ref<String> text_;
ArrayRef< ArrayRef<byte> > byteSegments_;
ArrayRef< ArrayRef<zxing::byte> > byteSegments_;
std::string ecLevel_;
std::string charSet_;
public:
DecoderResult(ArrayRef<byte> rawBytes,
DecoderResult(ArrayRef<zxing::byte> rawBytes,
Ref<String> text,
ArrayRef< ArrayRef<byte> >& byteSegments,
ArrayRef< ArrayRef<zxing::byte> >& byteSegments,
std::string const& ecLevel,
std::string charSet = "");
DecoderResult(ArrayRef<byte> rawBytes, Ref<String> text);
DecoderResult(ArrayRef<zxing::byte> rawBytes, Ref<String> text);
ArrayRef<byte> getRawBytes();
ArrayRef<zxing::byte> getRawBytes();
Ref<String> getText();
std::string charSet();
};

View File

@ -36,7 +36,7 @@ namespace zxing {
const int LUMINANCE_BITS = 5;
const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
const ArrayRef<byte> EMPTY (0);
const ArrayRef<zxing::byte> EMPTY (0);
GlobalHistogramBinarizer::GlobalHistogramBinarizer(Ref<LuminanceSource> source)
: Binarizer(source), luminances(EMPTY), buckets(LUMINANCE_BUCKETS) {}
@ -45,7 +45,7 @@ GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {}
void GlobalHistogramBinarizer::initArrays(int luminanceSize) {
if (luminances->size() < luminanceSize) {
luminances = ArrayRef<byte>(luminanceSize);
luminances = ArrayRef<zxing::byte>(luminanceSize);
}
// for (int x = 0; x < LUMINANCE_BUCKETS; x++) {
// buckets[x] = 0;
@ -64,7 +64,7 @@ Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
}
initArrays(width);
ArrayRef<byte> localLuminances = source.getRow(y, luminances);
ArrayRef<zxing::byte> localLuminances = source.getRow(y, luminances);
if (false) {
std::cerr << "gbr " << y << " r ";
for(int i=0, e=localLuminances->size(); i < e; ++i) {
@ -108,7 +108,7 @@ Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
ArrayRef<int> localBuckets = buckets;
for (int y = 1; y < 5; y++) {
int row = height * y / 5;
ArrayRef<byte> localLuminances = source.getRow(row, luminances);
ArrayRef<zxing::byte> localLuminances = source.getRow(row, luminances);
int right = (width << 2) / 5;
for (int x = width / 5; x < right; x++) {
int pixel = localLuminances[x] & 0xff;
@ -118,7 +118,7 @@ Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
int blackPoint = estimateBlackPoint(localBuckets);
ArrayRef<byte> localLuminances = source.getMatrix();
ArrayRef<zxing::byte> localLuminances = source.getMatrix();
for (int y = 0; y < height; y++) {
int offset = y * width;
for (int x = 0; x < width; x++) {

View File

@ -29,7 +29,7 @@ namespace zxing {
class GlobalHistogramBinarizer : public Binarizer {
private:
ArrayRef<byte> luminances;
ArrayRef<zxing::byte> luminances;
ArrayRef<int> buckets;
public:
GlobalHistogramBinarizer(Ref<LuminanceSource> source);

View File

@ -29,7 +29,7 @@ using zxing::LuminanceSource;
namespace zxing {
GreyscaleLuminanceSource::
GreyscaleLuminanceSource(ArrayRef<byte> greyData,
GreyscaleLuminanceSource(ArrayRef<zxing::byte> greyData,
int dataWidth, int dataHeight,
int left, int top,
int width, int height)
@ -43,13 +43,13 @@ GreyscaleLuminanceSource(ArrayRef<byte> greyData,
}
}
ArrayRef<byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<byte> row) const {
ArrayRef<zxing::byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<zxing::byte> row) const {
if (y < 0 || y >= this->getHeight()) {
throw IllegalArgumentException("Requested row is outside the image.");
}
int width = getWidth();
if (!row || row->size() < width) {
ArrayRef<byte> temp (width);
ArrayRef<zxing::byte> temp (width);
row = temp;
}
int offset = (y + top_) * dataWidth_ + left_;
@ -57,12 +57,12 @@ ArrayRef<byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<byte> row) const
return row;
}
ArrayRef<byte> GreyscaleLuminanceSource::getMatrix() const {
ArrayRef<zxing::byte> GreyscaleLuminanceSource::getMatrix() const {
if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) {
return greyData_;
} else {
int size = getWidth() * getHeight();
ArrayRef<byte> result (size);
ArrayRef<zxing::byte> result (size);
for (int row = 0; row < getHeight(); row++) {
memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth());
}

View File

@ -28,18 +28,18 @@ class GreyscaleLuminanceSource : public LuminanceSource {
private:
typedef LuminanceSource Super;
ArrayRef<byte> greyData_;
ArrayRef<zxing::byte> greyData_;
const int dataWidth_;
const int dataHeight_;
const int left_;
const int top_;
public:
GreyscaleLuminanceSource(ArrayRef<byte> greyData, int dataWidth, int dataHeight, int left,
GreyscaleLuminanceSource(ArrayRef<zxing::byte> greyData, int dataWidth, int dataHeight, int left,
int top, int width, int height);
ArrayRef<byte> getRow(int y, ArrayRef<byte> row) const;
ArrayRef<byte> getMatrix() const;
ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const;
ArrayRef<zxing::byte> getMatrix() const;
bool isRotateSupported() const {
return true;

View File

@ -30,7 +30,7 @@ namespace zxing {
// be able to traverse the greyData correctly, which does not get
// rotated.
GreyscaleRotatedLuminanceSource::
GreyscaleRotatedLuminanceSource(ArrayRef<byte> greyData,
GreyscaleRotatedLuminanceSource(ArrayRef<zxing::byte> greyData,
int dataWidth, int dataHeight,
int left, int top,
int width, int height)
@ -45,13 +45,13 @@ GreyscaleRotatedLuminanceSource(ArrayRef<byte> greyData,
}
// The API asks for rows, but we're rotated, so we return columns.
ArrayRef<byte>
GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef<byte> row) const {
ArrayRef<zxing::byte>
GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef<zxing::byte> row) const {
if (y < 0 || y >= getHeight()) {
throw IllegalArgumentException("Requested row is outside the image.");
}
if (!row || row->size() < getWidth()) {
row = ArrayRef<byte>(getWidth());
row = ArrayRef<zxing::byte>(getWidth());
}
int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_));
using namespace std;
@ -68,8 +68,8 @@ GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef<byte> row) const {
return row;
}
ArrayRef<byte> GreyscaleRotatedLuminanceSource::getMatrix() const {
ArrayRef<byte> result (getWidth() * getHeight());
ArrayRef<zxing::byte> GreyscaleRotatedLuminanceSource::getMatrix() const {
ArrayRef<zxing::byte> result (getWidth() * getHeight());
for (int y = 0; y < getHeight(); y++) {
byte* row = &result[y * getWidth()];
int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_));

View File

@ -28,17 +28,17 @@ namespace zxing {
class GreyscaleRotatedLuminanceSource : public LuminanceSource {
private:
typedef LuminanceSource Super;
ArrayRef<byte> greyData_;
ArrayRef<zxing::byte> greyData_;
const int dataWidth_;
const int left_;
const int top_;
public:
GreyscaleRotatedLuminanceSource(ArrayRef<byte> greyData, int dataWidth, int dataHeight,
GreyscaleRotatedLuminanceSource(ArrayRef<zxing::byte> greyData, int dataWidth, int dataHeight,
int left, int top, int width, int height);
ArrayRef<byte> getRow(int y, ArrayRef<byte> row) const;
ArrayRef<byte> getMatrix() const;
ArrayRef<zxing::byte> getRow(int y, ArrayRef<zxing::byte> row) const;
ArrayRef<zxing::byte> getMatrix() const;
};
}

View File

@ -59,7 +59,7 @@ Ref<BitMatrix> HybridBinarizer::getBlackMatrix() {
int width = source.getWidth();
int height = source.getHeight();
if (width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION) {
ArrayRef<byte> luminances = source.getMatrix();
ArrayRef<zxing::byte> luminances = source.getMatrix();
int subWidth = width >> BLOCK_SIZE_POWER;
if ((width & BLOCK_SIZE_MASK) != 0) {
subWidth++;
@ -94,7 +94,7 @@ namespace {
}
void
HybridBinarizer::calculateThresholdForBlock(ArrayRef<byte> luminances,
HybridBinarizer::calculateThresholdForBlock(ArrayRef<zxing::byte> luminances,
int subWidth,
int subHeight,
int width,
@ -130,7 +130,7 @@ HybridBinarizer::calculateThresholdForBlock(ArrayRef<byte> luminances,
}
}
void HybridBinarizer::thresholdBlock(ArrayRef<byte> luminances,
void HybridBinarizer::thresholdBlock(ArrayRef<zxing::byte> luminances,
int xoffset,
int yoffset,
int threshold,
@ -157,7 +157,7 @@ namespace {
}
ArrayRef<int> HybridBinarizer::calculateBlackPoints(ArrayRef<byte> luminances,
ArrayRef<int> HybridBinarizer::calculateBlackPoints(ArrayRef<zxing::byte> luminances,
int subWidth,
int subHeight,
int width,

View File

@ -42,19 +42,19 @@ namespace zxing {
private:
// We'll be using one-D arrays because C++ can't dynamically allocate 2D
// arrays
ArrayRef<int> calculateBlackPoints(ArrayRef<byte> luminances,
ArrayRef<int> calculateBlackPoints(ArrayRef<zxing::byte> luminances,
int subWidth,
int subHeight,
int width,
int height);
void calculateThresholdForBlock(ArrayRef<byte> luminances,
void calculateThresholdForBlock(ArrayRef<zxing::byte> luminances,
int subWidth,
int subHeight,
int width,
int height,
ArrayRef<int> blackPoints,
Ref<BitMatrix> const& matrix);
void thresholdBlock(ArrayRef<byte>luminances,
void thresholdBlock(ArrayRef<zxing::byte>luminances,
int xoffset,
int yoffset,
int threshold,

View File

@ -67,9 +67,9 @@ StringUtils::guessEncoding(byte* bytes, int length,
typedef byte byte;
boolean utf8bom = length > 3 &&
bytes[0] == (byte) 0xEF &&
bytes[1] == (byte) 0xBB &&
bytes[2] == (byte) 0xBF;
bytes[0] == (zxing::byte) 0xEF &&
bytes[1] == (zxing::byte) 0xBB &&
bytes[2] == (zxing::byte) 0xBF;
for (int i = 0;
i < length && (canBeISO88591 || canBeShiftJIS || canBeUTF8);

View File

@ -44,7 +44,7 @@ public:
typedef std::map<DecodeHintType, std::string> Hashtable;
static std::string guessEncoding(byte *bytes, int length, Hashtable const& hints);
static std::string guessEncoding(zxing::byte *bytes, int length, Hashtable const& hints);
static std::string intToStr(int number);
};

View File

@ -33,7 +33,7 @@ Ref<GenericGFPoly> ReedSolomonEncoder::buildGenerator(int degree)
return cachedGenerators_.at(degree); // ??? wont this through exception?
}
void ReedSolomonEncoder::encode(std::vector<byte> &toEncode, int ecBytes)
void ReedSolomonEncoder::encode(std::vector<zxing::byte> &toEncode, int ecBytes)
{
if (ecBytes == 0) {
throw Exception("No error correction bytes");

View File

@ -19,7 +19,7 @@ private:
public:
ReedSolomonEncoder(Ref<GenericGF> field);
void encode(std::vector<byte> &toEncode, int ecBytes);
void encode(std::vector<zxing::byte> &toEncode, int ecBytes);
};
}

View File

@ -41,7 +41,7 @@ private:
public:
BitMatrixParser(Ref<BitMatrix> bitMatrix);
Ref<Version> readVersion(Ref<BitMatrix> bitMatrix);
ArrayRef<byte> readCodewords();
ArrayRef<zxing::byte> readCodewords();
bool readModule(int row, int column, int numRows, int numColumns);
private:

View File

@ -32,15 +32,15 @@ namespace datamatrix {
class DataBlock : public Counted {
private:
int numDataCodewords_;
ArrayRef<byte> codewords_;
ArrayRef<zxing::byte> codewords_;
DataBlock(int numDataCodewords, ArrayRef<byte> codewords);
DataBlock(int numDataCodewords, ArrayRef<zxing::byte> codewords);
public:
static std::vector<Ref<DataBlock> > getDataBlocks(ArrayRef<byte> rawCodewords, Version *version);
static std::vector<Ref<DataBlock> > getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Version *version);
int getNumDataCodewords();
ArrayRef<byte> getCodewords();
ArrayRef<zxing::byte> getCodewords();
};
}

View File

@ -57,8 +57,8 @@ Ref<Version> BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) {
throw ReaderException("Couldn't decode version");
}
ArrayRef<byte> BitMatrixParser::readCodewords() {
ArrayRef<byte> result(parsedVersion_->getTotalCodewords());
ArrayRef<zxing::byte> BitMatrixParser::readCodewords() {
ArrayRef<zxing::byte> result(parsedVersion_->getTotalCodewords());
int resultOffset = 0;
int row = 4;
int column = 0;
@ -75,22 +75,22 @@ ArrayRef<byte> BitMatrixParser::readCodewords() {
do {
// Check the four corner cases
if ((row == numRows) && (column == 0) && !corner1Read) {
result[resultOffset++] = (byte) readCorner1(numRows, numColumns);
result[resultOffset++] = (zxing::byte) readCorner1(numRows, numColumns);
row -= 2;
column +=2;
corner1Read = true;
} else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) {
result[resultOffset++] = (byte) readCorner2(numRows, numColumns);
result[resultOffset++] = (zxing::byte) readCorner2(numRows, numColumns);
row -= 2;
column +=2;
corner2Read = true;
} else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) {
result[resultOffset++] = (byte) readCorner3(numRows, numColumns);
result[resultOffset++] = (zxing::byte) readCorner3(numRows, numColumns);
row -= 2;
column +=2;
corner3Read = true;
} else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) {
result[resultOffset++] = (byte) readCorner4(numRows, numColumns);
result[resultOffset++] = (zxing::byte) readCorner4(numRows, numColumns);
row -= 2;
column +=2;
corner4Read = true;
@ -98,7 +98,7 @@ ArrayRef<byte> BitMatrixParser::readCodewords() {
// Sweep upward diagonally to the right
do {
if ((row < numRows) && (column >= 0) && !readBitMatrix_->get(column, row)) {
result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns);
result[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns);
}
row -= 2;
column +=2;
@ -109,7 +109,7 @@ ArrayRef<byte> BitMatrixParser::readCodewords() {
// Sweep downward diagonally to the left
do {
if ((row >= 0) && (column < numColumns) && !readBitMatrix_->get(column, row)) {
result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns);
result[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns);
}
row += 2;
column -=2;

View File

@ -26,7 +26,7 @@ namespace datamatrix {
using namespace std;
DataBlock::DataBlock(int numDataCodewords, ArrayRef<byte> codewords) :
DataBlock::DataBlock(int numDataCodewords, ArrayRef<zxing::byte> codewords) :
numDataCodewords_(numDataCodewords), codewords_(codewords) {
}
@ -34,11 +34,11 @@ int DataBlock::getNumDataCodewords() {
return numDataCodewords_;
}
ArrayRef<byte> DataBlock::getCodewords() {
ArrayRef<zxing::byte> DataBlock::getCodewords() {
return codewords_;
}
std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<byte> rawCodewords, Version *version) {
std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Version *version) {
// Figure out the number and size of data blocks used by this version and
// error correction level
ECBlocks* ecBlocks = version->getECBlocks();
@ -58,7 +58,7 @@ std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<byte> rawCodeword
for (int i = 0; i < ecBlock->getCount(); i++) {
int numDataCodewords = ecBlock->getDataCodewords();
int numBlockCodewords = ecBlocks->getECCodewords() + numDataCodewords;
ArrayRef<byte> buffer(numBlockCodewords);
ArrayRef<zxing::byte> buffer(numBlockCodewords);
Ref<DataBlock> blockRef(new DataBlock(numDataCodewords, buffer));
result[numResultBlocks++] = blockRef;
}

View File

@ -48,14 +48,14 @@ const char DecodedBitStreamParser::TEXT_BASIC_SET_CHARS[] = {
const char DecodedBitStreamParser::TEXT_SHIFT3_SET_CHARS[] = {
'\'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (byte) 127
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (zxing::byte) 127
};
Ref<DecoderResult> DecodedBitStreamParser::decode(ArrayRef<byte> bytes) {
Ref<DecoderResult> DecodedBitStreamParser::decode(ArrayRef<zxing::byte> bytes) {
Ref<BitSource> bits(new BitSource(bytes));
ostringstream result;
ostringstream resultTrailer;
vector<byte> byteSegments;
vector<zxing::byte> byteSegments;
int mode = ASCII_ENCODE;
do {
if (mode == ASCII_ENCODE) {
@ -87,7 +87,7 @@ Ref<DecoderResult> DecodedBitStreamParser::decode(ArrayRef<byte> bytes) {
if (resultTrailer.str().size() > 0) {
result << resultTrailer.str();
}
ArrayRef<byte> rawBytes(bytes);
ArrayRef<zxing::byte> rawBytes(bytes);
Ref<String> text(new String(result.str()));
return Ref<DecoderResult>(new DecoderResult(rawBytes, text));
}
@ -102,7 +102,7 @@ int DecodedBitStreamParser::decodeAsciiSegment(Ref<BitSource> bits, ostringstrea
} else if (oneByte <= 128) { // ASCII data (ASCII value + 1)
oneByte = upperShift ? (oneByte + 128) : oneByte;
// upperShift = false;
result << (byte) (oneByte - 1);
result << (zxing::byte) (oneByte - 1);
return ASCII_ENCODE;
} else if (oneByte == 129) { // Pad
return PAD_ENCODE;
@ -117,7 +117,7 @@ int DecodedBitStreamParser::decodeAsciiSegment(Ref<BitSource> bits, ostringstrea
} else if (oneByte == 231) { // Latch to Base 256 encodation
return BASE256_ENCODE;
} else if (oneByte == 232) { // FNC1
result << ((byte) 29); // translate as ASCII 29
result << ((zxing::byte) 29); // translate as ASCII 29
} else if (oneByte == 233 || oneByte == 234) {
// Structured Append, Reader Programming
// Ignore these symbols for now
@ -178,7 +178,7 @@ void DecodedBitStreamParser::decodeC40Segment(Ref<BitSource> bits, ostringstream
shift = cValue + 1;
} else {
if (upperShift) {
result << (byte) (C40_BASIC_SET_CHARS[cValue] + 128);
result << (zxing::byte) (C40_BASIC_SET_CHARS[cValue] + 128);
upperShift = false;
} else {
result << C40_BASIC_SET_CHARS[cValue];
@ -187,23 +187,23 @@ void DecodedBitStreamParser::decodeC40Segment(Ref<BitSource> bits, ostringstream
break;
case 1:
if (upperShift) {
result << (byte) (cValue + 128);
result << (zxing::byte) (cValue + 128);
upperShift = false;
} else {
result << (byte) cValue;
result << (zxing::byte) cValue;
}
shift = 0;
break;
case 2:
if (cValue < 27) {
if (upperShift) {
result << (byte) (C40_SHIFT2_SET_CHARS[cValue] + 128);
result << (zxing::byte) (C40_SHIFT2_SET_CHARS[cValue] + 128);
upperShift = false;
} else {
result << C40_SHIFT2_SET_CHARS[cValue];
}
} else if (cValue == 27) { // FNC1
result << ((byte) 29); // translate as ASCII 29
result << ((zxing::byte) 29); // translate as ASCII 29
} else if (cValue == 30) { // Upper Shift
upperShift = true;
} else {
@ -213,10 +213,10 @@ void DecodedBitStreamParser::decodeC40Segment(Ref<BitSource> bits, ostringstream
break;
case 3:
if (upperShift) {
result << (byte) (cValue + 224);
result << (zxing::byte) (cValue + 224);
upperShift = false;
} else {
result << (byte) (cValue + 96);
result << (zxing::byte) (cValue + 96);
}
shift = 0;
break;
@ -255,7 +255,7 @@ void DecodedBitStreamParser::decodeTextSegment(Ref<BitSource> bits, ostringstrea
shift = cValue + 1;
} else {
if (upperShift) {
result << (byte) (TEXT_BASIC_SET_CHARS[cValue] + 128);
result << (zxing::byte) (TEXT_BASIC_SET_CHARS[cValue] + 128);
upperShift = false;
} else {
result << (TEXT_BASIC_SET_CHARS[cValue]);
@ -264,10 +264,10 @@ void DecodedBitStreamParser::decodeTextSegment(Ref<BitSource> bits, ostringstrea
break;
case 1:
if (upperShift) {
result << (byte) (cValue + 128);
result << (zxing::byte) (cValue + 128);
upperShift = false;
} else {
result << (byte) (cValue);
result << (zxing::byte) (cValue);
}
shift = 0;
break;
@ -275,13 +275,13 @@ void DecodedBitStreamParser::decodeTextSegment(Ref<BitSource> bits, ostringstrea
// Shift 2 for Text is the same encoding as C40
if (cValue < 27) {
if (upperShift) {
result << (byte) (C40_SHIFT2_SET_CHARS[cValue] + 128);
result << (zxing::byte) (C40_SHIFT2_SET_CHARS[cValue] + 128);
upperShift = false;
} else {
result << (C40_SHIFT2_SET_CHARS[cValue]);
}
} else if (cValue == 27) { // FNC1
result << ((byte) 29); // translate as ASCII 29
result << ((zxing::byte) 29); // translate as ASCII 29
} else if (cValue == 30) { // Upper Shift
upperShift = true;
} else {
@ -291,7 +291,7 @@ void DecodedBitStreamParser::decodeTextSegment(Ref<BitSource> bits, ostringstrea
break;
case 3:
if (upperShift) {
result << (byte) (TEXT_SHIFT3_SET_CHARS[cValue] + 128);
result << (zxing::byte) (TEXT_SHIFT3_SET_CHARS[cValue] + 128);
upperShift = false;
} else {
result << (TEXT_SHIFT3_SET_CHARS[cValue]);
@ -333,9 +333,9 @@ void DecodedBitStreamParser::decodeAnsiX12Segment(Ref<BitSource> bits, ostringst
} else if (cValue == 3) { // space
result << ' ';
} else if (cValue < 14) { // 0 - 9
result << (byte) (cValue + 44);
result << (zxing::byte) (cValue + 44);
} else if (cValue < 40) { // A - Z
result << (byte) (cValue + 51);
result << (zxing::byte) (cValue + 51);
} else {
throw FormatException("decodeAnsiX12Segment: no case");
}
@ -376,12 +376,12 @@ void DecodedBitStreamParser::decodeEdifactSegment(Ref<BitSource> bits, ostringst
if ((edifactValue & 0x20) == 0) { // no 1 in the leading (6th) bit
edifactValue |= 0x40; // Add a leading 01 to the 6 bit binary value
}
result << (byte)(edifactValue);
result << (zxing::byte)(edifactValue);
}
} while (bits->available() > 0);
}
void DecodedBitStreamParser::decodeBase256Segment(Ref<BitSource> bits, ostringstream& result, vector<byte> byteSegments) {
void DecodedBitStreamParser::decodeBase256Segment(Ref<BitSource> bits, ostringstream& result, vector<zxing::byte> byteSegments) {
// Figure out how long the Base 256 Segment is.
int codewordPosition = 1 + bits->getByteOffset(); // position is 1-indexed
int d1 = unrandomize255State(bits->readBits(8), codewordPosition++);
@ -408,7 +408,7 @@ void DecodedBitStreamParser::decodeBase256Segment(Ref<BitSource> bits, ostringst
}
bytes[i] = unrandomize255State(bits->readBits(8), codewordPosition++);
byteSegments.push_back(bytes[i]);
result << (byte)bytes[i];
result << (zxing::byte)bytes[i];
}
delete [] bytes;
}

View File

@ -42,7 +42,7 @@ namespace datamatrix {
Decoder::Decoder() : rsDecoder_(GenericGF::DATA_MATRIX_FIELD_256) {}
void Decoder::correctErrors(ArrayRef<byte> codewordBytes, int numDataCodewords) {
void Decoder::correctErrors(ArrayRef<zxing::byte> codewordBytes, int numDataCodewords) {
int numCodewords = codewordBytes->size();
ArrayRef<int> codewordInts(numCodewords);
for (int i = 0; i < numCodewords; i++) {
@ -58,7 +58,7 @@ void Decoder::correctErrors(ArrayRef<byte> codewordBytes, int numDataCodewords)
// Copy back into array of bytes -- only need to worry about the bytes that were data
// We don't care about errors in the error-correction codewords
for (int i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (byte)codewordInts[i];
codewordBytes[i] = (zxing::byte)codewordInts[i];
}
}
@ -68,7 +68,7 @@ Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
Version *version = parser.readVersion(bits);
// Read codewords
ArrayRef<byte> codewords(parser.readCodewords());
ArrayRef<zxing::byte> codewords(parser.readCodewords());
// Separate into data blocks
std::vector<Ref<DataBlock> > dataBlocks = DataBlock::getDataBlocks(codewords, version);
@ -79,12 +79,12 @@ Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
for (int i = 0; i < dataBlocksCount; i++) {
totalBytes += dataBlocks[i]->getNumDataCodewords();
}
ArrayRef<byte> resultBytes(totalBytes);
ArrayRef<zxing::byte> resultBytes(totalBytes);
// Error-correct and copy data blocks together into a stream of bytes
for (int j = 0; j < dataBlocksCount; j++) {
Ref<DataBlock> dataBlock(dataBlocks[j]);
ArrayRef<byte> codewordBytes = dataBlock->getCodewords();
ArrayRef<zxing::byte> codewordBytes = dataBlock->getCodewords();
int numDataCodewords = dataBlock->getNumDataCodewords();
correctErrors(codewordBytes, numDataCodewords);
for (int i = 0; i < numDataCodewords; i++) {

View File

@ -79,7 +79,7 @@ private:
/**
* See ISO 16022:2006, 5.2.9 and Annex B, B.2
*/
void decodeBase256Segment(Ref<BitSource> bits, std::ostringstream &result, std::vector<byte> byteSegments);
void decodeBase256Segment(Ref<BitSource> bits, std::ostringstream &result, std::vector<zxing::byte> byteSegments);
void parseTwoBytes(int firstByte, int secondByte, int* result);
/**
@ -89,13 +89,13 @@ private:
int base256CodewordPosition) {
int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1;
int tempVariable = randomizedBase256Codeword - pseudoRandomNumber;
return (byte) (tempVariable >= 0 ? tempVariable : (tempVariable + 256));
return (zxing::byte) (tempVariable >= 0 ? tempVariable : (tempVariable + 256));
};
void append(std::ostream &ost, const char *bufIn, size_t nIn, const char *src);
public:
DecodedBitStreamParser() { };
Ref<DecoderResult> decode(ArrayRef<byte> bytes);
Ref<DecoderResult> decode(ArrayRef<zxing::byte> bytes);
};
}

View File

@ -35,7 +35,7 @@ class Decoder {
private:
ReedSolomonDecoder rsDecoder_;
void correctErrors(ArrayRef<byte> bytes, int numDataCodewords);
void correctErrors(ArrayRef<zxing::byte> bytes, int numDataCodewords);
public:
Decoder();

View File

@ -96,7 +96,7 @@ Ref<Result> CodaBarReader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
// Hack: We store the position in the alphabet table into a
// StringBuilder, so that we can access the decoded patterns in
// validatePattern. We'll translate to the actual characters later.
decodeRowResult.append(1, (byte)charOffset);
decodeRowResult.append(1, (zxing::byte)charOffset);
nextStart += 8;
// Stop as soon as we see the end character.
if (decodeRowResult.length() > 1 &&
@ -161,7 +161,7 @@ Ref<Result> CodaBarReader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
Ref<OneDResultPoint>(new OneDResultPoint(right, (float) rowNumber));
return Ref<Result>(new Result(Ref<String>(new String(decodeRowResult)),
ArrayRef<byte>(),
ArrayRef<zxing::byte>(),
resultPoints,
BarcodeFormat::CODABAR));
}

View File

@ -273,7 +273,7 @@ Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
bool isNextShifted = false;
string result;
vector<byte> rawCodes(20, 0);
vector<zxing::byte> rawCodes(20, 0);
int lastStart = startPatternInfo[0];
int nextStart = startPatternInfo[1];
@ -329,16 +329,16 @@ Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
case CODE_CODE_A:
if (code < 64) {
if (shiftUpperMode == upperMode) {
result.append(1,(byte) (' ' + code));
result.append(1,(zxing::byte) (' ' + code));
} else {
result.append(1,(byte) (' ' + code + 128));
result.append(1,(zxing::byte) (' ' + code + 128));
}
shiftUpperMode = false;
} else if (code < 96) {
if (shiftUpperMode == upperMode) {
result.append(1, (byte) (code - 64));
result.append(1, (zxing::byte) (code - 64));
} else {
result.append(1, (byte) (code + 64));
result.append(1, (zxing::byte) (code + 64));
}
shiftUpperMode = false;
} else {
@ -356,7 +356,7 @@ Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
result.append("]C1");
} else {
// GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS)
result.append(1, (byte) 29);
result.append(1, (zxing::byte) 29);
}
}
break;
@ -393,9 +393,9 @@ Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
case CODE_CODE_B:
if (code < 96) {
if (shiftUpperMode == upperMode) {
result.append(1, (byte) (' ' + code));
result.append(1, (zxing::byte) (' ' + code));
} else {
result.append(1, (byte) (' ' + code + 128));
result.append(1, (zxing::byte) (' ' + code + 128));
}
shiftUpperMode = false;
} else {
@ -411,7 +411,7 @@ Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
result.append("]C1");
} else {
// GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS)
result.append(1, (byte) 29);
result.append(1, (zxing::byte) 29);
}
}
break;
@ -467,7 +467,7 @@ Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
result.append("]C1");
} else {
// GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS)
result.append(1, (byte) 29);
result.append(1, (zxing::byte) 29);
}
}
break;
@ -532,7 +532,7 @@ Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
float right = lastStart + lastPatternSize / 2.0f;
int rawCodesSize = rawCodes.size();
ArrayRef<byte> rawBytes (rawCodesSize);
ArrayRef<zxing::byte> rawBytes (rawCodesSize);
for (int i = 0; i < rawCodesSize; i++) {
rawBytes[i] = rawCodes[i];
}

View File

@ -171,7 +171,7 @@ Ref<Result> Code39Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::Dec
Ref<OneDResultPoint>(new OneDResultPoint(right, (float) rowNumber));
return Ref<Result>(
new Result(resultString, ArrayRef<byte>(), resultPoints, BarcodeFormat::CODE_39)
new Result(resultString, ArrayRef<zxing::byte>(), resultPoints, BarcodeFormat::CODE_39)
);
}
@ -283,7 +283,7 @@ Ref<String> Code39Reader::decodeExtended(std::string encoded){
case '+':
// +A to +Z map to a to z
if (next >= 'A' && next <= 'Z') {
decodedChar = (byte) (next + 32);
decodedChar = (zxing::byte) (next + 32);
} else {
throw ReaderException("");
}
@ -291,7 +291,7 @@ Ref<String> Code39Reader::decodeExtended(std::string encoded){
case '$':
// $A to $Z map to control codes SH to SB
if (next >= 'A' && next <= 'Z') {
decodedChar = (byte) (next - 64);
decodedChar = (zxing::byte) (next - 64);
} else {
throw ReaderException("");
}
@ -299,9 +299,9 @@ Ref<String> Code39Reader::decodeExtended(std::string encoded){
case '%':
// %A to %E map to control codes ESC to US
if (next >= 'A' && next <= 'E') {
decodedChar = (byte) (next - 38);
decodedChar = (zxing::byte) (next - 38);
} else if (next >= 'F' && next <= 'W') {
decodedChar = (byte) (next - 11);
decodedChar = (zxing::byte) (next - 11);
} else {
throw ReaderException("");
}
@ -309,7 +309,7 @@ Ref<String> Code39Reader::decodeExtended(std::string encoded){
case '/':
// /A to /O map to ! to , and /Z maps to :
if (next >= 'A' && next <= 'O') {
decodedChar = (byte) (next - 32);
decodedChar = (zxing::byte) (next - 32);
} else if (next == 'Z') {
decodedChar = ':';
} else {

View File

@ -130,7 +130,7 @@ Ref<Result> Code93Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::Dec
return Ref<Result>(new Result(
resultString,
ArrayRef<byte>(),
ArrayRef<zxing::byte>(),
resultPoints,
BarcodeFormat::CODE_93));
}
@ -226,7 +226,7 @@ Ref<String> Code93Reader::decodeExtended(string const& encoded) {
case 'd':
// +A to +Z map to a to z
if (next >= 'A' && next <= 'Z') {
decodedChar = (byte) (next + 32);
decodedChar = (zxing::byte) (next + 32);
} else {
throw FormatException::getFormatInstance();
}
@ -234,7 +234,7 @@ Ref<String> Code93Reader::decodeExtended(string const& encoded) {
case 'a':
// $A to $Z map to control codes SH to SB
if (next >= 'A' && next <= 'Z') {
decodedChar = (byte) (next - 64);
decodedChar = (zxing::byte) (next - 64);
} else {
throw FormatException::getFormatInstance();
}
@ -242,9 +242,9 @@ Ref<String> Code93Reader::decodeExtended(string const& encoded) {
case 'b':
// %A to %E map to control codes ESC to US
if (next >= 'A' && next <= 'E') {
decodedChar = (byte) (next - 38);
decodedChar = (zxing::byte) (next - 38);
} else if (next >= 'F' && next <= 'W') {
decodedChar = (byte) (next - 11);
decodedChar = (zxing::byte) (next - 11);
} else {
throw FormatException::getFormatInstance();
}
@ -252,7 +252,7 @@ Ref<String> Code93Reader::decodeExtended(string const& encoded) {
case 'c':
// /A to /O map to ! to , and /Z maps to :
if (next >= 'A' && next <= 'O') {
decodedChar = (byte) (next - 32);
decodedChar = (zxing::byte) (next - 32);
} else if (next == 'Z') {
decodedChar = ':';
} else {

View File

@ -44,7 +44,7 @@ int EAN13Reader::decodeMiddle(Ref<BitArray> row,
for (int x = 0; x < 6 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS);
resultString.append(1, (byte) ('0' + bestMatch % 10));
resultString.append(1, (zxing::byte) ('0' + bestMatch % 10));
for (int i = 0, end = counters.size(); i <end; i++) {
rowOffset += counters[i];
}
@ -61,7 +61,7 @@ int EAN13Reader::decodeMiddle(Ref<BitArray> row,
for (int x = 0; x < 6 && rowOffset < end; x++) {
int bestMatch =
decodeDigit(row, counters, rowOffset, L_PATTERNS);
resultString.append(1, (byte) ('0' + bestMatch));
resultString.append(1, (zxing::byte) ('0' + bestMatch));
for (int i = 0, end = counters.size(); i < end; i++) {
rowOffset += counters[i];
}
@ -73,7 +73,7 @@ void EAN13Reader::determineFirstDigit(std::string& resultString, int lgPatternFo
// std::cerr << "K " << resultString << " " << lgPatternFound << " " <<FIRST_DIGIT_ENCODINGS << std::endl;
for (int d = 0; d < 10; d++) {
if (lgPatternFound == FIRST_DIGIT_ENCODINGS[d]) {
resultString.insert((size_t)0, (size_t)1, (byte) ('0' + d));
resultString.insert((size_t)0, (size_t)1, (zxing::byte) ('0' + d));
return;
}
}

View File

@ -41,7 +41,7 @@ int EAN8Reader::decodeMiddle(Ref<BitArray> row,
for (int x = 0; x < 4 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
result.append(1, (byte) ('0' + bestMatch));
result.append(1, (zxing::byte) ('0' + bestMatch));
for (int i = 0, end = counters.size(); i < end; i++) {
rowOffset += counters[i];
}
@ -52,7 +52,7 @@ int EAN8Reader::decodeMiddle(Ref<BitArray> row,
rowOffset = middleRange[1];
for (int x = 0; x < 4 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
result.append(1, (byte) ('0' + bestMatch));
result.append(1, (zxing::byte) ('0' + bestMatch));
for (int i = 0, end = counters.size(); i < end; i++) {
rowOffset += counters[i];
}

View File

@ -117,7 +117,7 @@ Ref<Result> ITFReader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::Decode
Ref<OneDResultPoint>(new OneDResultPoint(float(startRange[1]), float(rowNumber)));
resultPoints[1] =
Ref<OneDResultPoint>(new OneDResultPoint(float(endRange[0]), float(rowNumber)));
return Ref<Result>(new Result(resultString, ArrayRef<byte>(), resultPoints, BarcodeFormat::ITF));
return Ref<Result>(new Result(resultString, ArrayRef<zxing::byte>(), resultPoints, BarcodeFormat::ITF));
}
/**
@ -151,9 +151,9 @@ void ITFReader::decodeMiddle(Ref<BitArray> row,
}
int bestMatch = decodeDigit(counterBlack);
resultString.append(1, (byte) ('0' + bestMatch));
resultString.append(1, (zxing::byte) ('0' + bestMatch));
bestMatch = decodeDigit(counterWhite);
resultString.append(1, (byte) ('0' + bestMatch));
resultString.append(1, (zxing::byte) ('0' + bestMatch));
for (int i = 0, e = counterDigitPair.size(); i < e; i++) {
payloadStart += counterDigitPair[i];

View File

@ -156,7 +156,7 @@ Ref<Result> UPCEANReader::decodeRow(int rowNumber,
ArrayRef< Ref<ResultPoint> > resultPoints(2);
resultPoints[0] = Ref<ResultPoint>(new OneDResultPoint(left, (float) rowNumber));
resultPoints[1] = Ref<ResultPoint>(new OneDResultPoint(right, (float) rowNumber));
Ref<Result> decodeResult (new Result(resultString, ArrayRef<byte>(), resultPoints, format));
Ref<Result> decodeResult (new Result(resultString, ArrayRef<zxing::byte>(), resultPoints, format));
// Java extension and man stuff
return decodeResult;
}

View File

@ -64,7 +64,7 @@ int UPCEReader::decodeMiddle(Ref<BitArray> row, Range const& startRange, string&
for (int x = 0; x < 6 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS);
result.append(1, (byte) ('0' + bestMatch % 10));
result.append(1, (zxing::byte) ('0' + bestMatch % 10));
for (int i = 0, e = counters.size(); i < e; i++) {
rowOffset += counters[i];
}
@ -91,8 +91,8 @@ bool UPCEReader::determineNumSysAndCheckDigit(std::string& resultString, int lgP
for (int numSys = 0; numSys <= 1; numSys++) {
for (int d = 0; d < 10; d++) {
if (lgPatternFound == NUMSYS_AND_CHECK_DIGIT_PATTERNS[numSys][d]) {
resultString.insert((size_t)0, (size_t)1, (byte) ('0' + numSys));
resultString.append(1, (byte) ('0' + d));
resultString.insert((size_t)0, (size_t)1, (zxing::byte) ('0' + numSys));
resultString.append(1, (zxing::byte) ('0' + d));
return true;
}
}

View File

@ -116,7 +116,7 @@ Ref<DecoderResult> DecodedBitStreamParser::decode(ArrayRef<int> codewords)
throw FormatException();
}
}
return Ref<DecoderResult>(new DecoderResult(ArrayRef<byte>(), result));
return Ref<DecoderResult>(new DecoderResult(ArrayRef<zxing::byte>(), result));
}
/**
@ -217,7 +217,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef<int> textCompactionDa
// Alpha (uppercase alphabetic)
if (subModeCh < 26) {
// Upper case Alpha Character
ch = (byte) ('A' + subModeCh);
ch = (zxing::byte) ('A' + subModeCh);
} else {
if (subModeCh == 26) {
ch = ' ';
@ -230,7 +230,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef<int> textCompactionDa
priorToShiftMode = subMode;
subMode = PUNCT_SHIFT;
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
result->append((byte) byteCompactionData[i]);
result->append((zxing::byte) byteCompactionData[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -240,7 +240,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef<int> textCompactionDa
case LOWER:
// Lower (lowercase alphabetic)
if (subModeCh < 26) {
ch = (byte) ('a' + subModeCh);
ch = (zxing::byte) ('a' + subModeCh);
} else {
if (subModeCh == 26) {
ch = ' ';
@ -255,7 +255,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef<int> textCompactionDa
priorToShiftMode = subMode;
subMode = PUNCT_SHIFT;
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
result->append((byte) byteCompactionData[i]);
result->append((zxing::byte) byteCompactionData[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -280,7 +280,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef<int> textCompactionDa
priorToShiftMode = subMode;
subMode = PUNCT_SHIFT;
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
result->append((byte) byteCompactionData[i]);
result->append((zxing::byte) byteCompactionData[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -295,7 +295,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef<int> textCompactionDa
if (subModeCh == PAL) {
subMode = ALPHA;
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
result->append((byte) byteCompactionData[i]);
result->append((zxing::byte) byteCompactionData[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -306,7 +306,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef<int> textCompactionDa
// Restore sub-mode
subMode = priorToShiftMode;
if (subModeCh < 26) {
ch = (byte) ('A' + subModeCh);
ch = (zxing::byte) ('A' + subModeCh);
} else {
if (subModeCh == 26) {
ch = ' ';
@ -332,7 +332,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef<int> textCompactionDa
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
// PS before Shift-to-Byte is used as a padding character,
// see 5.4.2.4 of the specification
result->append((byte) byteCompactionData[i]);
result->append((zxing::byte) byteCompactionData[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -366,7 +366,7 @@ int DecodedBitStreamParser::byteCompaction(int mode,
// is not a multiple of 6
int count = 0;
int64_t value = 0;
ArrayRef<byte> decodedData = new Array<byte>(6);
ArrayRef<zxing::byte> decodedData = new Array<zxing::byte>(6);
ArrayRef<int> byteCompactedCodewords = new Array<int>(6);
bool end = false;
int nextCode = codewords[codeIndex++];
@ -394,7 +394,7 @@ int DecodedBitStreamParser::byteCompaction(int mode,
// Convert to Base 256
for (int j = 0; j < 6; ++j)
{
decodedData[5 - j] = (byte) (value%256);
decodedData[5 - j] = (zxing::byte) (value%256);
value >>= 8;
}
result->append(string((char*)&(decodedData->values()[0]), decodedData->values().size()));
@ -412,7 +412,7 @@ int DecodedBitStreamParser::byteCompaction(int mode,
// as one byte per codeword, without compaction.
for (int i = 0; i < count; i++)
{
result->append((byte)byteCompactedCodewords[i]);
result->append((zxing::byte)byteCompactedCodewords[i]);
}
} else if (mode == BYTE_COMPACTION_MODE_LATCH_6) {
@ -442,9 +442,9 @@ int DecodedBitStreamParser::byteCompaction(int mode,
if ((count % 5 == 0) && (count > 0)) {
// Decode every 5 codewords
// Convert to Base 256
ArrayRef<byte> decodedData = new Array<byte>(6);
ArrayRef<zxing::byte> decodedData = new Array<zxing::byte>(6);
for (int j = 0; j < 6; ++j) {
decodedData[5 - j] = (byte) (value & 0xFF);
decodedData[5 - j] = (zxing::byte) (value & 0xFF);
value >>= 8;
}
result->append(string((char*)&decodedData[0],6));

View File

@ -40,7 +40,7 @@ int FormatInformation::N_FORMAT_INFO_DECODE_LOOKUPS = 32;
int FormatInformation::BITS_SET_IN_HALF_BYTE[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
FormatInformation::FormatInformation(int formatInfo) :
errorCorrectionLevel_(ErrorCorrectionLevel::forBits((formatInfo >> 3) & 0x03)), dataMask_((byte)(formatInfo & 0x07)) {
errorCorrectionLevel_(ErrorCorrectionLevel::forBits((formatInfo >> 3) & 0x03)), dataMask_((zxing::byte)(formatInfo & 0x07)) {
}
ErrorCorrectionLevel& FormatInformation::getErrorCorrectionLevel() {

View File

@ -43,7 +43,7 @@ public:
BitMatrixParser(Ref<BitMatrix> bitMatrix);
Ref<FormatInformation> readFormatInformation();
Version *readVersion();
ArrayRef<byte> readCodewords();
ArrayRef<zxing::byte> readCodewords();
void remask();
void setMirror(boolean mirror);
void mirror();

View File

@ -32,16 +32,16 @@ namespace qrcode {
class DataBlock : public Counted {
private:
int numDataCodewords_;
ArrayRef<byte> codewords_;
ArrayRef<zxing::byte> codewords_;
DataBlock(int numDataCodewords, ArrayRef<byte> codewords);
DataBlock(int numDataCodewords, ArrayRef<zxing::byte> codewords);
public:
static std::vector<Ref<DataBlock> >
getDataBlocks(ArrayRef<byte> rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel);
getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel);
int getNumDataCodewords();
ArrayRef<byte> getCodewords();
ArrayRef<zxing::byte> getCodewords();
};
}

View File

@ -51,16 +51,16 @@ private:
std::string& result,
int count,
common::CharacterSetECI const *currentCharacterSetECI,
ArrayRef<ArrayRef<byte> > &byteSegments,
ArrayRef<ArrayRef<zxing::byte> > &byteSegments,
Hashtable const& hints);
static void decodeAlphanumericSegment(Ref<BitSource> bits, std::string &result, int count, bool fc1InEffect);
static void decodeNumericSegment(Ref<BitSource> bits, std::string &result, int count);
static void append(std::string &ost, const byte *bufIn, size_t nIn, const char *src);
static void append(std::string &ost, const zxing::byte *bufIn, size_t nIn, const char *src);
static void append(std::string &ost, std::string const& in, const char *src);
public:
static Ref<DecoderResult> decode(ArrayRef<byte> bytes,
static Ref<DecoderResult> decode(ArrayRef<zxing::byte> bytes,
Version *version,
ErrorCorrectionLevel const& ecLevel,
Hashtable const& hints);

View File

@ -33,7 +33,7 @@ class Decoder {
private:
ReedSolomonDecoder rsDecoder_;
void correctErrors(ArrayRef<byte> bytes, int numDataCodewords);
void correctErrors(ArrayRef<zxing::byte> bytes, int numDataCodewords);
public:
Decoder();

View File

@ -116,7 +116,7 @@ Version *BitMatrixParser::readVersion() {
throw ReaderException("Could not decode version");
}
ArrayRef<byte> BitMatrixParser::readCodewords() {
ArrayRef<zxing::byte> BitMatrixParser::readCodewords() {
Ref<FormatInformation> formatInfo = readFormatInformation();
Version *version = readVersion();
@ -138,7 +138,7 @@ ArrayRef<byte> BitMatrixParser::readCodewords() {
// cout << *functionPattern << endl;
bool readingUp = true;
ArrayRef<byte> result(version->getTotalCodewords());
ArrayRef<zxing::byte> result(version->getTotalCodewords());
int resultOffset = 0;
int currentByte = 0;
int bitsRead = 0;
@ -163,7 +163,7 @@ ArrayRef<byte> BitMatrixParser::readCodewords() {
}
// If we've made a whole byte, save it off
if (bitsRead == 8) {
result[resultOffset++] = (byte)currentByte;
result[resultOffset++] = (zxing::byte)currentByte;
bitsRead = 0;
currentByte = 0;
}

View File

@ -26,7 +26,7 @@ namespace qrcode {
using namespace std;
DataBlock::DataBlock(int numDataCodewords, ArrayRef<byte> codewords) :
DataBlock::DataBlock(int numDataCodewords, ArrayRef<zxing::byte> codewords) :
numDataCodewords_(numDataCodewords), codewords_(codewords) {
}
@ -34,12 +34,12 @@ int DataBlock::getNumDataCodewords() {
return numDataCodewords_;
}
ArrayRef<byte> DataBlock::getCodewords() {
ArrayRef<zxing::byte> DataBlock::getCodewords() {
return codewords_;
}
std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<byte> rawCodewords, Version *version,
std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<zxing::byte> rawCodewords, Version *version,
ErrorCorrectionLevel &ecLevel) {
@ -63,7 +63,7 @@ std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(ArrayRef<byte> rawCodeword
for (int i = 0; i < ecBlock->getCount(); i++) {
int numDataCodewords = ecBlock->getDataCodewords();
int numBlockCodewords = ecBlocks.getECCodewordsPerBloc() + numDataCodewords;
ArrayRef<byte> buffer(numBlockCodewords);
ArrayRef<zxing::byte> buffer(numBlockCodewords);
Ref<DataBlock> blockRef(new DataBlock(numDataCodewords, buffer));
result[numResultBlocks++] = blockRef;
}

View File

@ -57,11 +57,11 @@ namespace {int GB2312_SUBSET = 1;}
void DecodedBitStreamParser::append(std::string &result,
string const& in,
const char *src) {
append(result, (byte const*)in.c_str(), in.length(), src);
append(result, (zxing::byte const*)in.c_str(), in.length(), src);
}
void DecodedBitStreamParser::append(std::string &result,
const byte *bufIn,
const zxing::byte *bufIn,
size_t nIn,
const char *src) {
#ifndef NO_ICONV
@ -132,8 +132,8 @@ void DecodedBitStreamParser::decodeHanziSegment(Ref<BitSource> bits_,
// In the 0xB0A1 to 0xFAFE range
assembledTwoBytes += 0x0A6A1;
}
buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF);
buffer[offset + 1] = (byte) (assembledTwoBytes & 0xFF);
buffer[offset] = (zxing::byte) ((assembledTwoBytes >> 8) & 0xFF);
buffer[offset + 1] = (zxing::byte) (assembledTwoBytes & 0xFF);
offset += 2;
count--;
}
@ -167,8 +167,8 @@ void DecodedBitStreamParser::decodeKanjiSegment(Ref<BitSource> bits, std::string
// In the 0xE040 to 0xEBBF range
assembledTwoBytes += 0x0C140;
}
buffer[offset] = (byte)(assembledTwoBytes >> 8);
buffer[offset + 1] = (byte)assembledTwoBytes;
buffer[offset] = (zxing::byte)(assembledTwoBytes >> 8);
buffer[offset + 1] = (zxing::byte)assembledTwoBytes;
offset += 2;
count--;
}
@ -186,7 +186,7 @@ std::string DecodedBitStreamParser::decodeByteSegment(Ref<BitSource> bits_,
string& result,
int count,
CharacterSetECI const * currentCharacterSetECI,
ArrayRef< ArrayRef<byte> >& byteSegments,
ArrayRef< ArrayRef<zxing::byte> >& byteSegments,
Hashtable const& hints) {
int nBytes = count;
BitSource& bits (*bits_);
@ -195,10 +195,10 @@ std::string DecodedBitStreamParser::decodeByteSegment(Ref<BitSource> bits_,
throw FormatException();
}
ArrayRef<byte> bytes_ (count);
ArrayRef<zxing::byte> bytes_ (count);
byte* readBytes = &(*bytes_)[0];
for (int i = 0; i < count; i++) {
readBytes[i] = (byte) bits.readBits(8);
readBytes[i] = (zxing::byte) bits.readBits(8);
}
string encoding;
if (currentCharacterSetECI == 0) {
@ -319,7 +319,7 @@ void DecodedBitStreamParser::decodeAlphanumericSegment(Ref<BitSource> bits_,
r << s[i++];
} else {
// In alpha mode, % should be converted to FNC1 separator 0x1D
r << (byte)0x1D;
r << (zxing::byte)0x1D;
}
}
}
@ -350,7 +350,7 @@ int parseECIValue(BitSource& bits) {
}
Ref<DecoderResult>
DecodedBitStreamParser::decode(ArrayRef<byte> bytes,
DecodedBitStreamParser::decode(ArrayRef<zxing::byte> bytes,
Version* version,
ErrorCorrectionLevel const& ecLevel,
Hashtable const& hints) {
@ -358,7 +358,7 @@ DecodedBitStreamParser::decode(ArrayRef<byte> bytes,
BitSource& bits (*bits_);
string result;
result.reserve(50);
ArrayRef< ArrayRef<byte> > byteSegments (0);
ArrayRef< ArrayRef<zxing::byte> > byteSegments (0);
const CharacterSetECI* currentCharacterSetECI = 0;
string charSet = "";
try {

View File

@ -43,7 +43,7 @@ Decoder::Decoder() :
rsDecoder_(GenericGF::QR_CODE_FIELD_256) {
}
void Decoder::correctErrors(ArrayRef<byte> codewordBytes, int numDataCodewords) {
void Decoder::correctErrors(ArrayRef<zxing::byte> codewordBytes, int numDataCodewords) {
int numCodewords = codewordBytes->size();
ArrayRef<int> codewordInts(numCodewords);
for (int i = 0; i < numCodewords; i++) {
@ -59,7 +59,7 @@ void Decoder::correctErrors(ArrayRef<byte> codewordBytes, int numDataCodewords)
}
for (int i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (byte)codewordInts[i];
codewordBytes[i] = (zxing::byte)codewordInts[i];
}
}
@ -74,7 +74,7 @@ Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
// Read codewords
ArrayRef<byte> codewords(parser.readCodewords());
ArrayRef<zxing::byte> codewords(parser.readCodewords());
// Separate into data blocks
@ -86,18 +86,18 @@ Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
for (size_t i = 0; i < dataBlocks.size(); i++) {
totalBytes += dataBlocks[i]->getNumDataCodewords();
}
ArrayRef<byte> resultBytes(totalBytes);
ArrayRef<zxing::byte> resultBytes(totalBytes);
int resultOffset = 0;
// Error-correct and copy data blocks together into a stream of bytes
for (size_t j = 0; j < dataBlocks.size(); j++) {
Ref<DataBlock> dataBlock(dataBlocks[j]);
ArrayRef<byte> codewordBytes = dataBlock->getCodewords();
ArrayRef<zxing::byte> codewordBytes = dataBlock->getCodewords();
int numDataCodewords = dataBlock->getNumDataCodewords();
correctErrors(codewordBytes, numDataCodewords);
for (int i = 0; i < numDataCodewords; i++) {
resultBytes[resultOffset++] = (byte)codewordBytes[i];
resultBytes[resultOffset++] = (zxing::byte)codewordBytes[i];
}
}

View File

@ -12,18 +12,18 @@ namespace qrcode {
class BlockPair
{
private:
ArrayRef<byte> data_;
ArrayRef<byte> errorCorrection_;
ArrayRef<zxing::byte> data_;
ArrayRef<zxing::byte> errorCorrection_;
public:
BlockPair(ArrayRef<byte> data, ArrayRef<byte> errorCorrection) :
BlockPair(ArrayRef<zxing::byte> data, ArrayRef<zxing::byte> errorCorrection) :
data_(data), errorCorrection_(errorCorrection) {}
BlockPair(const BlockPair& other) : data_(other.data_), errorCorrection_(other.errorCorrection_) {}
ArrayRef<byte> getDataBytes() { return data_; }
ArrayRef<zxing::byte> getDataBytes() { return data_; }
ArrayRef<byte> getErrorCorrectionBytes() { return errorCorrection_; }
ArrayRef<zxing::byte> getErrorCorrectionBytes() { return errorCorrection_; }
};
}

View File

@ -27,27 +27,27 @@ byte ByteMatrix::get(size_t x, size_t y) const
return bytes_[y][x];
}
std::vector< std::vector<byte> > ByteMatrix::getArray() const
std::vector< std::vector<zxing::byte> > ByteMatrix::getArray() const
{
return bytes_;
}
void ByteMatrix::set(size_t x, size_t y, const byte value)
void ByteMatrix::set(size_t x, size_t y, const zxing::byte value)
{
bytes_[y][x] = value;
}
void ByteMatrix::set(size_t x, size_t y, size_t value)
{
bytes_[y][x] = (byte) value;
bytes_[y][x] = (zxing::byte) value;
}
void ByteMatrix::set(size_t x, size_t y, bool value)
{
bytes_[y][x] = (byte) (value ? 1 : 0);
bytes_[y][x] = (zxing::byte) (value ? 1 : 0);
}
void ByteMatrix::clear(const byte value)
void ByteMatrix::clear(const zxing::byte value)
{
for (size_t y = 0; y < height_; y++) {
for (size_t x = 0; x < width_; x++) {
@ -60,7 +60,7 @@ const std::string ByteMatrix::toString() const
{
std::stringstream result;// = new StringBuilder(2 * width * height + 2);
for (size_t y = 0; y < height_; y++) {
const std::vector<byte>& bytesY = bytes_[y];
const std::vector<zxing::byte>& bytesY = bytes_[y];
for (size_t x = 0; x < width_; x++) {
switch (bytesY[x]) {
case 0:

View File

@ -12,7 +12,7 @@ namespace qrcode {
class ByteMatrix : public Counted
{
private:
std::vector< std::vector<byte> > bytes_;
std::vector< std::vector<zxing::byte> > bytes_;
size_t width_;
size_t height_;
@ -22,13 +22,13 @@ public:
size_t getHeight() const;
size_t getWidth() const;
byte get(size_t x, size_t y) const;
zxing::byte get(size_t x, size_t y) const;
std::vector<std::vector<byte> > getArray() const;
void set(size_t x, size_t y, const byte value);
std::vector<std::vector<zxing::byte> > getArray() const;
void set(size_t x, size_t y, const zxing::byte value);
void set(size_t x, size_t y, size_t value);
void set(size_t x, size_t y, bool value);
void clear(const byte value);
void clear(const zxing::byte value);
const std::string toString() const;
};

View File

@ -77,7 +77,7 @@ protected:
int numDataBytes,
int numRSBlocks);
static ArrayRef<byte> generateECBytes(const std::vector<byte> &dataBytes, int numEcBytesInBlock);
static ArrayRef<zxing::byte> generateECBytes(const std::vector<zxing::byte> &dataBytes, int numEcBytesInBlock);
static void appendNumericBytes(const std::string& content, BitArray& bits);

View File

@ -29,11 +29,11 @@ int MaskUtil::applyMaskPenaltyRule1(const ByteMatrix& matrix)
int MaskUtil::applyMaskPenaltyRule2(const ByteMatrix& matrix)
{
int penalty = 0;
const std::vector<std::vector<byte> >& array = matrix.getArray();
const std::vector<std::vector<zxing::byte> >& array = matrix.getArray();
int width = matrix.getWidth();
int height = matrix.getHeight();
for (int y = 0; y < height - 1; y++) {
const std::vector<byte>& arrayY = array[y];
const std::vector<zxing::byte>& arrayY = array[y];
for (int x = 0; x < width - 1; x++) {
int value = arrayY[x];
if (value == arrayY[x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) {
@ -52,12 +52,12 @@ int MaskUtil::applyMaskPenaltyRule2(const ByteMatrix& matrix)
int MaskUtil::applyMaskPenaltyRule3(const ByteMatrix& matrix)
{
int numPenalties = 0;
const std::vector<std::vector<byte> >& array = matrix.getArray();
const std::vector<std::vector<zxing::byte> >& array = matrix.getArray();
int width = matrix.getWidth();
int height = matrix.getHeight();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
const std::vector<byte>& arrayY = array[y]; // We can at least optimize this access
const std::vector<zxing::byte>& arrayY = array[y]; // We can at least optimize this access
if (x + 6 < width &&
arrayY[x] == 1 &&
arrayY[x + 1] == 0 &&
@ -85,7 +85,7 @@ int MaskUtil::applyMaskPenaltyRule3(const ByteMatrix& matrix)
return numPenalties * N3;
}
bool MaskUtil::isWhiteHorizontal(const std::vector<byte>& rowArray, int from, int to)
bool MaskUtil::isWhiteHorizontal(const std::vector<zxing::byte>& rowArray, int from, int to)
{
from = std::max(from, 0);
to = std::min(to, (int)rowArray.size());
@ -97,7 +97,7 @@ bool MaskUtil::isWhiteHorizontal(const std::vector<byte>& rowArray, int from, in
return true;
}
bool MaskUtil::isWhiteVertical(const std::vector<std::vector<byte> > &array, int col, int from, int to)
bool MaskUtil::isWhiteVertical(const std::vector<std::vector<zxing::byte> > &array, int col, int from, int to)
{
from = std::max(from, 0);
to = std::min(to, (int)array.size());
@ -116,11 +116,11 @@ bool MaskUtil::isWhiteVertical(const std::vector<std::vector<byte> > &array, int
int MaskUtil::applyMaskPenaltyRule4(const ByteMatrix& matrix)
{
int numDarkCells = 0;
const std::vector<std::vector<byte> >& array = matrix.getArray();
const std::vector<std::vector<zxing::byte> >& array = matrix.getArray();
int width = matrix.getWidth();
int height = matrix.getHeight();
for (int y = 0; y < height; y++) {
const std::vector<byte>& arrayY = array[y];
const std::vector<zxing::byte>& arrayY = array[y];
for (size_t x = 0; x < width; x++) {
if (arrayY[x] == 1) {
numDarkCells++;
@ -183,7 +183,7 @@ int MaskUtil::applyMaskPenaltyRule1Internal(const ByteMatrix& matrix, bool isHor
int penalty = 0;
int iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth();
int jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight();
const std::vector<std::vector<byte> >& array = matrix.getArray();
const std::vector<std::vector<zxing::byte> >& array = matrix.getArray();
for (size_t i = 0; i < iLimit; i++) {
int numSameBitCells = 0;
int prevBit = -1;

View File

@ -15,9 +15,9 @@ private:
static const int N3;
static const int N4;
static bool isWhiteHorizontal(const std::vector<byte>& rowArray, int from, int to);
static bool isWhiteHorizontal(const std::vector<zxing::byte>& rowArray, int from, int to);
static bool isWhiteVertical(const std::vector<std::vector<byte> >& array, int col, int from, int to);
static bool isWhiteVertical(const std::vector<std::vector<zxing::byte> >& array, int col, int from, int to);
/**
* Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both

View File

@ -294,11 +294,11 @@ void MatrixUtil::embedTimingPatterns(ByteMatrix& matrix)
int bit = (i + 1) % 2;
// Horizontal line.
if (isEmpty(matrix.get(i, 6))) {
matrix.set(i, 6, (byte)bit);
matrix.set(i, 6, (zxing::byte)bit);
}
// Vertical line.
if (isEmpty(matrix.get(6, i))) {
matrix.set(6, i, (byte)bit);
matrix.set(6, i, (zxing::byte)bit);
}
}
}
@ -308,7 +308,7 @@ void MatrixUtil::embedDarkDotAtLeftBottomCorner(ByteMatrix& matrix)
if (matrix.get(8, matrix.getHeight() - 8) == 0) {
throw WriterException();
}
matrix.set(8, matrix.getHeight() - 8, (byte)1);
matrix.set(8, matrix.getHeight() - 8, (zxing::byte)1);
}
void MatrixUtil::embedHorizontalSeparationPattern(int xStart,
@ -319,7 +319,7 @@ void MatrixUtil::embedHorizontalSeparationPattern(int xStart,
if (!isEmpty(matrix.get(xStart + x, yStart))) {
throw WriterException();
}
matrix.set(xStart + x, yStart, (byte)0);
matrix.set(xStart + x, yStart, (zxing::byte)0);
}
}
@ -331,7 +331,7 @@ void MatrixUtil::embedVerticalSeparationPattern(int xStart,
if (!isEmpty(matrix.get(xStart, yStart + y))) {
throw WriterException();
}
matrix.set(xStart, yStart + y, (byte)0);
matrix.set(xStart, yStart + y, (zxing::byte)0);
}
}
@ -339,7 +339,7 @@ void MatrixUtil::embedPositionAdjustmentPattern(int xStart, int yStart, ByteMatr
{
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
matrix.set(xStart + x, yStart + y, (byte)POSITION_ADJUSTMENT_PATTERN[y][x]);
matrix.set(xStart + x, yStart + y, (zxing::byte)POSITION_ADJUSTMENT_PATTERN[y][x]);
}
}
}
@ -348,7 +348,7 @@ void MatrixUtil::embedPositionDetectionPattern(int xStart, int yStart, ByteMatri
{
for (int y = 0; y < 7; ++y) {
for (int x = 0; x < 7; ++x) {
matrix.set(xStart + x, yStart + y, (byte)POSITION_DETECTION_PATTERN[y][x]);
matrix.set(xStart + x, yStart + y, (zxing::byte)POSITION_DETECTION_PATTERN[y][x]);
}
}
}

View File

@ -62,7 +62,7 @@ private:
public:
// Set all cells to -1. -1 means that the cell is empty (not set yet).
static void clearMatrix(ByteMatrix& matrix) {
matrix.clear((byte) -1);
matrix.clear((zxing::byte) -1);
}
// Embed basic patterns. On success, modify the matrix and return true.

View File

@ -186,7 +186,7 @@ Mode Encoder::chooseMode(const std::string& content, const std::string& encoding
//bool Encoder::isOnlyDoubleByteKanji(const std::string& content)
//{
// std::vector<byte> bytes;
// std::vector<zxing::byte> bytes;
// try {
// bytes = content.getBytes("Shift_JIS");
// } catch (UnsupportedEncodingException ignored) {
@ -374,11 +374,11 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits,
numDataBytesInBlock, numEcBytesInBlock);
int size = numDataBytesInBlock[0];
std::vector<byte> dataBytes;
std::vector<zxing::byte> dataBytes;
dataBytes.resize(size);
bits.toBytes(8*dataBytesOffset, dataBytes, 0, size);
ArrayRef<byte> ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]);
blocks.push_back(BlockPair(ArrayRef<byte>(dataBytes.data(), dataBytes.size()),ecBytes)); //?? please revisit
ArrayRef<zxing::byte> ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]);
blocks.push_back(BlockPair(ArrayRef<zxing::byte>(dataBytes.data(), dataBytes.size()),ecBytes)); //?? please revisit
maxNumDataBytes = max(maxNumDataBytes, size);
maxNumEcBytes = max(maxNumEcBytes, (int)ecBytes->size());
@ -393,7 +393,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits,
// First, place data blocks.
for (int i = 0; i < maxNumDataBytes; i++) {
for (std::vector< BlockPair >::iterator it=blocks.begin(); it != blocks.end(); it++) {
ArrayRef<byte> dataBytes = it->getDataBytes();
ArrayRef<zxing::byte> dataBytes = it->getDataBytes();
if (i < dataBytes.array_->size()) {
result->appendBits(dataBytes[i], 8); ///????? are we sure?
}
@ -402,7 +402,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits,
// Then, place error correction blocks.
for (int i = 0; i < maxNumEcBytes; i++) {
for (std::vector< BlockPair >::iterator it=blocks.begin(); it != blocks.end(); it++) {
ArrayRef<byte> ecBytes = it->getErrorCorrectionBytes();
ArrayRef<zxing::byte> ecBytes = it->getErrorCorrectionBytes();
if (i < ecBytes.array_->size()) {
result->appendBits(ecBytes[i], 8);
}
@ -420,15 +420,15 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits,
return result;
}
ArrayRef<byte> Encoder::generateECBytes(const std::vector<byte>& dataBytes, int numEcBytesInBlock)
ArrayRef<zxing::byte> Encoder::generateECBytes(const std::vector<zxing::byte>& dataBytes, int numEcBytesInBlock)
{
int numDataBytes = dataBytes.size();
std::vector<byte> dataBytesCopy(dataBytes);
std::vector<zxing::byte> dataBytesCopy(dataBytes);
zxing::ReedSolomonEncoder encoder(GenericGF::QR_CODE_FIELD_256);
encoder.encode(dataBytesCopy, numEcBytesInBlock);
ArrayRef<byte> ecBytes(numEcBytesInBlock);
ArrayRef<zxing::byte> ecBytes(numEcBytesInBlock);
for (int i = 0; i < numEcBytesInBlock; i++) {
ecBytes[i] = dataBytesCopy[numDataBytes + i];
}