use of com.google.zxing.common.BitMatrix in project zxing by zxing.
the class Code93WriterTestCase method doTest.
private static void doTest(String input, CharSequence expected) throws WriterException {
BitMatrix result = new Code93Writer().encode(input, BarcodeFormat.CODE_93, 0, 0);
assertEquals(expected, BitMatrixTestCase.matrixToString(result));
}
use of com.google.zxing.common.BitMatrix in project zxing by zxing.
the class EAN8WriterTestCase method testEncode.
@Test
public void testEncode() throws WriterException {
String testStr = "0000001010001011010111101111010110111010101001110111001010001001011100101000000";
BitMatrix result = new EAN8Writer().encode("96385074", BarcodeFormat.EAN_8, testStr.length(), 0);
assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
}
use of com.google.zxing.common.BitMatrix in project zxing by zxing.
the class ITFWriterTestCase method doTest.
private static void doTest(String input, CharSequence expected) throws WriterException {
BitMatrix result = new ITFWriter().encode(input, BarcodeFormat.ITF, 0, 0);
assertEquals(expected, BitMatrixTestCase.matrixToString(result));
}
use of com.google.zxing.common.BitMatrix in project zxing by zxing.
the class UPCAWriterTestCase method testEncode.
@Test
public void testEncode() throws WriterException {
String testStr = "00001010100011011011101100010001011010111101111010101011100101110100100111011001101101100101110010100000";
BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0);
assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
}
use of com.google.zxing.common.BitMatrix in project zxing by zxing.
the class Detector method processFinderPatternInfo.
protected final DetectorResult processFinderPatternInfo(FinderPatternInfo info) throws NotFoundException, FormatException {
FinderPattern topLeft = info.getTopLeft();
FinderPattern topRight = info.getTopRight();
FinderPattern bottomLeft = info.getBottomLeft();
float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
if (moduleSize < 1.0f) {
throw NotFoundException.getNotFoundInstance();
}
int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);
Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;
AlignmentPattern alignmentPattern = null;
// Anything above version 1 has an alignment pattern
if (provisionalVersion.getAlignmentPatternCenters().length > 0) {
// Guess where a "bottom right" finder pattern would have been
float bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();
float bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();
// Estimate that alignment pattern is closer by 3 modules
// from "bottom right" to known top left location
float correctionToTopLeft = 1.0f - 3.0f / modulesBetweenFPCenters;
int estAlignmentX = (int) (topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
int estAlignmentY = (int) (topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));
// Kind of arbitrary -- expand search radius before giving up
for (int i = 4; i <= 16; i <<= 1) {
try {
alignmentPattern = findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i);
break;
} catch (NotFoundException re) {
// try next round
}
}
// If we didn't find alignment pattern... well try anyway without it
}
PerspectiveTransform transform = createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
BitMatrix bits = sampleGrid(image, transform, dimension);
ResultPoint[] points;
if (alignmentPattern == null) {
points = new ResultPoint[] { bottomLeft, topLeft, topRight };
} else {
points = new ResultPoint[] { bottomLeft, topLeft, topRight, alignmentPattern };
}
return new DetectorResult(bits, points);
}
Aggregations