X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=csharp%2Foned%2FUPCAReader.cs;fp=csharp%2Foned%2FUPCAReader.cs;h=660e011e52366ab9ce7d741946389550b74ae3c3;hb=ec1d7dfa5fb34e69b0f65f936eec23c8a8b88b56;hp=0000000000000000000000000000000000000000;hpb=e8f7ac2a4615b772609002f4f903fda2e9474c5c;p=zxing.git diff --git a/csharp/oned/UPCAReader.cs b/csharp/oned/UPCAReader.cs new file mode 100755 index 00000000..660e011e --- /dev/null +++ b/csharp/oned/UPCAReader.cs @@ -0,0 +1,86 @@ +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +using System; +using BarcodeFormat = com.google.zxing.BarcodeFormat; +using ReaderException = com.google.zxing.ReaderException; +using Result = com.google.zxing.Result; +using BinaryBitmap = com.google.zxing.BinaryBitmap; +using BitArray = com.google.zxing.common.BitArray; +namespace com.google.zxing.oned +{ + + ///

Implements decoding of the UPC-A format.

+ /// + ///
+ /// dswitkin@google.com (Daniel Switkin) + /// + /// Sean Owen + /// + /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source + /// + public sealed class UPCAReader:UPCEANReader + { + override internal BarcodeFormat BarcodeFormat + { + get + { + return BarcodeFormat.UPC_A; + } + + } + + //UPGRADE_NOTE: Final was removed from the declaration of 'ean13Reader '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" + private UPCEANReader ean13Reader = new EAN13Reader(); + + public override Result decodeRow(int rowNumber, BitArray row, int[] startGuardRange, System.Collections.Hashtable hints) + { + return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange, hints)); + } + + public override Result decodeRow(int rowNumber, BitArray row, System.Collections.Hashtable hints) + { + return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, hints)); + } + + public override Result decode(BinaryBitmap image) + { + return maybeReturnResult(ean13Reader.decode(image)); + } + + public override Result decode(BinaryBitmap image, System.Collections.Hashtable hints) + { + return maybeReturnResult(ean13Reader.decode(image, hints)); + } + + protected internal override int decodeMiddle(BitArray row, int[] startRange, System.Text.StringBuilder resultString) + { + return ean13Reader.decodeMiddle(row, startRange, resultString); + } + + private static Result maybeReturnResult(Result result) + { + System.String text = result.Text; + if (text[0] == '0') + { + return new Result(text.Substring(1), null, result.ResultPoints, BarcodeFormat.UPC_A); + } + else + { + throw ReaderException.Instance; + } + } + } +} \ No newline at end of file