Search in sources :

Example 81 with BitMatrix

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));
}
Also used : BitMatrix(com.google.zxing.common.BitMatrix)

Example 82 with BitMatrix

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));
}
Also used : BitMatrix(com.google.zxing.common.BitMatrix) Test(org.junit.Test)

Example 83 with BitMatrix

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));
}
Also used : BitMatrix(com.google.zxing.common.BitMatrix)

Example 84 with BitMatrix

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));
}
Also used : BitMatrix(com.google.zxing.common.BitMatrix) Test(org.junit.Test)

Example 85 with BitMatrix

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);
}
Also used : ResultPoint(com.google.zxing.ResultPoint) Version(com.google.zxing.qrcode.decoder.Version) PerspectiveTransform(com.google.zxing.common.PerspectiveTransform) NotFoundException(com.google.zxing.NotFoundException) DetectorResult(com.google.zxing.common.DetectorResult) BitMatrix(com.google.zxing.common.BitMatrix) ResultPoint(com.google.zxing.ResultPoint)

Aggregations

BitMatrix (com.google.zxing.common.BitMatrix)119 EncodeHintType (com.google.zxing.EncodeHintType)27 ResultPoint (com.google.zxing.ResultPoint)26 Test (org.junit.Test)20 Bitmap (android.graphics.Bitmap)18 QRCodeWriter (com.google.zxing.qrcode.QRCodeWriter)17 WriterException (com.google.zxing.WriterException)14 DecoderResult (com.google.zxing.common.DecoderResult)12 EnumMap (java.util.EnumMap)11 MultiFormatWriter (com.google.zxing.MultiFormatWriter)10 DetectorResult (com.google.zxing.common.DetectorResult)10 Hashtable (java.util.Hashtable)10 AztecDetectorResult (com.google.zxing.aztec.AztecDetectorResult)8 Result (com.google.zxing.Result)7 Point (com.google.zxing.aztec.detector.Detector.Point)5 SymbolShapeHint (com.google.zxing.datamatrix.encoder.SymbolShapeHint)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 NotFoundException (com.google.zxing.NotFoundException)4