本文整理汇总了Java中com.google.zxing.common.BitMatrix.getBottomRightOnBit方法的典型用法代码示例。如果您正苦于以下问题:Java BitMatrix.getBottomRightOnBit方法的具体用法?Java BitMatrix.getBottomRightOnBit怎么用?Java BitMatrix.getBottomRightOnBit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.common.BitMatrix
的用法示例。
在下文中一共展示了BitMatrix.getBottomRightOnBit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractPureBits
import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
int[] leftTopBlack = image.getTopLeftOnBit();
int[] rightBottomBlack = image.getBottomRightOnBit();
if (leftTopBlack == null || rightBottomBlack == null) {
throw NotFoundException.getNotFoundInstance();
}
int moduleSize = moduleSize(leftTopBlack, image);
int top = leftTopBlack[1];
int bottom = rightBottomBlack[1];
int left = leftTopBlack[0];
int matrixWidth = ((rightBottomBlack[0] - left) + 1) / moduleSize;
int matrixHeight = ((bottom - top) + 1) / moduleSize;
if (matrixWidth <= 0 || matrixHeight <= 0) {
throw NotFoundException.getNotFoundInstance();
}
int nudge = moduleSize / 2;
top += nudge;
left += nudge;
BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight);
for (int y = 0; y < matrixHeight; y++) {
int iOffset = top + (y * moduleSize);
for (int x = 0; x < matrixWidth; x++) {
if (image.get((x * moduleSize) + left, iOffset)) {
bits.set(x, y);
}
}
}
return bits;
}
示例2: extractPureBits
import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
* This method detects a code in a "pure" image -- that is, pure monochrome image
* which contains only an unrotated, unskewed, image of a code, with some white border
* around it. This is a specialized method that works exceptionally fast in this special
* case.
*
* @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix)
*/
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
int[] leftTopBlack = image.getTopLeftOnBit();
int[] rightBottomBlack = image.getBottomRightOnBit();
if (leftTopBlack == null || rightBottomBlack == null) {
throw NotFoundException.getNotFoundInstance();
}
int moduleSize = moduleSize(leftTopBlack, image);
int top = leftTopBlack[1];
int bottom = rightBottomBlack[1];
int left = leftTopBlack[0];
int right = rightBottomBlack[0];
int matrixWidth = (right - left + 1) / moduleSize;
int matrixHeight = (bottom - top + 1) / moduleSize;
if (matrixWidth <= 0 || matrixHeight <= 0) {
throw NotFoundException.getNotFoundInstance();
}
// Push in the "border" by half the module width so that we start
// sampling in the middle of the module. Just in case the image is a
// little off, this will help recover.
int nudge = moduleSize / 2;
top += nudge;
left += nudge;
// Now just read off the bits
BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight);
for (int y = 0; y < matrixHeight; y++) {
int iOffset = top + y * moduleSize;
for (int x = 0; x < matrixWidth; x++) {
if (image.get(left + x * moduleSize, iOffset)) {
bits.set(x, y);
}
}
}
return bits;
}
示例3: extractPureBits
import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
int[] leftTopBlack = image.getTopLeftOnBit();
int[] rightBottomBlack = image.getBottomRightOnBit();
if (leftTopBlack == null || rightBottomBlack == null) {
throw NotFoundException.getNotFoundInstance();
}
float moduleSize = moduleSize(leftTopBlack, image);
int top = leftTopBlack[1];
int bottom = rightBottomBlack[1];
int left = leftTopBlack[0];
int right = rightBottomBlack[0];
if (left >= right || top >= bottom) {
throw NotFoundException.getNotFoundInstance();
}
if (bottom - top != right - left) {
right = left + (bottom - top);
}
int matrixWidth = Math.round(((float) ((right - left) + 1)) / moduleSize);
int matrixHeight = Math.round(((float) ((bottom - top) + 1)) / moduleSize);
if (matrixWidth <= 0 || matrixHeight <= 0) {
throw NotFoundException.getNotFoundInstance();
} else if (matrixHeight != matrixWidth) {
throw NotFoundException.getNotFoundInstance();
} else {
int nudge = (int) (moduleSize / 2.0f);
top += nudge;
left += nudge;
int nudgedTooFarRight = (((int) (((float) (matrixWidth - 1)) * moduleSize)) + left) -
right;
if (nudgedTooFarRight > 0) {
if (nudgedTooFarRight > nudge) {
throw NotFoundException.getNotFoundInstance();
}
left -= nudgedTooFarRight;
}
int nudgedTooFarDown = (((int) (((float) (matrixHeight - 1)) * moduleSize)) + top) -
bottom;
if (nudgedTooFarDown > 0) {
if (nudgedTooFarDown > nudge) {
throw NotFoundException.getNotFoundInstance();
}
top -= nudgedTooFarDown;
}
BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight);
for (int y = 0; y < matrixHeight; y++) {
int iOffset = top + ((int) (((float) y) * moduleSize));
for (int x = 0; x < matrixWidth; x++) {
if (image.get(((int) (((float) x) * moduleSize)) + left, iOffset)) {
bits.set(x, y);
}
}
}
return bits;
}
}