本文整理汇总了C++中zxing::FormatException方法的典型用法代码示例。如果您正苦于以下问题:C++ zxing::FormatException方法的具体用法?C++ zxing::FormatException怎么用?C++ zxing::FormatException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zxing
的用法示例。
在下文中一共展示了zxing::FormatException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FormatException
Ref<Result> ITFReader::decodeRow(int rowNumber, Ref<BitArray> row) {
// Find out where the Middle section (payload) starts & ends
Range startRange = decodeStart(row);
Range endRange = decodeEnd(row);
std::string result;
decodeMiddle(row, startRange[1], endRange[0], result);
Ref<String> resultString(new String(result));
ArrayRef<int> allowedLengths;
// Java hints stuff missing
if (!allowedLengths) {
allowedLengths = DEFAULT_ALLOWED_LENGTHS;
}
// To avoid false positives with 2D barcodes (and other patterns), make
// an assumption that the decoded string must be 6, 10 or 14 digits.
int length = resultString->size();
bool lengthOK = false;
for (int i = 0, e = allowedLengths->size(); i < e; i++) {
if (length == allowedLengths[i]) {
lengthOK = true;
break;
}
}
if (!lengthOK) {
throw FormatException();
}
ArrayRef<Ref<ResultPoint> > resultPoints(2);
resultPoints[0] = 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<char>(), resultPoints,
BarcodeFormat::ITF));
}
示例2: 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();
}
// UPC/EAN should never be less than 8 chars anyway
if (result.length() < 8) {
throw FormatException();
}
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;
}