rhodes 2.4.1 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/Rakefile +7 -36
- data/doc/build.txt +48 -22
- data/doc/device-caps.txt +130 -1
- data/doc/rhom.txt +9 -3
- data/doc/test-log-debug.txt +5 -2
- data/lib/extensions/barcode/ext/barcode/platform/android/Rakefile +40 -20
- data/lib/extensions/barcode/ext/barcode/platform/android/ZXing_Info/AUTHORS +58 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/ZXing_Info/CHANGES +266 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/ZXing_Info/COPYING +201 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/ZXing_Info/README +11 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/ext_build.files +173 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/jni/src/barcode.cpp +34 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/BarcodeFormat.java +103 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/Binarizer.java +80 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/BinaryBitmap.java +128 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/ChecksumException.java +37 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/DecodeHintType.java +79 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/EncodeHintType.java +39 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/FormatException.java +38 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/LuminanceSource.java +113 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/MultiFormatReader.java +166 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/MultiFormatWriter.java +65 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/NotFoundException.java +37 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/Reader.java +64 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/ReaderException.java +98 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/Result.java +143 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/ResultMetadataType.java +109 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/ResultPoint.java +127 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/ResultPointCallback.java +29 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/Writer.java +54 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/WriterException.java +35 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/AbstractDoCoMoResultParser.java +39 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/AddressBookAUResultParser.java +73 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/AddressBookDoCoMoResultParser.java +85 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/AddressBookParsedResult.java +122 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/BizcardResultParser.java +94 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/BookmarkDoCoMoResultParser.java +46 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/CalendarParsedResult.java +134 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/EmailAddressParsedResult.java +61 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/EmailAddressResultParser.java +64 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/EmailDoCoMoResultParser.java +87 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ExpandedProductParsedResult.java +195 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ExpandedProductResultParser.java +199 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/GeoParsedResult.java +132 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/GeoResultParser.java +77 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ISBNParsedResult.java +39 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ISBNResultParser.java +54 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ParsedResult.java +73 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ParsedResultType.java +53 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ProductParsedResult.java +49 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ProductResultParser.java +66 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/ResultParser.java +319 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/SMSMMSResultParser.java +107 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/SMSParsedResult.java +104 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/SMSTOMMSTOResultParser.java +57 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/TelParsedResult.java +54 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/TelResultParser.java +44 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/TextParsedResult.java +48 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/URIParsedResult.java +113 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/URIResultParser.java +87 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/URLTOResultParser.java +47 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/VCardResultParser.java +346 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/VEventResultParser.java +54 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/WifiParsedResult.java +53 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/WifiResultParser.java +50 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/optional/AbstractNDEFResultParser.java +45 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/optional/NDEFRecord.java +87 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/optional/NDEFSmartPosterParsedResult.java +63 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/optional/NDEFSmartPosterResultParser.java +81 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/optional/NDEFTextResultParser.java +57 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/result/optional/NDEFURIResultParser.java +95 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/BitArray.java +247 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/BitMatrix.java +226 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/BitSource.java +97 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/CharacterSetECI.java +110 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/Collections.java +53 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/Comparator.java +27 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/DecoderResult.java +63 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/DefaultGridSampler.java +81 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/DetectorResult.java +46 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/ECI.java +52 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/GlobalHistogramBinarizer.java +196 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/GridSampler.java +171 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/HybridBinarizer.java +185 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/PerspectiveTransform.java +148 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/StringUtils.java +191 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/detector/MonochromeRectangleDetector.java +209 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/detector/WhiteRectangleDetector.java +316 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/reedsolomon/GF256.java +139 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/reedsolomon/GF256Poly.java +263 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java +194 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java +75 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/common/reedsolomon/ReedSolomonException.java +31 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/datamatrix/DataMatrixReader.java +161 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java +446 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/datamatrix/decoder/DataBlock.java +118 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/datamatrix/decoder/DecodedBitStreamParser.java +462 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/datamatrix/decoder/Decoder.java +134 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/datamatrix/decoder/Version.java +242 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/datamatrix/detector/Detector.java +348 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/multi/ByQuadrantReader.java +96 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/multi/GenericMultipleBarcodeReader.java +156 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/multi/MultipleBarcodeReader.java +37 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/multi/qrcode/QRCodeMultiReader.java +80 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/multi/qrcode/detector/MultiDetector.java +72 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java +324 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/CodaBarReader.java +263 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/Code128Reader.java +473 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/Code128Writer.java +73 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/Code39Reader.java +333 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/Code39Writer.java +82 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/Code93Reader.java +273 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/EAN13Reader.java +135 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/EAN13Writer.java +81 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/EAN8Reader.java +72 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/EAN8Writer.java +76 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/EANManufacturerOrgSupport.java +170 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/ITFReader.java +348 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/ITFWriter.java +68 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/MultiFormatOneDReader.java +109 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/MultiFormatUPCEANReader.java +113 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/OneDReader.java +297 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/UPCAReader.java +75 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/UPCEANExtensionSupport.java +186 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/UPCEANReader.java +355 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/UPCEANWriter.java +104 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/UPCEReader.java +153 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/AbstractRSSReader.java +110 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/DataCharacter.java +37 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/FinderPattern.java +48 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/Pair.java +41 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/RSS14Reader.java +494 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/RSSUtils.java +155 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/BitArrayBuilder.java +85 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/ExpandedPair.java +68 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java +578 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI013103decoder.java +47 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI01320xDecoder.java +55 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI01392xDecoder.java +66 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI01393xDecoder.java +76 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.java +106 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.java +56 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.java +56 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI01decoder.java +81 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AI01weightDecoder.java +58 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.java +85 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/AnyAIDecoder.java +48 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/BlockParsedResult.java +60 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/CurrentParsingState.java +69 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/DecodedChar.java +52 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/DecodedInformation.java +63 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/DecodedNumeric.java +79 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/DecodedObject.java +44 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/FieldParser.java +285 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.java +414 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/pdf417/PDF417Reader.java +79 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/pdf417/decoder/BitMatrixParser.java +1163 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java +629 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/pdf417/decoder/Decoder.java +150 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/pdf417/detector/Detector.java +498 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/QRCodeReader.java +166 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/QRCodeWriter.java +108 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/BitMatrixParser.java +203 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/DataBlock.java +123 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/DataMask.java +155 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java +261 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/Decoder.java +148 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java +86 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/FormatInformation.java +171 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/Mode.java +112 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/decoder/Version.java +586 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/detector/AlignmentPattern.java +48 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java +279 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/detector/Detector.java +400 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/detector/FinderPattern.java +63 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java +585 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/detector/FinderPatternInfo.java +49 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/encoder/BlockPair.java +37 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/encoder/ByteMatrix.java +97 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/encoder/Encoder.java +557 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/encoder/MaskUtil.java +217 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/encoder/MatrixUtil.java +524 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/qrcode/encoder/QRCode.java +239 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/rhomobile/barcode/Barcode.java +63 -0
- data/lib/extensions/barcode/ext/barcode/platform/android/src/com/rhomobile/barcode/RhoLuminanceSource.java +75 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +74 -318
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/barcode.m +70 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/COPYING +27 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarCaptureReader.h +105 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarHelpController.h +60 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarImage.h +69 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarImageScanner.h +51 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarReaderController.h +142 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarReaderView.h +118 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarReaderViewController.h +100 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarSDK.h +33 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/ZBarSymbol.h +71 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar.h +1476 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Decoder.h +201 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Exception.h +187 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Image.h +321 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/ImageScanner.h +130 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Processor.h +223 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Scanner.h +162 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Symbol.h +529 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Video.h +170 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Headers/ZBarSDK/zbar/Window.h +136 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/LICENSE +504 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/README +59 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Resources/zbar-back.png +0 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Resources/zbar-help.html +88 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Resources/zbar-helpicons.png +0 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/Resources/zbar-samples.png +0 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/ZBarSDK/libzbar.a +0 -0
- data/lib/extensions/debugger/debugger.rb +215 -67
- data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +1 -1
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/Nfc.java +14 -2
- data/lib/extensions/timeout/timeout.rb +114 -0
- data/lib/framework/rho/render.rb +14 -16
- data/lib/framework/rho/rho.rb +38 -14
- data/lib/framework/rho/rhoapplication.rb +1 -1
- data/lib/framework/rho/rhocontroller.rb +3 -3
- data/lib/framework/rho/rhofsconnector.rb +18 -6
- data/lib/framework/rho/rhoviewhelpers.rb +1 -1
- data/lib/framework/rhoappmanifest.rb +44 -0
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhoframework.rb +31 -11
- data/lib/framework/rholang/localization_simplified.rb +10 -6
- data/lib/framework/rhom/rhom_object_factory.rb +3 -3
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesApplication.h +32 -8
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +21 -21
- data/platform/android/Rhodes/jni/src/rhocryptimpl.cpp +1 -0
- data/platform/android/Rhodes/jni/src/rhodes.cpp +21 -9
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +7 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +19 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +24 -15
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +39 -47
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +113 -106
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +11 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/StatusNotification.java +49 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/socket/SSLImpl.java +5 -1
- data/platform/android/build/RhodesSRC_build.files +1 -0
- data/platform/android/build/android.rake +93 -6
- data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +5 -4
- data/platform/bb/RubyVM/src/com/rho/file/RhoFile.java +10 -0
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +16 -15
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +2 -2
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +21 -19
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter5.java +2 -2
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +6 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +10 -3
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +21 -1
- data/platform/iphone/Classes/SimpleMainView.m +5 -5
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/rbuild/iphone.rake +30 -1
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +12 -0
- data/platform/shared/SyncClient/SyncClient.cpp +136 -20
- data/platform/shared/SyncClient/SyncClient.h +17 -0
- data/platform/shared/common/AppMenu.cpp +6 -1
- data/platform/shared/common/RhoConf.cpp +13 -1
- data/platform/shared/common/RhoConf.h +3 -1
- data/platform/shared/common/RhoDefs.h +10 -0
- data/platform/shared/common/RhoFile.cpp +15 -0
- data/platform/shared/common/RhoFile.h +1 -0
- data/platform/shared/common/RhodesApp.cpp +16 -3
- data/platform/shared/common/RhodesApp.h +1 -0
- data/platform/shared/common/RhodesAppBase.cpp +102 -62
- data/platform/shared/common/RhodesAppBase.h +7 -1
- data/platform/shared/curl/lib/rhossl.c +1 -0
- data/platform/shared/db/DBAdapter.cpp +14 -2
- data/platform/shared/logging/RhoLogConf.cpp +21 -0
- data/platform/shared/logging/RhoLogConf.h +11 -0
- data/platform/shared/logging/RhoLogSink.cpp +24 -0
- data/platform/shared/logging/RhoLogSink.h +20 -1
- data/platform/shared/net/HttpServer.cpp +8 -6
- data/platform/shared/net/RawSocket.cpp +130 -0
- data/platform/shared/net/RawSocket.h +74 -0
- data/platform/shared/ruby/ext/rho/rhoruby.c +37 -1
- data/platform/shared/ruby/ext/rho/rhosupport.c +74 -21
- data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +9 -1
- data/platform/shared/ruby/vm_eval.c +4 -3
- data/platform/shared/sync/SyncEngine.cpp +11 -12
- data/platform/shared/sync/SyncEngine.h +2 -2
- data/platform/shared/sync/SyncNotify.cpp +41 -13
- data/platform/shared/sync/SyncNotify.h +20 -3
- data/platform/shared/sync/SyncSource.cpp +21 -19
- data/platform/shared/sync/SyncThread.cpp +11 -1
- data/platform/shared/sync/SyncThread.h +3 -0
- data/platform/shared/test/test_helper.cpp +7 -0
- data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
- data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
- data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
- data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
- data/platform/win32/RhoSimulator/rhosimulator.exe +0 -0
- data/platform/wm/RhoLib/RhoLib.vcproj +762 -14
- data/platform/wm/build/wm.rake +87 -10
- data/platform/wm/rhodes.sln +155 -72
- data/platform/wm/rhodes/MainWindow.cpp +5 -2
- data/platform/wm/rhodes/MainWindow.h +9 -1
- data/platform/wm/rhodes/RhoNativeViewManager.cpp +4 -0
- data/platform/wm/rhodes/Rhodes.cpp +60 -6
- data/platform/wm/rhodes/emulator/ExternalWebView.cpp +20 -0
- data/platform/wm/rhodes/emulator/ExternalWebView.h +23 -0
- data/platform/wm/rhodes/emulator/ExternalWebView.ui +46 -0
- data/platform/wm/rhodes/emulator/MainWindowCallback.h +18 -0
- data/platform/wm/rhodes/emulator/MainWindowProxy.cpp +268 -0
- data/platform/wm/rhodes/emulator/MainWindowProxy.h +34 -0
- data/platform/wm/rhodes/emulator/MainWindowQt.cpp +345 -0
- data/platform/wm/rhodes/emulator/MainWindowQt.h +118 -0
- data/platform/wm/rhodes/emulator/NativeToolbarQt.cpp +57 -0
- data/platform/wm/rhodes/emulator/NativeToolbarQt.h +52 -0
- data/platform/wm/rhodes/emulator/QtMainWindow.cpp +219 -0
- data/platform/wm/rhodes/emulator/QtMainWindow.h +62 -0
- data/platform/wm/rhodes/emulator/QtMainWindow.ui +122 -0
- data/platform/wm/rhodes/{RhoCryptImpl.cpp → rho/common/RhoCryptImpl.cpp} +0 -0
- data/platform/wm/rhodes/{RhoCryptImpl.h → rho/common/RhoCryptImpl.h} +0 -0
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +2 -86
- data/platform/wm/rhodes/rho/rubyext/NativeToolbarExt.cpp +87 -0
- data/platform/wm/rhodes/rho/rubyext/NativeToolbarExt.h +6 -0
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +60 -0
- data/platform/wm/rhodes/rhodes.vcproj +4025 -365
- data/platform/wm/rhodes/signature/Signature.cpp +29 -13
- data/platform/wm/rubylib/rubylib.vcproj +1167 -195
- data/platform/wm/shttpd/shttpd.vcproj +4 -4
- data/platform/wm/sqlite3/sqlite3.vcproj +441 -13
- data/platform/wm/syncengine/syncengine.vcproj +443 -15
- data/platform/wm/tcmalloc/tcmalloc.vcproj +0 -154
- data/platform/wm/tools/detool/LogServer.cpp +150 -0
- data/platform/wm/tools/detool/LogServer.h +23 -0
- data/platform/wm/tools/detool/detool.cpp +42 -4
- data/platform/wm/tools/detool/detool.vcproj +10 -1
- data/platform/wp7/IronRuby/Bin/Silverlight3Release/IronRuby.Libraries.dll +0 -0
- data/platform/wp7/IronRuby/Bin/Silverlight3Release/IronRuby.dll +0 -0
- data/platform/wp7/IronRuby/Bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
- data/platform/wp7/IronRuby/Bin/Silverlight3Release/Microsoft.Scripting.Core.dll +0 -0
- data/platform/wp7/IronRuby/Bin/Silverlight3Release/Microsoft.Scripting.dll +0 -0
- data/platform/wp7/RhoAppRunner/Program.cs +20 -3
- data/platform/wp7/RhoLogServer/Program.cs +22 -0
- data/platform/wp7/RhoLogServer/Properties/AssemblyInfo.cs +36 -0
- data/platform/wp7/RhoLogServer/RhoLogServer.csproj +65 -0
- data/platform/wp7/RhoLogServer/SocketServer.cs +210 -0
- data/platform/wp7/RhoRubyExtGen/RhoAsyncHttp.cs +6 -0
- data/platform/wp7/RhoRubyLib/Initializers.Generated.cs +3 -2
- data/platform/wp7/RhoRubyLib/RhoRuby.cs +82 -0
- data/platform/wp7/RhoRubyLib/RhoRubyLib.csproj +7 -5
- data/platform/wp7/RhoRubyLib/WP_PlatformAdaptationLayer.cs +1 -1
- data/platform/wp7/RhoRubyLib/common/RhoParams.cs +1 -1
- data/platform/wp7/RhoRubyLib/common/ThreadQueue.cs +4 -1
- data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +2 -2
- data/platform/wp7/RhoRubyLib/logging/IRhoLogSink.cs +1 -1
- data/platform/wp7/RhoRubyLib/logging/RhoEmptyLogger.cs +30 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogConf.cs +10 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogFileSink.cs +6 -1
- data/platform/wp7/RhoRubyLib/logging/RhoLogServerSink.cs +56 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +24 -11
- data/platform/wp7/RhoRubyLib/net/AsyncHttp.cs +57 -14
- data/platform/wp7/RhoRubyLib/net/NetRequest.cs +32 -9
- data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +7 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +6 -0
- data/platform/wp7/RhoRubyLib/sync/SyncEngine.cs +20 -16
- data/platform/wp7/RhoRubyLib/sync/SyncNotify.cs +2 -2
- data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +138 -40
- data/platform/wp7/WPApplication/rho/apps/app/layout.erb +3 -1
- data/platform/wp7/build/wp.rake +151 -12
- data/platform/wp7/rhodes.sln +10 -0
- data/platform/wp7/rhodes/App.xaml.cs +6 -0
- data/platform/wp7/rhodes/MainPage.xaml +3 -0
- data/platform/wp7/rhodes/MainPage.xaml.cs +19 -0
- data/platform/wp7/rhodes/Rhodes.csproj +4 -2
- data/rakefile.rb +7 -36
- data/res/build-tools/RhoAppRunner.exe +0 -0
- data/res/build-tools/RhoLogServer.exe +0 -0
- data/res/build-tools/detool.exe +0 -0
- data/res/build-tools/wp7explorer.exe +0 -0
- data/res/generators/templates/application/app/layout.erb +3 -1
- data/res/generators/templates/application/public/jqtouch/jqtouch.js +1 -1
- data/rhodes.gemspec +1 -1
- data/spec/framework_spec/app/layout.erb +1 -1
- data/spec/framework_spec/build.yml +1 -0
- data/spec/perfomance_spec/app/layout.erb +3 -0
- data/spec/phone_spec/app/Account_s/account_s.rb +4 -1
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +30 -1
- data/spec/phone_spec/app/spec_runner.rb +1 -1
- data/spec/phone_spec/build.yml +4 -1
- metadata +262 -10
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Builtins/ConsoleStream.cs +0 -107
@@ -0,0 +1,217 @@
|
|
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.google.zxing.qrcode.encoder;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* @author satorux@google.com (Satoru Takabayashi) - creator
|
21
|
+
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
|
22
|
+
*/
|
23
|
+
public final class MaskUtil {
|
24
|
+
|
25
|
+
private MaskUtil() {
|
26
|
+
// do nothing
|
27
|
+
}
|
28
|
+
|
29
|
+
// Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
|
30
|
+
// give penalty to them. Example: 00000 or 11111.
|
31
|
+
public static int applyMaskPenaltyRule1(ByteMatrix matrix) {
|
32
|
+
return applyMaskPenaltyRule1Internal(matrix, true) + applyMaskPenaltyRule1Internal(matrix, false);
|
33
|
+
}
|
34
|
+
|
35
|
+
// Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
|
36
|
+
// penalty to them.
|
37
|
+
public static int applyMaskPenaltyRule2(ByteMatrix matrix) {
|
38
|
+
int penalty = 0;
|
39
|
+
byte[][] array = matrix.getArray();
|
40
|
+
int width = matrix.getWidth();
|
41
|
+
int height = matrix.getHeight();
|
42
|
+
for (int y = 0; y < height - 1; ++y) {
|
43
|
+
for (int x = 0; x < width - 1; ++x) {
|
44
|
+
int value = array[y][x];
|
45
|
+
if (value == array[y][x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) {
|
46
|
+
penalty += 3;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
return penalty;
|
51
|
+
}
|
52
|
+
|
53
|
+
// Apply mask penalty rule 3 and return the penalty. Find consecutive cells of 00001011101 or
|
54
|
+
// 10111010000, and give penalty to them. If we find patterns like 000010111010000, we give
|
55
|
+
// penalties twice (i.e. 40 * 2).
|
56
|
+
public static int applyMaskPenaltyRule3(ByteMatrix matrix) {
|
57
|
+
int penalty = 0;
|
58
|
+
byte[][] array = matrix.getArray();
|
59
|
+
int width = matrix.getWidth();
|
60
|
+
int height = matrix.getHeight();
|
61
|
+
for (int y = 0; y < height; ++y) {
|
62
|
+
for (int x = 0; x < width; ++x) {
|
63
|
+
// Tried to simplify following conditions but failed.
|
64
|
+
if (x + 6 < width &&
|
65
|
+
array[y][x] == 1 &&
|
66
|
+
array[y][x + 1] == 0 &&
|
67
|
+
array[y][x + 2] == 1 &&
|
68
|
+
array[y][x + 3] == 1 &&
|
69
|
+
array[y][x + 4] == 1 &&
|
70
|
+
array[y][x + 5] == 0 &&
|
71
|
+
array[y][x + 6] == 1 &&
|
72
|
+
((x + 10 < width &&
|
73
|
+
array[y][x + 7] == 0 &&
|
74
|
+
array[y][x + 8] == 0 &&
|
75
|
+
array[y][x + 9] == 0 &&
|
76
|
+
array[y][x + 10] == 0) ||
|
77
|
+
(x - 4 >= 0 &&
|
78
|
+
array[y][x - 1] == 0 &&
|
79
|
+
array[y][x - 2] == 0 &&
|
80
|
+
array[y][x - 3] == 0 &&
|
81
|
+
array[y][x - 4] == 0))) {
|
82
|
+
penalty += 40;
|
83
|
+
}
|
84
|
+
if (y + 6 < height &&
|
85
|
+
array[y][x] == 1 &&
|
86
|
+
array[y + 1][x] == 0 &&
|
87
|
+
array[y + 2][x] == 1 &&
|
88
|
+
array[y + 3][x] == 1 &&
|
89
|
+
array[y + 4][x] == 1 &&
|
90
|
+
array[y + 5][x] == 0 &&
|
91
|
+
array[y + 6][x] == 1 &&
|
92
|
+
((y + 10 < height &&
|
93
|
+
array[y + 7][x] == 0 &&
|
94
|
+
array[y + 8][x] == 0 &&
|
95
|
+
array[y + 9][x] == 0 &&
|
96
|
+
array[y + 10][x] == 0) ||
|
97
|
+
(y - 4 >= 0 &&
|
98
|
+
array[y - 1][x] == 0 &&
|
99
|
+
array[y - 2][x] == 0 &&
|
100
|
+
array[y - 3][x] == 0 &&
|
101
|
+
array[y - 4][x] == 0))) {
|
102
|
+
penalty += 40;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
return penalty;
|
107
|
+
}
|
108
|
+
|
109
|
+
// Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
|
110
|
+
// penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance. Examples:
|
111
|
+
// - 0% => 100
|
112
|
+
// - 40% => 20
|
113
|
+
// - 45% => 10
|
114
|
+
// - 50% => 0
|
115
|
+
// - 55% => 10
|
116
|
+
// - 55% => 20
|
117
|
+
// - 100% => 100
|
118
|
+
public static int applyMaskPenaltyRule4(ByteMatrix matrix) {
|
119
|
+
int numDarkCells = 0;
|
120
|
+
byte[][] array = matrix.getArray();
|
121
|
+
int width = matrix.getWidth();
|
122
|
+
int height = matrix.getHeight();
|
123
|
+
for (int y = 0; y < height; ++y) {
|
124
|
+
for (int x = 0; x < width; ++x) {
|
125
|
+
if (array[y][x] == 1) {
|
126
|
+
numDarkCells += 1;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
int numTotalCells = matrix.getHeight() * matrix.getWidth();
|
131
|
+
double darkRatio = (double) numDarkCells / numTotalCells;
|
132
|
+
return Math.abs((int) (darkRatio * 100 - 50)) / 5 * 10;
|
133
|
+
}
|
134
|
+
|
135
|
+
// Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask
|
136
|
+
// pattern conditions.
|
137
|
+
public static boolean getDataMaskBit(int maskPattern, int x, int y) {
|
138
|
+
if (!QRCode.isValidMaskPattern(maskPattern)) {
|
139
|
+
throw new IllegalArgumentException("Invalid mask pattern");
|
140
|
+
}
|
141
|
+
int intermediate, temp;
|
142
|
+
switch (maskPattern) {
|
143
|
+
case 0:
|
144
|
+
intermediate = (y + x) & 0x1;
|
145
|
+
break;
|
146
|
+
case 1:
|
147
|
+
intermediate = y & 0x1;
|
148
|
+
break;
|
149
|
+
case 2:
|
150
|
+
intermediate = x % 3;
|
151
|
+
break;
|
152
|
+
case 3:
|
153
|
+
intermediate = (y + x) % 3;
|
154
|
+
break;
|
155
|
+
case 4:
|
156
|
+
intermediate = ((y >>> 1) + (x / 3)) & 0x1;
|
157
|
+
break;
|
158
|
+
case 5:
|
159
|
+
temp = y * x;
|
160
|
+
intermediate = (temp & 0x1) + (temp % 3);
|
161
|
+
break;
|
162
|
+
case 6:
|
163
|
+
temp = y * x;
|
164
|
+
intermediate = (((temp & 0x1) + (temp % 3)) & 0x1);
|
165
|
+
break;
|
166
|
+
case 7:
|
167
|
+
temp = y * x;
|
168
|
+
intermediate = (((temp % 3) + ((y + x) & 0x1)) & 0x1);
|
169
|
+
break;
|
170
|
+
default:
|
171
|
+
throw new IllegalArgumentException("Invalid mask pattern: " + maskPattern);
|
172
|
+
}
|
173
|
+
return intermediate == 0;
|
174
|
+
}
|
175
|
+
|
176
|
+
// Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both
|
177
|
+
// vertical and horizontal orders respectively.
|
178
|
+
private static int applyMaskPenaltyRule1Internal(ByteMatrix matrix, boolean isHorizontal) {
|
179
|
+
int penalty = 0;
|
180
|
+
int numSameBitCells = 0;
|
181
|
+
int prevBit = -1;
|
182
|
+
// Horizontal mode:
|
183
|
+
// for (int i = 0; i < matrix.height(); ++i) {
|
184
|
+
// for (int j = 0; j < matrix.width(); ++j) {
|
185
|
+
// int bit = matrix.get(i, j);
|
186
|
+
// Vertical mode:
|
187
|
+
// for (int i = 0; i < matrix.width(); ++i) {
|
188
|
+
// for (int j = 0; j < matrix.height(); ++j) {
|
189
|
+
// int bit = matrix.get(j, i);
|
190
|
+
int iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth();
|
191
|
+
int jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight();
|
192
|
+
byte[][] array = matrix.getArray();
|
193
|
+
for (int i = 0; i < iLimit; ++i) {
|
194
|
+
for (int j = 0; j < jLimit; ++j) {
|
195
|
+
int bit = isHorizontal ? array[i][j] : array[j][i];
|
196
|
+
if (bit == prevBit) {
|
197
|
+
numSameBitCells += 1;
|
198
|
+
// Found five repetitive cells with the same color (bit).
|
199
|
+
// We'll give penalty of 3.
|
200
|
+
if (numSameBitCells == 5) {
|
201
|
+
penalty += 3;
|
202
|
+
} else if (numSameBitCells > 5) {
|
203
|
+
// After five repetitive cells, we'll add the penalty one
|
204
|
+
// by one.
|
205
|
+
penalty += 1;
|
206
|
+
}
|
207
|
+
} else {
|
208
|
+
numSameBitCells = 1; // Include the cell itself.
|
209
|
+
prevBit = bit;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
numSameBitCells = 0; // Clear at each row/column.
|
213
|
+
}
|
214
|
+
return penalty;
|
215
|
+
}
|
216
|
+
|
217
|
+
}
|
@@ -0,0 +1,524 @@
|
|
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.google.zxing.qrcode.encoder;
|
18
|
+
|
19
|
+
import com.google.zxing.WriterException;
|
20
|
+
import com.google.zxing.common.BitArray;
|
21
|
+
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @author satorux@google.com (Satoru Takabayashi) - creator
|
25
|
+
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
|
26
|
+
*/
|
27
|
+
public final class MatrixUtil {
|
28
|
+
|
29
|
+
private MatrixUtil() {
|
30
|
+
// do nothing
|
31
|
+
}
|
32
|
+
|
33
|
+
private static final int[][] POSITION_DETECTION_PATTERN = {
|
34
|
+
{1, 1, 1, 1, 1, 1, 1},
|
35
|
+
{1, 0, 0, 0, 0, 0, 1},
|
36
|
+
{1, 0, 1, 1, 1, 0, 1},
|
37
|
+
{1, 0, 1, 1, 1, 0, 1},
|
38
|
+
{1, 0, 1, 1, 1, 0, 1},
|
39
|
+
{1, 0, 0, 0, 0, 0, 1},
|
40
|
+
{1, 1, 1, 1, 1, 1, 1},
|
41
|
+
};
|
42
|
+
|
43
|
+
private static final int[][] HORIZONTAL_SEPARATION_PATTERN = {
|
44
|
+
{0, 0, 0, 0, 0, 0, 0, 0},
|
45
|
+
};
|
46
|
+
|
47
|
+
private static final int[][] VERTICAL_SEPARATION_PATTERN = {
|
48
|
+
{0}, {0}, {0}, {0}, {0}, {0}, {0},
|
49
|
+
};
|
50
|
+
|
51
|
+
private static final int[][] POSITION_ADJUSTMENT_PATTERN = {
|
52
|
+
{1, 1, 1, 1, 1},
|
53
|
+
{1, 0, 0, 0, 1},
|
54
|
+
{1, 0, 1, 0, 1},
|
55
|
+
{1, 0, 0, 0, 1},
|
56
|
+
{1, 1, 1, 1, 1},
|
57
|
+
};
|
58
|
+
|
59
|
+
// From Appendix E. Table 1, JIS0510X:2004 (p 71). The table was double-checked by komatsu.
|
60
|
+
private static final int[][] POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = {
|
61
|
+
{-1, -1, -1, -1, -1, -1, -1}, // Version 1
|
62
|
+
{ 6, 18, -1, -1, -1, -1, -1}, // Version 2
|
63
|
+
{ 6, 22, -1, -1, -1, -1, -1}, // Version 3
|
64
|
+
{ 6, 26, -1, -1, -1, -1, -1}, // Version 4
|
65
|
+
{ 6, 30, -1, -1, -1, -1, -1}, // Version 5
|
66
|
+
{ 6, 34, -1, -1, -1, -1, -1}, // Version 6
|
67
|
+
{ 6, 22, 38, -1, -1, -1, -1}, // Version 7
|
68
|
+
{ 6, 24, 42, -1, -1, -1, -1}, // Version 8
|
69
|
+
{ 6, 26, 46, -1, -1, -1, -1}, // Version 9
|
70
|
+
{ 6, 28, 50, -1, -1, -1, -1}, // Version 10
|
71
|
+
{ 6, 30, 54, -1, -1, -1, -1}, // Version 11
|
72
|
+
{ 6, 32, 58, -1, -1, -1, -1}, // Version 12
|
73
|
+
{ 6, 34, 62, -1, -1, -1, -1}, // Version 13
|
74
|
+
{ 6, 26, 46, 66, -1, -1, -1}, // Version 14
|
75
|
+
{ 6, 26, 48, 70, -1, -1, -1}, // Version 15
|
76
|
+
{ 6, 26, 50, 74, -1, -1, -1}, // Version 16
|
77
|
+
{ 6, 30, 54, 78, -1, -1, -1}, // Version 17
|
78
|
+
{ 6, 30, 56, 82, -1, -1, -1}, // Version 18
|
79
|
+
{ 6, 30, 58, 86, -1, -1, -1}, // Version 19
|
80
|
+
{ 6, 34, 62, 90, -1, -1, -1}, // Version 20
|
81
|
+
{ 6, 28, 50, 72, 94, -1, -1}, // Version 21
|
82
|
+
{ 6, 26, 50, 74, 98, -1, -1}, // Version 22
|
83
|
+
{ 6, 30, 54, 78, 102, -1, -1}, // Version 23
|
84
|
+
{ 6, 28, 54, 80, 106, -1, -1}, // Version 24
|
85
|
+
{ 6, 32, 58, 84, 110, -1, -1}, // Version 25
|
86
|
+
{ 6, 30, 58, 86, 114, -1, -1}, // Version 26
|
87
|
+
{ 6, 34, 62, 90, 118, -1, -1}, // Version 27
|
88
|
+
{ 6, 26, 50, 74, 98, 122, -1}, // Version 28
|
89
|
+
{ 6, 30, 54, 78, 102, 126, -1}, // Version 29
|
90
|
+
{ 6, 26, 52, 78, 104, 130, -1}, // Version 30
|
91
|
+
{ 6, 30, 56, 82, 108, 134, -1}, // Version 31
|
92
|
+
{ 6, 34, 60, 86, 112, 138, -1}, // Version 32
|
93
|
+
{ 6, 30, 58, 86, 114, 142, -1}, // Version 33
|
94
|
+
{ 6, 34, 62, 90, 118, 146, -1}, // Version 34
|
95
|
+
{ 6, 30, 54, 78, 102, 126, 150}, // Version 35
|
96
|
+
{ 6, 24, 50, 76, 102, 128, 154}, // Version 36
|
97
|
+
{ 6, 28, 54, 80, 106, 132, 158}, // Version 37
|
98
|
+
{ 6, 32, 58, 84, 110, 136, 162}, // Version 38
|
99
|
+
{ 6, 26, 54, 82, 110, 138, 166}, // Version 39
|
100
|
+
{ 6, 30, 58, 86, 114, 142, 170}, // Version 40
|
101
|
+
};
|
102
|
+
|
103
|
+
// Type info cells at the left top corner.
|
104
|
+
private static final int[][] TYPE_INFO_COORDINATES = {
|
105
|
+
{8, 0},
|
106
|
+
{8, 1},
|
107
|
+
{8, 2},
|
108
|
+
{8, 3},
|
109
|
+
{8, 4},
|
110
|
+
{8, 5},
|
111
|
+
{8, 7},
|
112
|
+
{8, 8},
|
113
|
+
{7, 8},
|
114
|
+
{5, 8},
|
115
|
+
{4, 8},
|
116
|
+
{3, 8},
|
117
|
+
{2, 8},
|
118
|
+
{1, 8},
|
119
|
+
{0, 8},
|
120
|
+
};
|
121
|
+
|
122
|
+
// From Appendix D in JISX0510:2004 (p. 67)
|
123
|
+
private static final int VERSION_INFO_POLY = 0x1f25; // 1 1111 0010 0101
|
124
|
+
|
125
|
+
// From Appendix C in JISX0510:2004 (p.65).
|
126
|
+
private static final int TYPE_INFO_POLY = 0x537;
|
127
|
+
private static final int TYPE_INFO_MASK_PATTERN = 0x5412;
|
128
|
+
|
129
|
+
// Set all cells to -1. -1 means that the cell is empty (not set yet).
|
130
|
+
//
|
131
|
+
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
|
132
|
+
// with the ByteMatrix initialized all to zero.
|
133
|
+
public static void clearMatrix(ByteMatrix matrix) {
|
134
|
+
matrix.clear((byte) -1);
|
135
|
+
}
|
136
|
+
|
137
|
+
// Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On
|
138
|
+
// success, store the result in "matrix" and return true.
|
139
|
+
public static void buildMatrix(BitArray dataBits, ErrorCorrectionLevel ecLevel, int version,
|
140
|
+
int maskPattern, ByteMatrix matrix) throws WriterException {
|
141
|
+
clearMatrix(matrix);
|
142
|
+
embedBasicPatterns(version, matrix);
|
143
|
+
// Type information appear with any version.
|
144
|
+
embedTypeInfo(ecLevel, maskPattern, matrix);
|
145
|
+
// Version info appear if version >= 7.
|
146
|
+
maybeEmbedVersionInfo(version, matrix);
|
147
|
+
// Data should be embedded at end.
|
148
|
+
embedDataBits(dataBits, maskPattern, matrix);
|
149
|
+
}
|
150
|
+
|
151
|
+
// Embed basic patterns. On success, modify the matrix and return true.
|
152
|
+
// The basic patterns are:
|
153
|
+
// - Position detection patterns
|
154
|
+
// - Timing patterns
|
155
|
+
// - Dark dot at the left bottom corner
|
156
|
+
// - Position adjustment patterns, if need be
|
157
|
+
public static void embedBasicPatterns(int version, ByteMatrix matrix) throws WriterException {
|
158
|
+
// Let's get started with embedding big squares at corners.
|
159
|
+
embedPositionDetectionPatternsAndSeparators(matrix);
|
160
|
+
// Then, embed the dark dot at the left bottom corner.
|
161
|
+
embedDarkDotAtLeftBottomCorner(matrix);
|
162
|
+
|
163
|
+
// Position adjustment patterns appear if version >= 2.
|
164
|
+
maybeEmbedPositionAdjustmentPatterns(version, matrix);
|
165
|
+
// Timing patterns should be embedded after position adj. patterns.
|
166
|
+
embedTimingPatterns(matrix);
|
167
|
+
}
|
168
|
+
|
169
|
+
// Embed type information. On success, modify the matrix.
|
170
|
+
public static void embedTypeInfo(ErrorCorrectionLevel ecLevel, int maskPattern, ByteMatrix matrix)
|
171
|
+
throws WriterException {
|
172
|
+
BitArray typeInfoBits = new BitArray();
|
173
|
+
makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits);
|
174
|
+
|
175
|
+
for (int i = 0; i < typeInfoBits.getSize(); ++i) {
|
176
|
+
// Place bits in LSB to MSB order. LSB (least significant bit) is the last value in
|
177
|
+
// "typeInfoBits".
|
178
|
+
boolean bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i);
|
179
|
+
|
180
|
+
// Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46).
|
181
|
+
int x1 = TYPE_INFO_COORDINATES[i][0];
|
182
|
+
int y1 = TYPE_INFO_COORDINATES[i][1];
|
183
|
+
matrix.set(x1, y1, bit);
|
184
|
+
|
185
|
+
if (i < 8) {
|
186
|
+
// Right top corner.
|
187
|
+
int x2 = matrix.getWidth() - i - 1;
|
188
|
+
int y2 = 8;
|
189
|
+
matrix.set(x2, y2, bit);
|
190
|
+
} else {
|
191
|
+
// Left bottom corner.
|
192
|
+
int x2 = 8;
|
193
|
+
int y2 = matrix.getHeight() - 7 + (i - 8);
|
194
|
+
matrix.set(x2, y2, bit);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
// Embed version information if need be. On success, modify the matrix and return true.
|
200
|
+
// See 8.10 of JISX0510:2004 (p.47) for how to embed version information.
|
201
|
+
public static void maybeEmbedVersionInfo(int version, ByteMatrix matrix) throws WriterException {
|
202
|
+
if (version < 7) { // Version info is necessary if version >= 7.
|
203
|
+
return; // Don't need version info.
|
204
|
+
}
|
205
|
+
BitArray versionInfoBits = new BitArray();
|
206
|
+
makeVersionInfoBits(version, versionInfoBits);
|
207
|
+
|
208
|
+
int bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0.
|
209
|
+
for (int i = 0; i < 6; ++i) {
|
210
|
+
for (int j = 0; j < 3; ++j) {
|
211
|
+
// Place bits in LSB (least significant bit) to MSB order.
|
212
|
+
boolean bit = versionInfoBits.get(bitIndex);
|
213
|
+
bitIndex--;
|
214
|
+
// Left bottom corner.
|
215
|
+
matrix.set(i, matrix.getHeight() - 11 + j, bit);
|
216
|
+
// Right bottom corner.
|
217
|
+
matrix.set(matrix.getHeight() - 11 + j, i, bit);
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
// Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true.
|
223
|
+
// For debugging purposes, it skips masking process if "getMaskPattern" is -1.
|
224
|
+
// See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.
|
225
|
+
public static void embedDataBits(BitArray dataBits, int maskPattern, ByteMatrix matrix)
|
226
|
+
throws WriterException {
|
227
|
+
int bitIndex = 0;
|
228
|
+
int direction = -1;
|
229
|
+
// Start from the right bottom cell.
|
230
|
+
int x = matrix.getWidth() - 1;
|
231
|
+
int y = matrix.getHeight() - 1;
|
232
|
+
while (x > 0) {
|
233
|
+
// Skip the vertical timing pattern.
|
234
|
+
if (x == 6) {
|
235
|
+
x -= 1;
|
236
|
+
}
|
237
|
+
while (y >= 0 && y < matrix.getHeight()) {
|
238
|
+
for (int i = 0; i < 2; ++i) {
|
239
|
+
int xx = x - i;
|
240
|
+
// Skip the cell if it's not empty.
|
241
|
+
if (!isEmpty(matrix.get(xx, y))) {
|
242
|
+
continue;
|
243
|
+
}
|
244
|
+
boolean bit;
|
245
|
+
if (bitIndex < dataBits.getSize()) {
|
246
|
+
bit = dataBits.get(bitIndex);
|
247
|
+
++bitIndex;
|
248
|
+
} else {
|
249
|
+
// Padding bit. If there is no bit left, we'll fill the left cells with 0, as described
|
250
|
+
// in 8.4.9 of JISX0510:2004 (p. 24).
|
251
|
+
bit = false;
|
252
|
+
}
|
253
|
+
|
254
|
+
// Skip masking if mask_pattern is -1.
|
255
|
+
if (maskPattern != -1) {
|
256
|
+
if (MaskUtil.getDataMaskBit(maskPattern, xx, y)) {
|
257
|
+
bit = !bit;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
matrix.set(xx, y, bit);
|
261
|
+
}
|
262
|
+
y += direction;
|
263
|
+
}
|
264
|
+
direction = -direction; // Reverse the direction.
|
265
|
+
y += direction;
|
266
|
+
x -= 2; // Move to the left.
|
267
|
+
}
|
268
|
+
// All bits should be consumed.
|
269
|
+
if (bitIndex != dataBits.getSize()) {
|
270
|
+
throw new WriterException("Not all bits consumed: " + bitIndex + '/' + dataBits.getSize());
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
// Return the position of the most significant bit set (to one) in the "value". The most
|
275
|
+
// significant bit is position 32. If there is no bit set, return 0. Examples:
|
276
|
+
// - findMSBSet(0) => 0
|
277
|
+
// - findMSBSet(1) => 1
|
278
|
+
// - findMSBSet(255) => 8
|
279
|
+
public static int findMSBSet(int value) {
|
280
|
+
int numDigits = 0;
|
281
|
+
while (value != 0) {
|
282
|
+
value >>>= 1;
|
283
|
+
++numDigits;
|
284
|
+
}
|
285
|
+
return numDigits;
|
286
|
+
}
|
287
|
+
|
288
|
+
// Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH
|
289
|
+
// code is used for encoding type information and version information.
|
290
|
+
// Example: Calculation of version information of 7.
|
291
|
+
// f(x) is created from 7.
|
292
|
+
// - 7 = 000111 in 6 bits
|
293
|
+
// - f(x) = x^2 + x^1 + x^0
|
294
|
+
// g(x) is given by the standard (p. 67)
|
295
|
+
// - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1
|
296
|
+
// Multiply f(x) by x^(18 - 6)
|
297
|
+
// - f'(x) = f(x) * x^(18 - 6)
|
298
|
+
// - f'(x) = x^14 + x^13 + x^12
|
299
|
+
// Calculate the remainder of f'(x) / g(x)
|
300
|
+
// x^2
|
301
|
+
// __________________________________________________
|
302
|
+
// g(x) )x^14 + x^13 + x^12
|
303
|
+
// x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2
|
304
|
+
// --------------------------------------------------
|
305
|
+
// x^11 + x^10 + x^7 + x^4 + x^2
|
306
|
+
//
|
307
|
+
// The remainder is x^11 + x^10 + x^7 + x^4 + x^2
|
308
|
+
// Encode it in binary: 110010010100
|
309
|
+
// The return value is 0xc94 (1100 1001 0100)
|
310
|
+
//
|
311
|
+
// Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit
|
312
|
+
// operations. We don't care if cofficients are positive or negative.
|
313
|
+
public static int calculateBCHCode(int value, int poly) {
|
314
|
+
// If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1
|
315
|
+
// from 13 to make it 12.
|
316
|
+
int msbSetInPoly = findMSBSet(poly);
|
317
|
+
value <<= msbSetInPoly - 1;
|
318
|
+
// Do the division business using exclusive-or operations.
|
319
|
+
while (findMSBSet(value) >= msbSetInPoly) {
|
320
|
+
value ^= poly << (findMSBSet(value) - msbSetInPoly);
|
321
|
+
}
|
322
|
+
// Now the "value" is the remainder (i.e. the BCH code)
|
323
|
+
return value;
|
324
|
+
}
|
325
|
+
|
326
|
+
// Make bit vector of type information. On success, store the result in "bits" and return true.
|
327
|
+
// Encode error correction level and mask pattern. See 8.9 of
|
328
|
+
// JISX0510:2004 (p.45) for details.
|
329
|
+
public static void makeTypeInfoBits(ErrorCorrectionLevel ecLevel, int maskPattern, BitArray bits)
|
330
|
+
throws WriterException {
|
331
|
+
if (!QRCode.isValidMaskPattern(maskPattern)) {
|
332
|
+
throw new WriterException("Invalid mask pattern");
|
333
|
+
}
|
334
|
+
int typeInfo = (ecLevel.getBits() << 3) | maskPattern;
|
335
|
+
bits.appendBits(typeInfo, 5);
|
336
|
+
|
337
|
+
int bchCode = calculateBCHCode(typeInfo, TYPE_INFO_POLY);
|
338
|
+
bits.appendBits(bchCode, 10);
|
339
|
+
|
340
|
+
BitArray maskBits = new BitArray();
|
341
|
+
maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15);
|
342
|
+
bits.xor(maskBits);
|
343
|
+
|
344
|
+
if (bits.getSize() != 15) { // Just in case.
|
345
|
+
throw new WriterException("should not happen but we got: " + bits.getSize());
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
// Make bit vector of version information. On success, store the result in "bits" and return true.
|
350
|
+
// See 8.10 of JISX0510:2004 (p.45) for details.
|
351
|
+
public static void makeVersionInfoBits(int version, BitArray bits) throws WriterException {
|
352
|
+
bits.appendBits(version, 6);
|
353
|
+
int bchCode = calculateBCHCode(version, VERSION_INFO_POLY);
|
354
|
+
bits.appendBits(bchCode, 12);
|
355
|
+
|
356
|
+
if (bits.getSize() != 18) { // Just in case.
|
357
|
+
throw new WriterException("should not happen but we got: " + bits.getSize());
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
// Check if "value" is empty.
|
362
|
+
private static boolean isEmpty(int value) {
|
363
|
+
return value == -1;
|
364
|
+
}
|
365
|
+
|
366
|
+
// Check if "value" is valid.
|
367
|
+
private static boolean isValidValue(int value) {
|
368
|
+
return (value == -1 || // Empty.
|
369
|
+
value == 0 || // Light (white).
|
370
|
+
value == 1); // Dark (black).
|
371
|
+
}
|
372
|
+
|
373
|
+
private static void embedTimingPatterns(ByteMatrix matrix) throws WriterException {
|
374
|
+
// -8 is for skipping position detection patterns (size 7), and two horizontal/vertical
|
375
|
+
// separation patterns (size 1). Thus, 8 = 7 + 1.
|
376
|
+
for (int i = 8; i < matrix.getWidth() - 8; ++i) {
|
377
|
+
int bit = (i + 1) % 2;
|
378
|
+
// Horizontal line.
|
379
|
+
if (!isValidValue(matrix.get(i, 6))) {
|
380
|
+
throw new WriterException();
|
381
|
+
}
|
382
|
+
if (isEmpty(matrix.get(i, 6))) {
|
383
|
+
matrix.set(i, 6, bit);
|
384
|
+
}
|
385
|
+
// Vertical line.
|
386
|
+
if (!isValidValue(matrix.get(6, i))) {
|
387
|
+
throw new WriterException();
|
388
|
+
}
|
389
|
+
if (isEmpty(matrix.get(6, i))) {
|
390
|
+
matrix.set(6, i, bit);
|
391
|
+
}
|
392
|
+
}
|
393
|
+
}
|
394
|
+
|
395
|
+
// Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46)
|
396
|
+
private static void embedDarkDotAtLeftBottomCorner(ByteMatrix matrix) throws WriterException {
|
397
|
+
if (matrix.get(8, matrix.getHeight() - 8) == 0) {
|
398
|
+
throw new WriterException();
|
399
|
+
}
|
400
|
+
matrix.set(8, matrix.getHeight() - 8, 1);
|
401
|
+
}
|
402
|
+
|
403
|
+
private static void embedHorizontalSeparationPattern(int xStart, int yStart,
|
404
|
+
ByteMatrix matrix) throws WriterException {
|
405
|
+
// We know the width and height.
|
406
|
+
if (HORIZONTAL_SEPARATION_PATTERN[0].length != 8 || HORIZONTAL_SEPARATION_PATTERN.length != 1) {
|
407
|
+
throw new WriterException("Bad horizontal separation pattern");
|
408
|
+
}
|
409
|
+
for (int x = 0; x < 8; ++x) {
|
410
|
+
if (!isEmpty(matrix.get(xStart + x, yStart))) {
|
411
|
+
throw new WriterException();
|
412
|
+
}
|
413
|
+
matrix.set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]);
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
private static void embedVerticalSeparationPattern(int xStart, int yStart,
|
418
|
+
ByteMatrix matrix) throws WriterException {
|
419
|
+
// We know the width and height.
|
420
|
+
if (VERTICAL_SEPARATION_PATTERN[0].length != 1 || VERTICAL_SEPARATION_PATTERN.length != 7) {
|
421
|
+
throw new WriterException("Bad vertical separation pattern");
|
422
|
+
}
|
423
|
+
for (int y = 0; y < 7; ++y) {
|
424
|
+
if (!isEmpty(matrix.get(xStart, yStart + y))) {
|
425
|
+
throw new WriterException();
|
426
|
+
}
|
427
|
+
matrix.set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]);
|
428
|
+
}
|
429
|
+
}
|
430
|
+
|
431
|
+
// Note that we cannot unify the function with embedPositionDetectionPattern() despite they are
|
432
|
+
// almost identical, since we cannot write a function that takes 2D arrays in different sizes in
|
433
|
+
// C/C++. We should live with the fact.
|
434
|
+
private static void embedPositionAdjustmentPattern(int xStart, int yStart,
|
435
|
+
ByteMatrix matrix) throws WriterException {
|
436
|
+
// We know the width and height.
|
437
|
+
if (POSITION_ADJUSTMENT_PATTERN[0].length != 5 || POSITION_ADJUSTMENT_PATTERN.length != 5) {
|
438
|
+
throw new WriterException("Bad position adjustment");
|
439
|
+
}
|
440
|
+
for (int y = 0; y < 5; ++y) {
|
441
|
+
for (int x = 0; x < 5; ++x) {
|
442
|
+
if (!isEmpty(matrix.get(xStart + x, yStart + y))) {
|
443
|
+
throw new WriterException();
|
444
|
+
}
|
445
|
+
matrix.set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]);
|
446
|
+
}
|
447
|
+
}
|
448
|
+
}
|
449
|
+
|
450
|
+
private static void embedPositionDetectionPattern(int xStart, int yStart,
|
451
|
+
ByteMatrix matrix) throws WriterException {
|
452
|
+
// We know the width and height.
|
453
|
+
if (POSITION_DETECTION_PATTERN[0].length != 7 || POSITION_DETECTION_PATTERN.length != 7) {
|
454
|
+
throw new WriterException("Bad position detection pattern");
|
455
|
+
}
|
456
|
+
for (int y = 0; y < 7; ++y) {
|
457
|
+
for (int x = 0; x < 7; ++x) {
|
458
|
+
if (!isEmpty(matrix.get(xStart + x, yStart + y))) {
|
459
|
+
throw new WriterException();
|
460
|
+
}
|
461
|
+
matrix.set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]);
|
462
|
+
}
|
463
|
+
}
|
464
|
+
}
|
465
|
+
|
466
|
+
// Embed position detection patterns and surrounding vertical/horizontal separators.
|
467
|
+
private static void embedPositionDetectionPatternsAndSeparators(ByteMatrix matrix) throws WriterException {
|
468
|
+
// Embed three big squares at corners.
|
469
|
+
int pdpWidth = POSITION_DETECTION_PATTERN[0].length;
|
470
|
+
// Left top corner.
|
471
|
+
embedPositionDetectionPattern(0, 0, matrix);
|
472
|
+
// Right top corner.
|
473
|
+
embedPositionDetectionPattern(matrix.getWidth() - pdpWidth, 0, matrix);
|
474
|
+
// Left bottom corner.
|
475
|
+
embedPositionDetectionPattern(0, matrix.getWidth() - pdpWidth, matrix);
|
476
|
+
|
477
|
+
// Embed horizontal separation patterns around the squares.
|
478
|
+
int hspWidth = HORIZONTAL_SEPARATION_PATTERN[0].length;
|
479
|
+
// Left top corner.
|
480
|
+
embedHorizontalSeparationPattern(0, hspWidth - 1, matrix);
|
481
|
+
// Right top corner.
|
482
|
+
embedHorizontalSeparationPattern(matrix.getWidth() - hspWidth,
|
483
|
+
hspWidth - 1, matrix);
|
484
|
+
// Left bottom corner.
|
485
|
+
embedHorizontalSeparationPattern(0, matrix.getWidth() - hspWidth, matrix);
|
486
|
+
|
487
|
+
// Embed vertical separation patterns around the squares.
|
488
|
+
int vspSize = VERTICAL_SEPARATION_PATTERN.length;
|
489
|
+
// Left top corner.
|
490
|
+
embedVerticalSeparationPattern(vspSize, 0, matrix);
|
491
|
+
// Right top corner.
|
492
|
+
embedVerticalSeparationPattern(matrix.getHeight() - vspSize - 1, 0, matrix);
|
493
|
+
// Left bottom corner.
|
494
|
+
embedVerticalSeparationPattern(vspSize, matrix.getHeight() - vspSize,
|
495
|
+
matrix);
|
496
|
+
}
|
497
|
+
|
498
|
+
// Embed position adjustment patterns if need be.
|
499
|
+
private static void maybeEmbedPositionAdjustmentPatterns(int version, ByteMatrix matrix)
|
500
|
+
throws WriterException {
|
501
|
+
if (version < 2) { // The patterns appear if version >= 2
|
502
|
+
return;
|
503
|
+
}
|
504
|
+
int index = version - 1;
|
505
|
+
int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
|
506
|
+
int numCoordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index].length;
|
507
|
+
for (int i = 0; i < numCoordinates; ++i) {
|
508
|
+
for (int j = 0; j < numCoordinates; ++j) {
|
509
|
+
int y = coordinates[i];
|
510
|
+
int x = coordinates[j];
|
511
|
+
if (x == -1 || y == -1) {
|
512
|
+
continue;
|
513
|
+
}
|
514
|
+
// If the cell is unset, we embed the position adjustment pattern here.
|
515
|
+
if (isEmpty(matrix.get(x, y))) {
|
516
|
+
// -2 is necessary since the x/y coordinates point to the center of the pattern, not the
|
517
|
+
// left top corner.
|
518
|
+
embedPositionAdjustmentPattern(x - 2, y - 2, matrix);
|
519
|
+
}
|
520
|
+
}
|
521
|
+
}
|
522
|
+
}
|
523
|
+
|
524
|
+
}
|