本文整理汇总了Java中com.google.zxing.BinaryBitmap.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java BinaryBitmap.getHeight方法的具体用法?Java BinaryBitmap.getHeight怎么用?Java BinaryBitmap.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.BinaryBitmap
的用法示例。
在下文中一共展示了BinaryBitmap.getHeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import com.google.zxing.BinaryBitmap; //导入方法依赖的package包/类
@Override
public Result decode(BinaryBitmap image,
Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
try {
return doDecode(image, hints);
} catch (NotFoundException nfe) {
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
if (tryHarder && image.isRotateSupported()) {
BinaryBitmap rotatedImage = image.rotateCounterClockwise();
Result result = doDecode(rotatedImage, hints);
// Record that we found it rotated 90 degrees CCW / 270 degrees CW
Map<ResultMetadataType,?> metadata = result.getResultMetadata();
int orientation = 270;
if (metadata != null && metadata.containsKey(ResultMetadataType.ORIENTATION)) {
// But if we found it reversed in doDecode(), add in that result here:
orientation = (orientation +
(Integer) metadata.get(ResultMetadataType.ORIENTATION)) % 360;
}
result.putMetadata(ResultMetadataType.ORIENTATION, orientation);
// Update result points
ResultPoint[] points = result.getResultPoints();
if (points != null) {
int height = rotatedImage.getHeight();
for (int i = 0; i < points.length; i++) {
points[i] = new ResultPoint(height - points[i].getY() - 1, points[i].getX());
}
}
return result;
} else {
throw nfe;
}
}
}
示例2: decode
import com.google.zxing.BinaryBitmap; //导入方法依赖的package包/类
public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws
NotFoundException, FormatException {
Result doDecode;
try {
doDecode = doDecode(image, hints);
} catch (NotFoundException nfe) {
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
if (tryHarder && image.isRotateSupported()) {
BinaryBitmap rotatedImage = image.rotateCounterClockwise();
doDecode = doDecode(rotatedImage, hints);
Map<ResultMetadataType, ?> metadata = doDecode.getResultMetadata();
int orientation = 270;
if (metadata != null && metadata.containsKey(ResultMetadataType.ORIENTATION)) {
orientation = (((Integer) metadata.get(ResultMetadataType.ORIENTATION))
.intValue() + 270) % 360;
}
doDecode.putMetadata(ResultMetadataType.ORIENTATION, Integer.valueOf(orientation));
ResultPoint[] points = doDecode.getResultPoints();
if (points != null) {
int height = rotatedImage.getHeight();
for (int i = 0; i < points.length; i++) {
points[i] = new ResultPoint((((float) height) - points[i].getY()) - 1.0f,
points[i].getX());
}
}
} else {
throw nfe;
}
}
return doDecode;
}
示例3: decode
import com.google.zxing.BinaryBitmap; //导入方法依赖的package包/类
public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws
NotFoundException, ChecksumException, FormatException {
int halfWidth = image.getWidth() / 2;
int halfHeight = image.getHeight() / 2;
try {
return this.delegate.decode(image.crop(0, 0, halfWidth, halfHeight), hints);
} catch (NotFoundException e) {
Result result;
try {
result = this.delegate.decode(image.crop(halfWidth, 0, halfWidth, halfHeight),
hints);
makeAbsolute(result.getResultPoints(), halfWidth, 0);
return result;
} catch (NotFoundException e2) {
try {
result = this.delegate.decode(image.crop(0, halfHeight, halfWidth,
halfHeight), hints);
makeAbsolute(result.getResultPoints(), 0, halfHeight);
return result;
} catch (NotFoundException e3) {
try {
result = this.delegate.decode(image.crop(halfWidth, halfHeight,
halfWidth, halfHeight), hints);
makeAbsolute(result.getResultPoints(), halfWidth, halfHeight);
return result;
} catch (NotFoundException e4) {
int quarterWidth = halfWidth / 2;
int quarterHeight = halfHeight / 2;
result = this.delegate.decode(image.crop(quarterWidth, quarterHeight,
halfWidth, halfHeight), hints);
makeAbsolute(result.getResultPoints(), quarterWidth, quarterHeight);
return result;
}
}
}
}
}
示例4: 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();
}
示例5: doDecodeMultiple
import com.google.zxing.BinaryBitmap; //导入方法依赖的package包/类
private void doDecodeMultiple(BinaryBitmap image, Map<DecodeHintType, ?> hints, List<Result>
results, int xOffset, int yOffset, int currentDepth) {
if (currentDepth <= 4) {
try {
Result result = this.delegate.decode(image, hints);
boolean alreadyFound = false;
for (Result existingResult : results) {
if (existingResult.getText().equals(result.getText())) {
alreadyFound = true;
break;
}
}
if (!alreadyFound) {
results.add(translateResultPoints(result, xOffset, yOffset));
}
ResultPoint[] resultPoints = result.getResultPoints();
if (resultPoints != null && resultPoints.length != 0) {
int width = image.getWidth();
int height = image.getHeight();
float minX = (float) width;
float minY = (float) height;
float maxX = 0.0f;
float maxY = 0.0f;
for (ResultPoint point : resultPoints) {
if (point != null) {
float x = point.getX();
float y = point.getY();
if (x < minX) {
minX = x;
}
if (y < minY) {
minY = y;
}
if (x > maxX) {
maxX = x;
}
if (y > maxY) {
maxY = y;
}
}
}
if (minX > 100.0f) {
doDecodeMultiple(image.crop(0, 0, (int) minX, height), hints, results,
xOffset, yOffset, currentDepth + 1);
}
if (minY > 100.0f) {
doDecodeMultiple(image.crop(0, 0, width, (int) minY), hints, results,
xOffset, yOffset, currentDepth + 1);
}
if (maxX < ((float) (width - 100))) {
doDecodeMultiple(image.crop((int) maxX, 0, width - ((int) maxX), height),
hints, results, xOffset + ((int) maxX), yOffset, currentDepth + 1);
}
if (maxY < ((float) (height - 100))) {
doDecodeMultiple(image.crop(0, (int) maxY, width, height - ((int) maxY)),
hints, results, xOffset, yOffset + ((int) maxY), currentDepth + 1);
}
}
} catch (ReaderException e) {
}
}
}