package com.google.zxing.oned;
-import java.util.Hashtable;
-
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
-import com.google.zxing.common.ByteMatrix;
+import com.google.zxing.common.BitMatrix;
+
+import java.util.Hashtable;
/**
- * This object renders an EAN13 code as a ByteMatrix 2D array of greyscale
- * values.
- *
+ * This object renders an EAN13 code as a {@link BitMatrix}.
+ *
* @author aripollak@gmail.com (Ari Pollak)
*/
-public final class EAN13Writer extends AbstractUPCEANWriter {
+public final class EAN13Writer extends UPCEANWriter {
private static final int codeWidth = 3 + // start guard
(7 * 6) + // left bars
(7 * 6) + // right bars
3; // end guard
- public ByteMatrix encode(String contents, BarcodeFormat format, int width, int height,
+ public BitMatrix encode(String contents, BarcodeFormat format, int width, int height,
Hashtable hints) throws WriterException {
if (format != BarcodeFormat.EAN_13) {
throw new IllegalArgumentException("Can only encode EAN_13, but got " + format);
}
-
+
return super.encode(contents, format, width, height, hints);
}
byte[] result = new byte[codeWidth];
int pos = 0;
- pos += appendPattern(result, pos, AbstractUPCEANReader.START_END_PATTERN, 1);
+ pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, 1);
// See {@link #EAN13Reader} for a description of how the first digit & left bars are encoded
for (int i = 1; i <= 6; i++) {
if ((parities >> (6 - i) & 1) == 1) {
digit += 10;
}
- pos += appendPattern(result, pos, AbstractUPCEANReader.L_AND_G_PATTERNS[digit], 0);
+ pos += appendPattern(result, pos, UPCEANReader.L_AND_G_PATTERNS[digit], 0);
}
- pos += appendPattern(result, pos, AbstractUPCEANReader.MIDDLE_PATTERN, 0);
+ pos += appendPattern(result, pos, UPCEANReader.MIDDLE_PATTERN, 0);
for (int i = 7; i <= 12; i++) {
int digit = Integer.parseInt(contents.substring(i, i + 1));
- pos += appendPattern(result, pos, AbstractUPCEANReader.L_PATTERNS[digit], 1);
+ pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], 1);
}
- pos += appendPattern(result, pos, AbstractUPCEANReader.START_END_PATTERN, 1);
+ pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, 1);
return result;
}