ByQuadrantReader.cpp Example File
appdemos/qtws/QZXing/zxing/zxing/multi/ByQuadrantReader.cpp
#include <zxing/multi/ByQuadrantReader.h>
#include <zxing/ReaderException.h>
namespace zxing {
namespace multi {
ByQuadrantReader::ByQuadrantReader(Reader& delegate) : delegate_(delegate) {}
ByQuadrantReader::~ByQuadrantReader(){}
Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image){
return decode(image, DecodeHints::DEFAULT_HINT);
}
Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image, DecodeHints hints){
int width = image->getWidth();
int height = image->getHeight();
int halfWidth = width / 2;
int halfHeight = height / 2;
Ref<BinaryBitmap> topLeft = image->crop(0, 0, halfWidth, halfHeight);
try {
return delegate_.decode(topLeft, hints);
} catch (ReaderException const& re) {
(void)re;
}
Ref<BinaryBitmap> topRight = image->crop(halfWidth, 0, halfWidth, halfHeight);
try {
return delegate_.decode(topRight, hints);
} catch (ReaderException const& re) {
(void)re;
}
Ref<BinaryBitmap> bottomLeft = image->crop(0, halfHeight, halfWidth, halfHeight);
try {
return delegate_.decode(bottomLeft, hints);
} catch (ReaderException const& re) {
(void)re;
}
Ref<BinaryBitmap> bottomRight = image->crop(halfWidth, halfHeight, halfWidth, halfHeight);
try {
return delegate_.decode(bottomRight, hints);
} catch (ReaderException const& re) {
(void)re;
}
int quarterWidth = halfWidth / 2;
int quarterHeight = halfHeight / 2;
Ref<BinaryBitmap> center = image->crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
return delegate_.decode(center, hints);
}
}
}