mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
C++ port Binarizer and BinaryBitmap weren't caching rows correctly.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1473 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
b1032ceba4
commit
ecbf50da87
|
@ -23,15 +23,17 @@
|
|||
|
||||
namespace zxing {
|
||||
|
||||
Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source), array_(NULL), matrix_(NULL) {
|
||||
Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source), array_(NULL), matrix_(NULL), cached_y_(-1) {
|
||||
}
|
||||
|
||||
Binarizer::~Binarizer() {
|
||||
}
|
||||
|
||||
Ref<BitArray> Binarizer::getBlackRow(int y, Ref<BitArray> row){
|
||||
if (array_ == NULL)
|
||||
if (array_ == NULL && cached_y_ != y) {
|
||||
array_ = estimateBlackRow(y, row);
|
||||
cached_y_ = y;
|
||||
}
|
||||
return array_;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ class Binarizer : public Counted {
|
|||
Ref<LuminanceSource> source_;
|
||||
Ref<BitArray> array_;
|
||||
Ref<BitMatrix> matrix_;
|
||||
int cached_y_;
|
||||
|
||||
public:
|
||||
Binarizer(Ref<LuminanceSource> source);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace zxing {
|
||||
|
||||
BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : bits_(NULL), array_bits_(NULL), binarizer_(binarizer) {
|
||||
BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : bits_(NULL), array_bits_(NULL), binarizer_(binarizer), cached_y_(-1) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,9 @@ namespace zxing {
|
|||
}
|
||||
|
||||
Ref<BitArray> BinaryBitmap::getBlackRow(int y, Ref<BitArray> row) {
|
||||
if (array_bits_ == NULL) {
|
||||
if (array_bits_ == NULL && cached_y_ != y) {
|
||||
array_bits_ = binarizer_->getBlackRow(y, row);
|
||||
cached_y_ = y;
|
||||
}
|
||||
return array_bits_;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace zxing {
|
|||
Ref<BitMatrix> bits_;
|
||||
Ref<BitArray> array_bits_;
|
||||
Ref<Binarizer> binarizer_;
|
||||
int cached_y_;
|
||||
|
||||
public:
|
||||
BinaryBitmap(Ref<Binarizer> binarizer);
|
||||
|
|
Loading…
Reference in a new issue