本文整理汇总了Java中com.google.zxing.BinaryBitmap.getBlackRow方法的典型用法代码示例。如果您正苦于以下问题:Java BinaryBitmap.getBlackRow方法的具体用法?Java BinaryBitmap.getBlackRow怎么用?Java BinaryBitmap.getBlackRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.BinaryBitmap
的用法示例。
在下文中一共展示了BinaryBitmap.getBlackRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doDecode
import com.google.zxing.BinaryBitmap; //导入方法依赖的package包/类
private Result doDecode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws
NotFoundException {
int maxLines;
int width = image.getWidth();
int height = image.getHeight();
BitArray row = new BitArray(width);
int middle = height >> 1;
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
int rowStep = Math.max(1, height >> (tryHarder ? 8 : 5));
if (tryHarder) {
maxLines = height;
} else {
maxLines = 15;
}
for (int x = 0; x < maxLines; x++) {
int rowStepsAboveOrBelow = (x + 1) / 2;
if (!((x & 1) == 0)) {
rowStepsAboveOrBelow = -rowStepsAboveOrBelow;
}
int rowNumber = middle + (rowStep * rowStepsAboveOrBelow);
if (rowNumber < 0 || rowNumber >= height) {
break;
}
try {
row = image.getBlackRow(rowNumber, row);
int attempt = 0;
while (attempt < 2) {
if (attempt == 1) {
row.reverse();
if (hints != null && hints.containsKey(DecodeHintType
.NEED_RESULT_POINT_CALLBACK)) {
Map<DecodeHintType, Object> newHints = new EnumMap(DecodeHintType
.class);
newHints.putAll(hints);
newHints.remove(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
hints = newHints;
}
}
try {
Result result = decodeRow(rowNumber, row, hints);
if (attempt == 1) {
result.putMetadata(ResultMetadataType.ORIENTATION, Integer.valueOf
(180));
ResultPoint[] points = result.getResultPoints();
if (points != null) {
points[0] = new ResultPoint((((float) width) - points[0].getX())
- 1.0f, points[0].getY());
points[1] = new ResultPoint((((float) width) - points[1].getX())
- 1.0f, points[1].getY());
}
}
return result;
} catch (ReaderException e) {
attempt++;
}
}
continue;
} catch (NotFoundException e2) {
}
}
throw NotFoundException.getNotFoundInstance();
}