本文整理汇总了C++中zxing::ChecksumException方法的典型用法代码示例。如果您正苦于以下问题:C++ zxing::ChecksumException方法的具体用法?C++ zxing::ChecksumException怎么用?C++ zxing::ChecksumException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zxing
的用法示例。
在下文中一共展示了zxing::ChecksumException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NotFoundException
Ref<Result> UPCEANReader::decodeRow(int rowNumber,
Ref<BitArray> row,
Range const& startGuardRange) {
string& result = decodeRowStringBuffer;
result.clear();
int endStart = decodeMiddle(row, startGuardRange, result);
Range endRange = decodeEnd(row, endStart);
// Make sure there is a quiet zone at least as big as the end pattern after the barcode.
// The spec might want more whitespace, but in practice this is the maximum we can count on.
int end = endRange[1];
int quietEnd = end + (end - endRange[0]);
if (quietEnd >= row->getSize() || !row->isRange(end, quietEnd, false)) {
throw NotFoundException();
}
Ref<String> resultString (new String(result));
if (!checkChecksum(resultString)) {
throw ChecksumException();
}
float left = (float) (startGuardRange[1] + startGuardRange[0]) / 2.0f;
float right = (float) (endRange[1] + endRange[0]) / 2.0f;
BarcodeFormat format = getBarcodeFormat();
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<char>(), resultPoints, format));
// Java extension and man stuff
return decodeResult;
}
示例2: ChecksumException
void Code93Reader::checkOneChecksum(string const& result,
int checkPosition,
int weightMax) {
int weight = 1;
int total = 0;
for (int i = checkPosition - 1; i >= 0; i--) {
total += weight * ALPHABET_STRING.find_first_of(result[i]);
if (++weight > weightMax) {
weight = 1;
}
}
if (result[checkPosition] != ALPHABET[total % 47]) {
throw ChecksumException();
}
}