Thrown when an exception occurs during Reed-Solomon decoding, such as when 21 | * there are too many errors to correct.
22 | * 23 | * @author Sean Owen 24 | */ 25 | public final class ReedSolomonException extends Exception { 26 | 27 | public ReedSolomonException(String message) { 28 | super(message); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/ParsedResultType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | /** 20 | * Represents the type of data encoded by a barcode -- from plain text, to a 21 | * URI, to an e-mail address, etc. 22 | * 23 | * @author Sean Owen 24 | */ 25 | public enum ParsedResultType { 26 | 27 | ADDRESSBOOK, 28 | EMAIL_ADDRESS, 29 | PRODUCT, 30 | URI, 31 | TEXT, 32 | GEO, 33 | TEL, 34 | SMS, 35 | CALENDAR, 36 | WIFI, 37 | ISBN, 38 | VIN, 39 | 40 | } 41 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/datamatrix/encoder/DataMatrixSymbolInfo144.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 Jeremias Maerki 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.datamatrix.encoder; 18 | 19 | 20 | final class DataMatrixSymbolInfo144 extends SymbolInfo { 21 | 22 | DataMatrixSymbolInfo144() { 23 | super(false, 1558, 620, 22, 22, 36, -1, 62); 24 | } 25 | 26 | @Override 27 | public int getInterleavedBlockCount() { 28 | return 10; 29 | } 30 | 31 | @Override 32 | public int getDataLengthForInterleavedBlock(int index) { 33 | return (index <= 8) ? 156 : 155; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/qrcode/encoder/BlockPair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.qrcode.encoder; 18 | 19 | final class BlockPair { 20 | 21 | private final byte[] dataBytes; 22 | private final byte[] errorCorrectionBytes; 23 | 24 | BlockPair(byte[] data, byte[] errorCorrection) { 25 | dataBytes = data; 26 | errorCorrectionBytes = errorCorrection; 27 | } 28 | 29 | public byte[] getDataBytes() { 30 | return dataBytes; 31 | } 32 | 33 | public byte[] getErrorCorrectionBytes() { 34 | return errorCorrectionBytes; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/WriterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing; 18 | 19 | /** 20 | * A base class which covers the range of exceptions which may occur when encoding a barcode using 21 | * the Writer framework. 22 | * 23 | * @author dswitkin@google.com (Daniel Switkin) 24 | */ 25 | public final class WriterException extends Exception { 26 | 27 | public WriterException() { 28 | } 29 | 30 | public WriterException(String message) { 31 | super(message); 32 | } 33 | 34 | public WriterException(Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/UPCEANWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.oned; 18 | 19 | 20 | /** 21 | *Encapsulates functionality and implementation that is common to UPC and EAN families 22 | * of one-dimensional barcodes.
23 | * 24 | * @author aripollak@gmail.com (Ari Pollak) 25 | * @author dsbnatut@gmail.com (Kazuki Nishiura) 26 | */ 27 | public abstract class UPCEANWriter extends OneDimensionalCodeWriter { 28 | 29 | @Override 30 | public int getDefaultMargin() { 31 | // Use a different default more appropriate for UPC/EAN 32 | return 9; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /ZxingScan/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 |Encapsulates the result of detecting a barcode in an image. This includes the raw 24 | * matrix of black/white pixels corresponding to the barcode, and possibly points of interest 25 | * in the image, like the location of finder patterns or corners of the barcode in the image.
26 | * 27 | * @author Sean Owen 28 | */ 29 | public class DetectorResult { 30 | 31 | private final BitMatrix bits; 32 | private final ResultPoint[] points; 33 | 34 | public DetectorResult(BitMatrix bits, ResultPoint[] points) { 35 | this.bits = bits; 36 | this.points = points; 37 | } 38 | 39 | public final BitMatrix getBits() { 40 | return bits; 41 | } 42 | 43 | public final ResultPoint[] getPoints() { 44 | return points; 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/TelResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | 20 | import com.zhouk.zxing.Result; 21 | 22 | /** 23 | * Parses a "tel:" URI result, which specifies a phone number. 24 | * 25 | * @author Sean Owen 26 | */ 27 | public final class TelResultParser extends ResultParser { 28 | 29 | @Override 30 | public TelParsedResult parse(Result result) { 31 | String rawText = getMassagedText(result); 32 | if (!rawText.startsWith("tel:") && !rawText.startsWith("TEL:")) { 33 | return null; 34 | } 35 | // Normalize "TEL:" to "tel:" 36 | String telURI = rawText.startsWith("TEL:") ? "tel:" + rawText.substring(4) : rawText; 37 | // Drop tel, query portion 38 | int queryStart = rawText.indexOf('?', 4); 39 | String number = queryStart < 0 ? rawText.substring(4) : rawText.substring(4, queryStart); 40 | return new TelParsedResult(number, telURI, null); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/AbstractDoCoMoResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | 20 | /** 21 | *See 22 | * 23 | * DoCoMo's documentation about the result types represented by subclasses of this class.
24 | * 25 | *Thanks to Jeff Griffin for proposing rewrite of these classes that relies less 26 | * on exception-based mechanisms during parsing.
27 | * 28 | * @author Sean Owen 29 | */ 30 | abstract class AbstractDoCoMoResultParser extends ResultParser { 31 | 32 | static String[] matchDoCoMoPrefixedField(String prefix, String rawText) { 33 | return matchPrefixedField(prefix, rawText, ';', true); 34 | } 35 | 36 | static String matchSingleDoCoMoPrefixedField(String prefix, String rawText, boolean trim) { 37 | return matchSinglePrefixedField(prefix, rawText, ';', trim); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/pdf417/encoder/Dimensions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.pdf417.encoder; 18 | 19 | /** 20 | * Data object to specify the minimum and maximum number of rows and columns for a PDF417 barcode. 21 | * 22 | * @author qwandor@google.com (Andrew Walbran) 23 | */ 24 | public final class Dimensions { 25 | 26 | private final int minCols; 27 | private final int maxCols; 28 | private final int minRows; 29 | private final int maxRows; 30 | 31 | public Dimensions(int minCols, int maxCols, int minRows, int maxRows) { 32 | this.minCols = minCols; 33 | this.maxCols = maxCols; 34 | this.minRows = minRows; 35 | this.maxRows = maxRows; 36 | } 37 | 38 | public int getMinCols() { 39 | return minCols; 40 | } 41 | 42 | public int getMaxCols() { 43 | return maxCols; 44 | } 45 | 46 | public int getMinRows() { 47 | return minRows; 48 | } 49 | 50 | public int getMaxRows() { 51 | return maxRows; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/ChecksumException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing; 18 | 19 | 20 | /** 21 | * Thrown when a barcode was successfully detected and decoded, but 22 | * was not returned because its checksum feature failed. 23 | * 24 | * @author Sean Owen 25 | */ 26 | public final class ChecksumException extends ReaderException { 27 | 28 | private static final ChecksumException INSTANCE = new ChecksumException(); 29 | static { 30 | INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless 31 | } 32 | 33 | private ChecksumException() { 34 | // do nothing 35 | } 36 | 37 | private ChecksumException(Throwable cause) { 38 | super(cause); 39 | } 40 | 41 | public static ChecksumException getChecksumInstance() { 42 | return isStackTrace ? new ChecksumException() : INSTANCE; 43 | } 44 | 45 | public static ChecksumException getChecksumInstance(Throwable cause) { 46 | return isStackTrace ? new ChecksumException(cause) : INSTANCE; 47 | } 48 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/qrcode/detector/FinderPatternInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.qrcode.detector; 18 | 19 | 20 | /** 21 | *Encapsulates information about finder patterns in an image, including the location of 22 | * the three finder patterns, and their estimated module size.
23 | * 24 | * @author Sean Owen 25 | */ 26 | public final class FinderPatternInfo { 27 | 28 | private final FinderPattern bottomLeft; 29 | private final FinderPattern topLeft; 30 | private final FinderPattern topRight; 31 | 32 | public FinderPatternInfo(FinderPattern[] patternCenters) { 33 | this.bottomLeft = patternCenters[0]; 34 | this.topLeft = patternCenters[1]; 35 | this.topRight = patternCenters[2]; 36 | } 37 | 38 | public FinderPattern getBottomLeft() { 39 | return bottomLeft; 40 | } 41 | 42 | public FinderPattern getTopLeft() { 43 | return topLeft; 44 | } 45 | 46 | public FinderPattern getTopRight() { 47 | return topRight; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/FormatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing; 18 | 19 | 20 | /** 21 | * Thrown when a barcode was successfully detected, but some aspect of 22 | * the content did not conform to the barcode's format rules. This could have 23 | * been due to a mis-detection. 24 | * 25 | * @author Sean Owen 26 | */ 27 | public final class FormatException extends ReaderException { 28 | 29 | private static final FormatException INSTANCE = new FormatException(); 30 | static { 31 | INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless 32 | } 33 | 34 | private FormatException() { 35 | } 36 | 37 | private FormatException(Throwable cause) { 38 | super(cause); 39 | } 40 | 41 | public static FormatException getFormatInstance() { 42 | return isStackTrace ? new FormatException() : INSTANCE; 43 | } 44 | 45 | public static FormatException getFormatInstance(Throwable cause) { 46 | return isStackTrace ? new FormatException(cause) : INSTANCE; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/URLTOResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | import com.zhouk.zxing.Result; 20 | 21 | /** 22 | * Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]". 23 | * This seems to be used sometimes, but I am not able to find documentation 24 | * on its origin or official format? 25 | * 26 | * @author Sean Owen 27 | */ 28 | public final class URLTOResultParser extends ResultParser { 29 | 30 | @Override 31 | public URIParsedResult parse(Result result) { 32 | String rawText = getMassagedText(result); 33 | if (!rawText.startsWith("urlto:") && !rawText.startsWith("URLTO:")) { 34 | return null; 35 | } 36 | int titleEnd = rawText.indexOf(':', 6); 37 | if (titleEnd < 0) { 38 | return null; 39 | } 40 | String title = titleEnd <= 6 ? null : rawText.substring(6, titleEnd); 41 | String uri = rawText.substring(titleEnd + 1); 42 | return new URIParsedResult(uri, title); 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/ReaderException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing; 18 | 19 | /** 20 | * The general exception class throw when something goes wrong during decoding of a barcode. 21 | * This includes, but is not limited to, failing checksums / error correction algorithms, being 22 | * unable to locate finder timing patterns, and so on. 23 | * 24 | * @author Sean Owen 25 | */ 26 | public abstract class ReaderException extends Exception { 27 | 28 | // disable stack traces when not running inside test units 29 | protected static final boolean isStackTrace = 30 | System.getProperty("surefire.test.class.path") != null; 31 | protected static final StackTraceElement[] NO_TRACE = new StackTraceElement[0]; 32 | 33 | ReaderException() { 34 | // do nothing 35 | } 36 | 37 | ReaderException(Throwable cause) { 38 | super(cause); 39 | } 40 | 41 | // Prevent stack traces from being taken 42 | @Override 43 | public final synchronized Throwable fillInStackTrace() { 44 | return null; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/ProductParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | 20 | /** 21 | * Represents a parsed result that encodes a product by an identifier of some kind. 22 | * 23 | * @author dswitkin@google.com (Daniel Switkin) 24 | */ 25 | public final class ProductParsedResult extends ParsedResult { 26 | 27 | private final String productID; 28 | private final String normalizedProductID; 29 | 30 | ProductParsedResult(String productID) { 31 | this(productID, productID); 32 | } 33 | 34 | ProductParsedResult(String productID, String normalizedProductID) { 35 | super(ParsedResultType.PRODUCT); 36 | this.productID = productID; 37 | this.normalizedProductID = normalizedProductID; 38 | } 39 | 40 | public String getProductID() { 41 | return productID; 42 | } 43 | 44 | public String getNormalizedProductID() { 45 | return normalizedProductID; 46 | } 47 | 48 | @Override 49 | public String getDisplayResult() { 50 | return productID; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/ISBNResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | 20 | import com.zhouk.zxing.BarcodeFormat; 21 | import com.zhouk.zxing.Result; 22 | 23 | /** 24 | * Parses strings of digits that represent a ISBN. 25 | * 26 | * @author jbreiden@google.com (Jeff Breidenbach) 27 | */ 28 | public final class ISBNResultParser extends ResultParser { 29 | 30 | /** 31 | * See ISBN-13 For Dummies 32 | */ 33 | @Override 34 | public ISBNParsedResult parse(Result result) { 35 | BarcodeFormat format = result.getBarcodeFormat(); 36 | if (format != BarcodeFormat.EAN_13) { 37 | return null; 38 | } 39 | String rawText = getMassagedText(result); 40 | int length = rawText.length(); 41 | if (length != 13) { 42 | return null; 43 | } 44 | if (!rawText.startsWith("978") && !rawText.startsWith("979")) { 45 | return null; 46 | } 47 | 48 | return new ISBNParsedResult(rawText); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/expanded/decoders/AI013103decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.zhouk.zxing.oned.rss.expanded.decoders; 28 | 29 | 30 | import com.zhouk.zxing.common.BitArray; 31 | 32 | /** 33 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 34 | */ 35 | final class AI013103decoder extends AI013x0xDecoder { 36 | 37 | AI013103decoder(BitArray information) { 38 | super(information); 39 | } 40 | 41 | @Override 42 | protected void addWeightCode(StringBuilder buf, int weight) { 43 | buf.append("(3103)"); 44 | } 45 | 46 | @Override 47 | protected int checkWeight(int weight) { 48 | return weight; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/Dimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing; 18 | 19 | /** 20 | * Simply encapsulates a width and height. 21 | */ 22 | public final class Dimension { 23 | 24 | private final int width; 25 | private final int height; 26 | 27 | public Dimension(int width, int height) { 28 | if (width < 0 || height < 0) { 29 | throw new IllegalArgumentException(); 30 | } 31 | this.width = width; 32 | this.height = height; 33 | } 34 | 35 | public int getWidth() { 36 | return width; 37 | } 38 | 39 | public int getHeight() { 40 | return height; 41 | } 42 | 43 | @Override 44 | public boolean equals(Object other) { 45 | if (other instanceof Dimension) { 46 | Dimension d = (Dimension) other; 47 | return width == d.width && height == d.height; 48 | } 49 | return false; 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | return width * 32713 + height; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return width + "x" + height; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/TelParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | 20 | /** 21 | * Represents a parsed result that encodes a telephone number. 22 | * 23 | * @author Sean Owen 24 | */ 25 | public final class TelParsedResult extends ParsedResult { 26 | 27 | private final String number; 28 | private final String telURI; 29 | private final String title; 30 | 31 | public TelParsedResult(String number, String telURI, String title) { 32 | super(ParsedResultType.TEL); 33 | this.number = number; 34 | this.telURI = telURI; 35 | this.title = title; 36 | } 37 | 38 | public String getNumber() { 39 | return number; 40 | } 41 | 42 | public String getTelURI() { 43 | return telURI; 44 | } 45 | 46 | public String getTitle() { 47 | return title; 48 | } 49 | 50 | @Override 51 | public String getDisplayResult() { 52 | StringBuilder result = new StringBuilder(20); 53 | maybeAppend(number, result); 54 | maybeAppend(title, result); 55 | return result.toString(); 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zhouk/qrzxingscan/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.zhouk.qrzxingscan; 2 | 3 | import android.Manifest; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.support.v4.content.ContextCompat; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | import android.view.View; 11 | import android.widget.Toast; 12 | 13 | import com.zhouk.zxing.QRScanActivity; 14 | 15 | import static com.zhouk.zxing.QRScanActivity.SCAN_CODE; 16 | 17 | public class MainActivity extends AppCompatActivity { 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | requestPermission(); 23 | } 24 | private void requestPermission() { 25 | if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) 26 | != PackageManager.PERMISSION_GRANTED) { 27 | ActivityCompat.requestPermissions(this, 28 | new String[]{Manifest.permission.CAMERA}, 29 | 1); 30 | } 31 | } 32 | public void goScan(View view){ 33 | Intent intent = new Intent(this, QRScanActivity.class); 34 | startActivityForResult(intent,SCAN_CODE); 35 | } 36 | 37 | @Override 38 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 39 | super.onActivityResult(requestCode, resultCode, data); 40 | if(resultCode==RESULT_OK&&requestCode==SCAN_CODE){ 41 | Toast.makeText(this,data.getStringExtra("code"),Toast.LENGTH_SHORT).show(); 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/camera/open/OpenCamera.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.camera.open; 18 | 19 | import android.hardware.Camera; 20 | 21 | 22 | /** 23 | * Represents an open {@link Camera} and its metadata, like facing direction and orientation. 24 | */ 25 | @SuppressWarnings("deprecation") // camera APIs 26 | public final class OpenCamera { 27 | 28 | private final int index; 29 | private final Camera camera; 30 | private final CameraFacing facing; 31 | private final int orientation; 32 | 33 | public OpenCamera(int index, Camera camera, CameraFacing facing, int orientation) { 34 | this.index = index; 35 | this.camera = camera; 36 | this.facing = facing; 37 | this.orientation = orientation; 38 | } 39 | 40 | public Camera getCamera() { 41 | return camera; 42 | } 43 | 44 | public CameraFacing getFacing() { 45 | return facing; 46 | } 47 | 48 | public int getOrientation() { 49 | return orientation; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "Camera #" + index + " : " + facing + ',' + orientation; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/DataCharacter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.oned.rss; 18 | 19 | /** 20 | * Encapsulates a since character value in an RSS barcode, including its checksum information. 21 | */ 22 | public class DataCharacter { 23 | 24 | private final int value; 25 | private final int checksumPortion; 26 | 27 | public DataCharacter(int value, int checksumPortion) { 28 | this.value = value; 29 | this.checksumPortion = checksumPortion; 30 | } 31 | 32 | public final int getValue() { 33 | return value; 34 | } 35 | 36 | public final int getChecksumPortion() { 37 | return checksumPortion; 38 | } 39 | 40 | @Override 41 | public final String toString() { 42 | return value + "(" + checksumPortion + ')'; 43 | } 44 | 45 | @Override 46 | public final boolean equals(Object o) { 47 | if (!(o instanceof DataCharacter)) { 48 | return false; 49 | } 50 | DataCharacter that = (DataCharacter) o; 51 | return value == that.value && checksumPortion == that.checksumPortion; 52 | } 53 | 54 | @Override 55 | public final int hashCode() { 56 | return value ^ checksumPortion; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/expanded/decoders/DecodedChar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.zhouk.zxing.oned.rss.expanded.decoders; 28 | 29 | 30 | /** 31 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 32 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 33 | */ 34 | final class DecodedChar extends DecodedObject { 35 | 36 | private final char value; 37 | 38 | static final char FNC1 = '$'; // It's not in Alphanumeric neither in ISO/IEC 646 charset 39 | 40 | DecodedChar(int newPosition, char value) { 41 | super(newPosition); 42 | this.value = value; 43 | } 44 | 45 | char getValue() { 46 | return this.value; 47 | } 48 | 49 | boolean isFNC1() { 50 | return this.value == FNC1; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/UPCEANExtensionSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.oned; 18 | 19 | import com.zhouk.zxing.NotFoundException; 20 | import com.zhouk.zxing.ReaderException; 21 | import com.zhouk.zxing.Result; 22 | import com.zhouk.zxing.common.BitArray; 23 | import com.zhouk.zxing.oned.UPCEANExtension2Support; 24 | import com.zhouk.zxing.oned.UPCEANExtension5Support; 25 | import com.zhouk.zxing.oned.UPCEANReader; 26 | 27 | final class UPCEANExtensionSupport { 28 | 29 | private static final int[] EXTENSION_START_PATTERN = {1,1,2}; 30 | 31 | private final UPCEANExtension2Support twoSupport = new UPCEANExtension2Support(); 32 | private final UPCEANExtension5Support fiveSupport = new UPCEANExtension5Support(); 33 | 34 | Result decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException { 35 | int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN); 36 | try { 37 | return fiveSupport.decodeRow(rowNumber, row, extensionStartRange); 38 | } catch (ReaderException ignored) { 39 | return twoSupport.decodeRow(rowNumber, row, extensionStartRange); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/pdf417/decoder/BarcodeMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.pdf417.decoder; 18 | 19 | /** 20 | * @author Guenther Grau 21 | */ 22 | final class BarcodeMetadata { 23 | 24 | private final int columnCount; 25 | private final int errorCorrectionLevel; 26 | private final int rowCountUpperPart; 27 | private final int rowCountLowerPart; 28 | private final int rowCount; 29 | 30 | BarcodeMetadata(int columnCount, int rowCountUpperPart, int rowCountLowerPart, int errorCorrectionLevel) { 31 | this.columnCount = columnCount; 32 | this.errorCorrectionLevel = errorCorrectionLevel; 33 | this.rowCountUpperPart = rowCountUpperPart; 34 | this.rowCountLowerPart = rowCountLowerPart; 35 | this.rowCount = rowCountUpperPart + rowCountLowerPart; 36 | } 37 | 38 | int getColumnCount() { 39 | return columnCount; 40 | } 41 | 42 | int getErrorCorrectionLevel() { 43 | return errorCorrectionLevel; 44 | } 45 | 46 | int getRowCount() { 47 | return rowCount; 48 | } 49 | 50 | int getRowCountUpperPart() { 51 | return rowCountUpperPart; 52 | } 53 | 54 | int getRowCountLowerPart() { 55 | return rowCountLowerPart; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 |See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels 21 | * defined by the QR code standard.
22 | * 23 | * @author Sean Owen 24 | */ 25 | public enum ErrorCorrectionLevel { 26 | 27 | /** L = ~7% correction */ 28 | L(0x01), 29 | /** M = ~15% correction */ 30 | M(0x00), 31 | /** Q = ~25% correction */ 32 | Q(0x03), 33 | /** H = ~30% correction */ 34 | H(0x02); 35 | 36 | private static final ErrorCorrectionLevel[] FOR_BITS = {M, L, H, Q}; 37 | 38 | private final int bits; 39 | 40 | ErrorCorrectionLevel(int bits) { 41 | this.bits = bits; 42 | } 43 | 44 | public int getBits() { 45 | return bits; 46 | } 47 | 48 | /** 49 | * @param bits int containing the two bits encoding a QR Code's error correction level 50 | * @return ErrorCorrectionLevel representing the encoded error correction level 51 | */ 52 | public static ErrorCorrectionLevel forBits(int bits) { 53 | if (bits < 0 || bits >= FOR_BITS.length) { 54 | throw new IllegalArgumentException(); 55 | } 56 | return FOR_BITS[bits]; 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/BarcodeFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing; 18 | 19 | /** 20 | * Enumerates barcode formats known to this package. Please keep alphabetized. 21 | * 22 | * @author Sean Owen 23 | */ 24 | public enum BarcodeFormat { 25 | 26 | /** Aztec 2D barcode format. */ 27 | AZTEC, 28 | 29 | /** CODABAR 1D format. */ 30 | CODABAR, 31 | 32 | /** Code 39 1D format. */ 33 | CODE_39, 34 | 35 | /** Code 93 1D format. */ 36 | CODE_93, 37 | 38 | /** Code 128 1D format. */ 39 | CODE_128, 40 | 41 | /** Data Matrix 2D barcode format. */ 42 | DATA_MATRIX, 43 | 44 | /** EAN-8 1D format. */ 45 | EAN_8, 46 | 47 | /** EAN-13 1D format. */ 48 | EAN_13, 49 | 50 | /** ITF (Interleaved Two of Five) 1D format. */ 51 | ITF, 52 | 53 | /** MaxiCode 2D barcode format. */ 54 | MAXICODE, 55 | 56 | /** PDF417 format. */ 57 | PDF_417, 58 | 59 | /** QR Code 2D barcode format. */ 60 | QR_CODE, 61 | 62 | /** RSS 14 */ 63 | RSS_14, 64 | 65 | /** RSS EXPANDED */ 66 | RSS_EXPANDED, 67 | 68 | /** UPC-A 1D format. */ 69 | UPC_A, 70 | 71 | /** UPC-E 1D format. */ 72 | UPC_E, 73 | 74 | /** UPC/EAN extension format. Not a stand-alone format. */ 75 | UPC_EAN_EXTENSION 76 | 77 | } 78 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/expanded/decoders/AnyAIDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.zhouk.zxing.oned.rss.expanded.decoders; 28 | 29 | 30 | import com.zhouk.zxing.FormatException; 31 | import com.zhouk.zxing.NotFoundException; 32 | import com.zhouk.zxing.common.BitArray; 33 | 34 | /** 35 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 36 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 37 | */ 38 | final class AnyAIDecoder extends AbstractExpandedDecoder { 39 | 40 | private static final int HEADER_SIZE = 2 + 1 + 2; 41 | 42 | AnyAIDecoder(BitArray information) { 43 | super(information); 44 | } 45 | 46 | @Override 47 | public String parseInformation() throws NotFoundException, FormatException { 48 | StringBuilder buf = new StringBuilder(); 49 | return this.getGeneralDecoder().decodeAllCodes(buf, HEADER_SIZE); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/expanded/decoders/BlockParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.zhouk.zxing.oned.rss.expanded.decoders; 28 | 29 | 30 | /** 31 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 32 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 33 | */ 34 | final class BlockParsedResult { 35 | 36 | private final DecodedInformation decodedInformation; 37 | private final boolean finished; 38 | 39 | BlockParsedResult(boolean finished) { 40 | this(null, finished); 41 | } 42 | 43 | BlockParsedResult(DecodedInformation information, boolean finished) { 44 | this.finished = finished; 45 | this.decodedInformation = information; 46 | } 47 | 48 | DecodedInformation getDecodedInformation() { 49 | return this.decodedInformation; 50 | } 51 | 52 | boolean isFinished() { 53 | return this.finished; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/FinderPattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.oned.rss; 18 | 19 | 20 | import com.zhouk.zxing.ResultPoint; 21 | 22 | /** 23 | * Encapsulates an RSS barcode finder pattern, including its start/end position and row. 24 | */ 25 | public final class FinderPattern { 26 | 27 | private final int value; 28 | private final int[] startEnd; 29 | private final ResultPoint[] resultPoints; 30 | 31 | public FinderPattern(int value, int[] startEnd, int start, int end, int rowNumber) { 32 | this.value = value; 33 | this.startEnd = startEnd; 34 | this.resultPoints = new ResultPoint[] { 35 | new ResultPoint(start, rowNumber), 36 | new ResultPoint(end, rowNumber), 37 | }; 38 | } 39 | 40 | public int getValue() { 41 | return value; 42 | } 43 | 44 | public int[] getStartEnd() { 45 | return startEnd; 46 | } 47 | 48 | public ResultPoint[] getResultPoints() { 49 | return resultPoints; 50 | } 51 | 52 | @Override 53 | public boolean equals(Object o) { 54 | if (!(o instanceof FinderPattern)) { 55 | return false; 56 | } 57 | FinderPattern that = (FinderPattern) o; 58 | return value == that.value; 59 | } 60 | 61 | @Override 62 | public int hashCode() { 63 | return value; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 |Parses an "smtp:" URI result, whose format is not standardized but appears to be like: 23 | * {@code smtp[:subject[:body]]}.
24 | * 25 | * @author Sean Owen 26 | */ 27 | public final class SMTPResultParser extends ResultParser { 28 | 29 | @Override 30 | public EmailAddressParsedResult parse(Result result) { 31 | String rawText = getMassagedText(result); 32 | if (!(rawText.startsWith("smtp:") || rawText.startsWith("SMTP:"))) { 33 | return null; 34 | } 35 | String emailAddress = rawText.substring(5); 36 | String subject = null; 37 | String body = null; 38 | int colon = emailAddress.indexOf(':'); 39 | if (colon >= 0) { 40 | subject = emailAddress.substring(colon + 1); 41 | emailAddress = emailAddress.substring(0, colon); 42 | colon = subject.indexOf(':'); 43 | if (colon >= 0) { 44 | body = subject.substring(colon + 1); 45 | subject = subject.substring(0, colon); 46 | } 47 | } 48 | return new EmailAddressParsedResult(new String[] {emailAddress}, 49 | null, 50 | null, 51 | subject, 52 | body); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/SMSTOMMSTOResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | 20 | import com.zhouk.zxing.Result; 21 | 22 | /** 23 | *Parses an "smsto:" URI result, whose format is not standardized but appears to be like: 24 | * {@code smsto:number(:body)}.
25 | * 26 | *This actually also parses URIs starting with "smsto:", "mmsto:", "SMSTO:", and 27 | * "MMSTO:", and treats them all the same way, and effectively converts them to an "sms:" URI 28 | * for purposes of forwarding to the platform.
29 | * 30 | * @author Sean Owen 31 | */ 32 | public final class SMSTOMMSTOResultParser extends ResultParser { 33 | 34 | @Override 35 | public SMSParsedResult parse(Result result) { 36 | String rawText = getMassagedText(result); 37 | if (!(rawText.startsWith("smsto:") || rawText.startsWith("SMSTO:") || 38 | rawText.startsWith("mmsto:") || rawText.startsWith("MMSTO:"))) { 39 | return null; 40 | } 41 | // Thanks to dominik.wild for suggesting this enhancement to support 42 | // smsto:number:body URIs 43 | String number = rawText.substring(6); 44 | String body = null; 45 | int bodyStart = number.indexOf(':'); 46 | if (bodyStart >= 0) { 47 | body = number.substring(bodyStart + 1); 48 | number = number.substring(0, bodyStart); 49 | } 50 | return new SMSParsedResult(number, null, null, body); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/ProductResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | 20 | import com.zhouk.zxing.BarcodeFormat; 21 | import com.zhouk.zxing.Result; 22 | import com.zhouk.zxing.oned.UPCEReader; 23 | 24 | /** 25 | * Parses strings of digits that represent a UPC code. 26 | * 27 | * @author dswitkin@google.com (Daniel Switkin) 28 | */ 29 | public final class ProductResultParser extends ResultParser { 30 | 31 | // Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes. 32 | @Override 33 | public ProductParsedResult parse(Result result) { 34 | BarcodeFormat format = result.getBarcodeFormat(); 35 | if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E || 36 | format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) { 37 | return null; 38 | } 39 | String rawText = getMassagedText(result); 40 | if (!isStringOfDigits(rawText, rawText.length())) { 41 | return null; 42 | } 43 | // Not actually checking the checksum again here 44 | 45 | String normalizedProductID; 46 | // Expand UPC-E for purposes of searching 47 | if (format == BarcodeFormat.UPC_E && rawText.length() == 8) { 48 | normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText); 49 | } else { 50 | normalizedProductID = rawText; 51 | } 52 | 53 | return new ProductParsedResult(rawText, normalizedProductID); 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/UPCAWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.oned; 18 | 19 | import com.zhouk.zxing.BarcodeFormat; 20 | import com.zhouk.zxing.EncodeHintType; 21 | import com.zhouk.zxing.Writer; 22 | import com.zhouk.zxing.WriterException; 23 | import com.zhouk.zxing.common.BitMatrix; 24 | import com.zhouk.zxing.oned.EAN13Writer; 25 | 26 | import java.util.Map; 27 | 28 | /** 29 | * This object renders a UPC-A code as a {@link BitMatrix}. 30 | * 31 | * @author qwandor@google.com (Andrew Walbran) 32 | */ 33 | public final class UPCAWriter implements Writer { 34 | 35 | private final EAN13Writer subWriter = new EAN13Writer(); 36 | 37 | @Override 38 | public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) 39 | throws WriterException { 40 | return encode(contents, format, width, height, null); 41 | } 42 | 43 | @Override 44 | public BitMatrix encode(String contents, 45 | BarcodeFormat format, 46 | int width, 47 | int height, 48 | MapAbstract class representing the result of decoding a barcode, as more than 22 | * a String -- as some type of structured data. This might be a subclass which represents 23 | * decoded string into the most appropriate type of structured representation.
24 | * 25 | *Thanks to Jeff Griffin for proposing rewrite of these classes that relies less 26 | * on exception-based mechanisms during parsing.
27 | * 28 | * @author Sean Owen 29 | */ 30 | public abstract class ParsedResult { 31 | 32 | private final ParsedResultType type; 33 | 34 | protected ParsedResult(ParsedResultType type) { 35 | this.type = type; 36 | } 37 | 38 | public final ParsedResultType getType() { 39 | return type; 40 | } 41 | 42 | public abstract String getDisplayResult(); 43 | 44 | @Override 45 | public final String toString() { 46 | return getDisplayResult(); 47 | } 48 | 49 | public static void maybeAppend(String value, StringBuilder result) { 50 | if (value != null && !value.isEmpty()) { 51 | // Don't add a newline before the first value 52 | if (result.length() > 0) { 53 | result.append('\n'); 54 | } 55 | result.append(value); 56 | } 57 | } 58 | 59 | public static void maybeAppend(String[] values, StringBuilder result) { 60 | if (values != null) { 61 | for (String value : values) { 62 | maybeAppend(value, result); 63 | } 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/expanded/decoders/AI01weightDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.zhouk.zxing.oned.rss.expanded.decoders; 28 | 29 | 30 | import com.zhouk.zxing.common.BitArray; 31 | 32 | /** 33 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 34 | */ 35 | abstract class AI01weightDecoder extends AI01decoder { 36 | 37 | AI01weightDecoder(BitArray information) { 38 | super(information); 39 | } 40 | 41 | final void encodeCompressedWeight(StringBuilder buf, int currentPos, int weightSize) { 42 | int originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize); 43 | addWeightCode(buf, originalWeightNumeric); 44 | 45 | int weightNumeric = checkWeight(originalWeightNumeric); 46 | 47 | int currentDivisor = 100000; 48 | for (int i = 0; i < 5; ++i) { 49 | if (weightNumeric / currentDivisor == 0) { 50 | buf.append('0'); 51 | } 52 | currentDivisor /= 10; 53 | } 54 | buf.append(weightNumeric); 55 | } 56 | 57 | protected abstract void addWeightCode(StringBuilder buf, int weight); 58 | 59 | protected abstract int checkWeight(int weight); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/expanded/decoders/DecodedInformation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.zhouk.zxing.oned.rss.expanded.decoders; 28 | 29 | 30 | /** 31 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 32 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 33 | */ 34 | final class DecodedInformation extends DecodedObject { 35 | 36 | private final String newString; 37 | private final int remainingValue; 38 | private final boolean remaining; 39 | 40 | DecodedInformation(int newPosition, String newString) { 41 | super(newPosition); 42 | this.newString = newString; 43 | this.remaining = false; 44 | this.remainingValue = 0; 45 | } 46 | 47 | DecodedInformation(int newPosition, String newString, int remainingValue) { 48 | super(newPosition); 49 | this.remaining = true; 50 | this.remainingValue = remainingValue; 51 | this.newString = newString; 52 | } 53 | 54 | String getNewString() { 55 | return this.newString; 56 | } 57 | 58 | boolean isRemaining() { 59 | return this.remaining; 60 | } 61 | 62 | int getRemainingValue() { 63 | return this.remainingValue; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/pdf417/decoder/BarcodeValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.pdf417.decoder; 18 | 19 | 20 | import com.zhouk.zxing.pdf417.PDF417Common; 21 | 22 | import java.util.ArrayList; 23 | import java.util.Collection; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | import java.util.Map.Entry; 27 | 28 | /** 29 | * @author Guenther Grau 30 | */ 31 | final class BarcodeValue { 32 | private final MapEncapsulates an alignment pattern, which are the smaller square patterns found in 24 | * all but the simplest QR Codes.
25 | * 26 | * @author Sean Owen 27 | */ 28 | public final class AlignmentPattern extends ResultPoint { 29 | 30 | private final float estimatedModuleSize; 31 | 32 | AlignmentPattern(float posX, float posY, float estimatedModuleSize) { 33 | super(posX, posY); 34 | this.estimatedModuleSize = estimatedModuleSize; 35 | } 36 | 37 | /** 38 | *Determines if this alignment pattern "about equals" an alignment pattern at the stated 39 | * position and size -- meaning, it is at nearly the same center with nearly the same size.
40 | */ 41 | boolean aboutEquals(float moduleSize, float i, float j) { 42 | if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) { 43 | float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize); 44 | return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize; 45 | } 46 | return false; 47 | } 48 | 49 | /** 50 | * Combines this object's current estimate of a finder pattern position and module size 51 | * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. 52 | */ 53 | AlignmentPattern combineEstimate(float i, float j, float newModuleSize) { 54 | float combinedX = (getX() + j) / 2.0f; 55 | float combinedY = (getY() + i) / 2.0f; 56 | float combinedModuleSize = (estimatedModuleSize + newModuleSize) / 2.0f; 57 | return new AlignmentPattern(combinedX, combinedY, combinedModuleSize); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/datamatrix/encoder/TextEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2007 Jeremias Maerki. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.datamatrix.encoder; 18 | 19 | 20 | final class TextEncoder extends C40Encoder { 21 | 22 | @Override 23 | public int getEncodingMode() { 24 | return HighLevelEncoder.TEXT_ENCODATION; 25 | } 26 | 27 | @Override 28 | int encodeChar(char c, StringBuilder sb) { 29 | if (c == ' ') { 30 | sb.append('\3'); 31 | return 1; 32 | } 33 | if (c >= '0' && c <= '9') { 34 | sb.append((char) (c - 48 + 4)); 35 | return 1; 36 | } 37 | if (c >= 'a' && c <= 'z') { 38 | sb.append((char) (c - 97 + 14)); 39 | return 1; 40 | } 41 | if (c < ' ') { 42 | sb.append('\0'); //Shift 1 Set 43 | sb.append(c); 44 | return 2; 45 | } 46 | if (c <= '/') { 47 | sb.append('\1'); //Shift 2 Set 48 | sb.append((char) (c - 33)); 49 | return 2; 50 | } 51 | if (c <= '@') { 52 | sb.append('\1'); //Shift 2 Set 53 | sb.append((char) (c - 58 + 15)); 54 | return 2; 55 | } 56 | if (c >= '[' && c <= '_') { 57 | sb.append('\1'); //Shift 2 Set 58 | sb.append((char) (c - 91 + 22)); 59 | return 2; 60 | } 61 | if (c == '`') { 62 | sb.append('\2'); //Shift 3 Set 63 | sb.append((char) (c - 96)); 64 | return 2; 65 | } 66 | if (c <= 'Z') { 67 | sb.append('\2'); //Shift 3 Set 68 | sb.append((char) (c - 65 + 1)); 69 | return 2; 70 | } 71 | if (c <= 127) { 72 | sb.append('\2'); //Shift 3 Set 73 | sb.append((char) (c - 123 + 27)); 74 | return 2; 75 | } 76 | sb.append("\1\u001e"); //Shift 2, Upper Shift 77 | int len = 2; 78 | len += encodeChar((char) (c - 128), sb); 79 | return len; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/pdf417/encoder/BarcodeRow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.pdf417.encoder; 18 | 19 | /** 20 | * @author Jacob Haynes 21 | */ 22 | final class BarcodeRow { 23 | 24 | private final byte[] row; 25 | //A tacker for position in the bar 26 | private int currentLocation; 27 | 28 | /** 29 | * Creates a Barcode row of the width 30 | */ 31 | BarcodeRow(int width) { 32 | this.row = new byte[width]; 33 | currentLocation = 0; 34 | } 35 | 36 | /** 37 | * Sets a specific location in the bar 38 | * 39 | * @param x The location in the bar 40 | * @param value Black if true, white if false; 41 | */ 42 | void set(int x, byte value) { 43 | row[x] = value; 44 | } 45 | 46 | /** 47 | * Sets a specific location in the bar 48 | * 49 | * @param x The location in the bar 50 | * @param black Black if true, white if false; 51 | */ 52 | private void set(int x, boolean black) { 53 | row[x] = (byte) (black ? 1 : 0); 54 | } 55 | 56 | /** 57 | * @param black A boolean which is true if the bar black false if it is white 58 | * @param width How many spots wide the bar is. 59 | */ 60 | void addBar(boolean black, int width) { 61 | for (int ii = 0; ii < width; ii++) { 62 | set(currentLocation++, black); 63 | } 64 | } 65 | 66 | /* 67 | byte[] getRow() { 68 | return row; 69 | } 70 | */ 71 | 72 | /** 73 | * This function scales the row 74 | * 75 | * @param scale How much you want the image to be scaled, must be greater than or equal to 1. 76 | * @return the scaled row 77 | */ 78 | byte[] getScaledRow(int scale) { 79 | byte[] output = new byte[row.length * scale]; 80 | for (int i = 0; i < output.length; i++) { 81 | output[i] = row[i / scale]; 82 | } 83 | return output; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/Writer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing; 18 | 19 | import com.zhouk.zxing.BarcodeFormat; 20 | import com.zhouk.zxing.EncodeHintType; 21 | import com.zhouk.zxing.WriterException; 22 | import com.zhouk.zxing.common.BitMatrix; 23 | 24 | import java.util.Map; 25 | 26 | /** 27 | * The base class for all objects which encode/generate a barcode image. 28 | * 29 | * @author dswitkin@google.com (Daniel Switkin) 30 | */ 31 | public interface Writer { 32 | 33 | /** 34 | * Encode a barcode using the default settings. 35 | * 36 | * @param contents The contents to encode in the barcode 37 | * @param format The barcode format to generate 38 | * @param width The preferred width in pixels 39 | * @param height The preferred height in pixels 40 | * @return {@link BitMatrix} representing encoded barcode image 41 | * @throws com.zhouk.zxing.WriterException if contents cannot be encoded legally in a format 42 | */ 43 | BitMatrix encode(String contents, com.zhouk.zxing.BarcodeFormat format, int width, int height) 44 | throws com.zhouk.zxing.WriterException; 45 | 46 | /** 47 | * @param contents The contents to encode in the barcode 48 | * @param format The barcode format to generate 49 | * @param width The preferred width in pixels 50 | * @param height The preferred height in pixels 51 | * @param hints Additional parameters to supply to the encoder 52 | * @return {@link BitMatrix} representing encoded barcode image 53 | * @throws com.zhouk.zxing.WriterException if contents cannot be encoded legally in a format 54 | */ 55 | BitMatrix encode(String contents, 56 | BarcodeFormat format, 57 | int width, 58 | int height, 59 | MapImplements decoding of the EAN-8 format.
26 | * 27 | * @author Sean Owen 28 | */ 29 | public final class EAN8Reader extends UPCEANReader { 30 | 31 | private final int[] decodeMiddleCounters; 32 | 33 | public EAN8Reader() { 34 | decodeMiddleCounters = new int[4]; 35 | } 36 | 37 | @Override 38 | protected int decodeMiddle(BitArray row, 39 | int[] startRange, 40 | StringBuilder result) throws NotFoundException { 41 | int[] counters = decodeMiddleCounters; 42 | counters[0] = 0; 43 | counters[1] = 0; 44 | counters[2] = 0; 45 | counters[3] = 0; 46 | int end = row.getSize(); 47 | int rowOffset = startRange[1]; 48 | 49 | for (int x = 0; x < 4 && rowOffset < end; x++) { 50 | int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); 51 | result.append((char) ('0' + bestMatch)); 52 | for (int counter : counters) { 53 | rowOffset += counter; 54 | } 55 | } 56 | 57 | int[] middleRange = findGuardPattern(row, rowOffset, true, MIDDLE_PATTERN); 58 | rowOffset = middleRange[1]; 59 | 60 | for (int x = 0; x < 4 && rowOffset < end; x++) { 61 | int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); 62 | result.append((char) ('0' + bestMatch)); 63 | for (int counter : counters) { 64 | rowOffset += counter; 65 | } 66 | } 67 | 68 | return rowOffset; 69 | } 70 | 71 | @Override 72 | BarcodeFormat getBarcodeFormat() { 73 | return BarcodeFormat.EAN_8; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/oned/rss/expanded/decoders/AI01392xDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.zhouk.zxing.oned.rss.expanded.decoders; 28 | 29 | 30 | import com.zhouk.zxing.FormatException; 31 | import com.zhouk.zxing.NotFoundException; 32 | import com.zhouk.zxing.common.BitArray; 33 | 34 | /** 35 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 36 | */ 37 | final class AI01392xDecoder extends AI01decoder { 38 | 39 | private static final int HEADER_SIZE = 5 + 1 + 2; 40 | private static final int LAST_DIGIT_SIZE = 2; 41 | 42 | AI01392xDecoder(BitArray information) { 43 | super(information); 44 | } 45 | 46 | @Override 47 | public String parseInformation() throws NotFoundException, FormatException { 48 | if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) { 49 | throw NotFoundException.getNotFoundInstance(); 50 | } 51 | 52 | StringBuilder buf = new StringBuilder(); 53 | 54 | encodeCompressedGtin(buf, HEADER_SIZE); 55 | 56 | int lastAIdigit = 57 | this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); 58 | buf.append("(392"); 59 | buf.append(lastAIdigit); 60 | buf.append(')'); 61 | 62 | DecodedInformation decodedInformation = 63 | this.getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, null); 64 | buf.append(decodedInformation.getNewString()); 65 | 66 | return buf.toString(); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/pdf417/encoder/BarcodeMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.pdf417.encoder; 18 | 19 | 20 | /** 21 | * Holds all of the information for a barcode in a format where it can be easily accessible 22 | * 23 | * @author Jacob Haynes 24 | */ 25 | public final class BarcodeMatrix { 26 | 27 | private final BarcodeRow[] matrix; 28 | private int currentRow; 29 | private final int height; 30 | private final int width; 31 | 32 | /** 33 | * @param height the height of the matrix (Rows) 34 | * @param width the width of the matrix (Cols) 35 | */ 36 | BarcodeMatrix(int height, int width) { 37 | matrix = new BarcodeRow[height]; 38 | //Initializes the array to the correct width 39 | for (int i = 0, matrixLength = matrix.length; i < matrixLength; i++) { 40 | matrix[i] = new BarcodeRow((width + 4) * 17 + 1); 41 | } 42 | this.width = width * 17; 43 | this.height = height; 44 | this.currentRow = -1; 45 | } 46 | 47 | void set(int x, int y, byte value) { 48 | matrix[y].set(x, value); 49 | } 50 | 51 | /* 52 | void setMatrix(int x, int y, boolean black) { 53 | set(x, y, (byte) (black ? 1 : 0)); 54 | } 55 | */ 56 | 57 | void startRow() { 58 | ++currentRow; 59 | } 60 | 61 | BarcodeRow getCurrentRow() { 62 | return matrix[currentRow]; 63 | } 64 | 65 | public byte[][] getMatrix() { 66 | return getScaledMatrix(1, 1); 67 | } 68 | 69 | /* 70 | public byte[][] getScaledMatrix(int scale) { 71 | return getScaledMatrix(scale, scale); 72 | } 73 | */ 74 | 75 | public byte[][] getScaledMatrix(int xScale, int yScale) { 76 | byte[][] matrixOut = new byte[height * yScale][width * xScale]; 77 | int yMax = height * yScale; 78 | for (int i = 0; i < yMax; i++) { 79 | matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale); 80 | } 81 | return matrixOut; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/client/result/GeoResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.client.result; 18 | 19 | import com.zhouk.zxing.Result; 20 | 21 | import java.util.regex.Matcher; 22 | import java.util.regex.Pattern; 23 | 24 | /** 25 | * Parses a "geo:" URI result, which specifies a location on the surface of 26 | * the Earth as well as an optional altitude above the surface. See 27 | * 28 | * http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00. 29 | * 30 | * @author Sean Owen 31 | */ 32 | public final class GeoResultParser extends ResultParser { 33 | 34 | private static final Pattern GEO_URL_PATTERN = 35 | Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE); 36 | 37 | @Override 38 | public GeoParsedResult parse(Result result) { 39 | CharSequence rawText = getMassagedText(result); 40 | Matcher matcher = GEO_URL_PATTERN.matcher(rawText); 41 | if (!matcher.matches()) { 42 | return null; 43 | } 44 | 45 | String query = matcher.group(4); 46 | 47 | double latitude; 48 | double longitude; 49 | double altitude; 50 | try { 51 | latitude = Double.parseDouble(matcher.group(1)); 52 | if (latitude > 90.0 || latitude < -90.0) { 53 | return null; 54 | } 55 | longitude = Double.parseDouble(matcher.group(2)); 56 | if (longitude > 180.0 || longitude < -180.0) { 57 | return null; 58 | } 59 | if (matcher.group(3) == null) { 60 | altitude = 0.0; 61 | } else { 62 | altitude = Double.parseDouble(matcher.group(3)); 63 | if (altitude < 0.0) { 64 | return null; 65 | } 66 | } 67 | } catch (NumberFormatException ignored) { 68 | return null; 69 | } 70 | return new GeoParsedResult(latitude, longitude, altitude, query); 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/common/detector/MathUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.common.detector; 18 | 19 | /** 20 | * General math-related and numeric utility functions. 21 | */ 22 | public final class MathUtils { 23 | 24 | private MathUtils() { 25 | } 26 | 27 | /** 28 | * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its 29 | * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut 30 | * differ slightly from {@link Math#round(float)} in that half rounds down for negative 31 | * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference. 32 | * 33 | * @param d real value to round 34 | * @return nearest {@code int} 35 | */ 36 | public static int round(float d) { 37 | return (int) (d + (d < 0.0f ? -0.5f : 0.5f)); 38 | } 39 | 40 | /** 41 | * @param aX point A x coordinate 42 | * @param aY point A y coordinate 43 | * @param bX point B x coordinate 44 | * @param bY point B y coordinate 45 | * @return Euclidean distance between points A and B 46 | */ 47 | public static float distance(float aX, float aY, float bX, float bY) { 48 | double xDiff = aX - bX; 49 | double yDiff = aY - bY; 50 | return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); 51 | } 52 | 53 | /** 54 | * @param aX point A x coordinate 55 | * @param aY point A y coordinate 56 | * @param bX point B x coordinate 57 | * @param bY point B y coordinate 58 | * @return Euclidean distance between points A and B 59 | */ 60 | public static float distance(int aX, int aY, int bX, int bY) { 61 | double xDiff = aX - bX; 62 | double yDiff = aY - bY; 63 | return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); 64 | } 65 | 66 | /** 67 | * @param array values to sum 68 | * @return sum of values in array 69 | */ 70 | public static int sum(int[] array) { 71 | int count = 0; 72 | for (int a : array) { 73 | count += a; 74 | } 75 | return count; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /ZxingScan/src/main/java/com/zhouk/zxing/multi/qrcode/detector/MultiDetector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.zhouk.zxing.multi.qrcode.detector; 18 | 19 | import com.zhouk.zxing.DecodeHintType; 20 | import com.zhouk.zxing.NotFoundException; 21 | import com.zhouk.zxing.ReaderException; 22 | import com.zhouk.zxing.ResultPointCallback; 23 | import com.zhouk.zxing.common.BitMatrix; 24 | import com.zhouk.zxing.common.DetectorResult; 25 | import com.zhouk.zxing.multi.qrcode.detector.MultiFinderPatternFinder; 26 | import com.zhouk.zxing.qrcode.detector.Detector; 27 | import com.zhouk.zxing.qrcode.detector.FinderPatternInfo; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | import java.util.Map; 32 | 33 | /** 34 | *Encapsulates logic that can detect one or more QR Codes in an image, even if the QR Code 35 | * is rotated or skewed, or partially obscured.
36 | * 37 | * @author Sean Owen 38 | * @author Hannes Erven 39 | */ 40 | public final class MultiDetector extends Detector { 41 | 42 | private static final DetectorResult[] EMPTY_DETECTOR_RESULTS = new DetectorResult[0]; 43 | 44 | public MultiDetector(BitMatrix image) { 45 | super(image); 46 | } 47 | 48 | public DetectorResult[] detectMulti(Map