Issue 509

git-svn-id: https://zxing.googlecode.com/svn/trunk@1525 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-08-12 20:54:54 +00:00
parent 00322f3873
commit b868c6e3ae
2 changed files with 6 additions and 3 deletions

View file

@ -84,7 +84,7 @@ Version *BitMatrixParser::readVersion() {
return parsedVersion_;
}
size_t dimension = bitMatrix_->getDimension();
int dimension = bitMatrix_->getDimension();
int provisionalVersion = (dimension - 17) >> 2;
if (provisionalVersion <= 6) {
@ -101,7 +101,7 @@ Version *BitMatrixParser::readVersion() {
}
parsedVersion_ = Version::decodeVersionInformation(versionBits);
if (parsedVersion_ != 0) {
if (parsedVersion_ != 0 && parsedVersion_->getDimensionForVersion() == dimension) {
return parsedVersion_;
}
@ -115,7 +115,7 @@ Version *BitMatrixParser::readVersion() {
}
parsedVersion_ = Version::decodeVersionInformation(versionBits);
if (parsedVersion_ != 0) {
if (parsedVersion_ != 0 && parsedVersion_->getDimensionForVersion() == dimension) {
return parsedVersion_;
}
throw ReaderException("Could not decode version");

View file

@ -53,6 +53,9 @@ Ref<DetectorResult> Detector::detect(DecodeHints const& hints) {
Ref<FinderPattern> bottomLeft(info->getBottomLeft());
float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
if (moduleSize < 1.0f) {
throw zxing::ReaderException("bad module size");
}
int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
Version *provisionalVersion = Version::getProvisionalVersionForDimension(dimension);
int modulesBetweenFPCenters = provisionalVersion->getDimensionForVersion() - 7;