示例#1
0
 // added by .net follower (http://dotnetfollower.com)
 // public override ByteMatrix encode(string contents, BarcodeFormat format, int width, int height, Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
 public override ByteMatrix encode(string contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary<Object, Object> hints)
 {
     if (format != BarcodeFormat.CODE_39) {
         throw new ArgumentException("Can only encode CODE_39, but got " + format);
     }
     return base.encode(contents, format, width, height, hints);
 }
        // added by .net follower (http://dotnetfollower.com)
        // public ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary<Object, Object> hints)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (format != BarcodeFormat.QR_CODE)
            {
                throw new System.ArgumentException("Can only encode QR_CODE, but got " + format);
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
            if (hints != null)
            {
                // ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints[EncodeHintType.ERROR_CORRECTION]; // commented by .net follower (http://dotnetfollower.com)
                ErrorCorrectionLevel requestedECLevel = hints.ContainsKey(EncodeHintType.ERROR_CORRECTION) ? (ErrorCorrectionLevel)hints[EncodeHintType.ERROR_CORRECTION] : null; // added by .net follower (http://dotnetfollower.com)
                if (requestedECLevel != null)
                {
                    errorCorrectionLevel = requestedECLevel;
                }
            }

            QRCode code = new QRCode();
            Encoder.encode(contents, errorCorrectionLevel, hints, code);
            return renderResult(code, width, height);
        }
        // ISBN-13 For Dummies
        // http://www.bisg.org/isbn-13/for.dummies.html
        public static ISBNParsedResult parse(Result result)
        {
            BarcodeFormat format = result.BarcodeFormat;

            if (!BarcodeFormat.EAN_13.Equals(format))
            {
                return(null);
            }
            System.String rawText = result.Text;
            if (rawText == null)
            {
                return(null);
            }
            int length = rawText.Length;

            if (length != 13)
            {
                return(null);
            }
            if (!rawText.StartsWith("978") && !rawText.StartsWith("979"))
            {
                return(null);
            }

            return(new ISBNParsedResult(rawText));
        }
示例#4
0
        public ByteMatrix encode(string contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary <Object, Object> hints)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (format != BarcodeFormat.QR_CODE)
            {
                throw new System.ArgumentException("Can only encode QR_CODE, but got " + format);
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;

            if (hints != null && hints.ContainsKey(EncodeHintType.ERROR_CORRECTION))
            {
                errorCorrectionLevel = (ErrorCorrectionLevel)hints[EncodeHintType.ERROR_CORRECTION]; //UPGRADE: Fixed dictionary key grab issue
            }

            QRCode code = new QRCode();

            Encoder.encode(contents, errorCorrectionLevel, hints, code);
            return(renderResult(code, width, height));
        }
示例#5
0
        public ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Hashtable hints)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (format != BarcodeFormat.QR_CODE)
            {
                throw new System.ArgumentException("Can only encode QR_CODE, but got " + format);
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
            if (hints != null)
            {
                ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints[EncodeHintType.ERROR_CORRECTION];
                if (requestedECLevel != null)
                {
                    errorCorrectionLevel = requestedECLevel;
                }
            }

            QRCode code = new QRCode();
            Encoder.encode(contents, errorCorrectionLevel, hints, code);
            return renderResult(code, width, height);
        }
        // public ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (format != BarcodeFormat.QR_CODE)
            {
                throw new System.ArgumentException("Can only encode QR_CODE, but got " + format);
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;

            if (hints != null)
            {
                // ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints[EncodeHintType.ERROR_CORRECTION]; // commented by .net follower (http://dotnetfollower.com)
                ErrorCorrectionLevel requestedECLevel = hints.ContainsKey(EncodeHintType.ERROR_CORRECTION) ? (ErrorCorrectionLevel)hints[EncodeHintType.ERROR_CORRECTION] : null; // added by .net follower (http://dotnetfollower.com)
                if (requestedECLevel != null)
                {
                    errorCorrectionLevel = requestedECLevel;
                }
            }

            QRCode code = new QRCode();

            Encoder.encode(contents, errorCorrectionLevel, hints, code);
            return(renderResult(code, width, height));
        }
示例#7
0
 public override ByteMatrix encode1(string contents, BarcodeFormat format, int width, int height, Dictionary<object, object> hints)
 {
     if (format != BarcodeFormat.CODE_39) {
         throw new Exception("ArgumentException: Can only encode CODE_39, but got " + format);
     }
     return base.encode1(contents, format, width, height, hints);
 }
示例#8
0
        public ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary<Object,Object> hints)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (format != BarcodeFormat.QR_CODE)
            {
                throw new System.ArgumentException("Can only encode QR_CODE, but got " + format);
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
            if (hints != null && hints.ContainsKey(EncodeHintType.ERROR_CORRECTION))
            {
                errorCorrectionLevel = (ErrorCorrectionLevel)hints[EncodeHintType.ERROR_CORRECTION]; //UPGRADE: Fixed dictionary key grab issue
            }

            QRCode code = new QRCode();
            Encoder.encode(contents, errorCorrectionLevel, hints, code);
            return renderResult(code, width, height);
        }
示例#9
0
        // Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes.
        public override ParsedResult parse(Result result)
        {
            BarcodeFormat format = result.BarcodeFormat;

            if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E || format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13))
            {
                return(null);
            }
            string rawText = getMassagedText(result);
            int    length  = rawText.Length;

            for (int x = 0; x < length; x++)
            {
                char c = rawText[x];
                if (c < '0' || c > '9')
                {
                    return(null);
                }
            }
            // Not actually checking the checksum again here

            string normalizedProductID;

            // Expand UPC-E for purposes of searching
            if (format == BarcodeFormat.UPC_E)
            {
                normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText);
            }
            else
            {
                normalizedProductID = rawText;
            }

            return(new ProductParsedResult(rawText, normalizedProductID));
        }
        // Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes.
        public static ProductParsedResult parse(Result result)
        {
            BarcodeFormat format = result.BarcodeFormat;

            if (!(BarcodeFormat.UPC_A.Equals(format) || BarcodeFormat.UPC_E.Equals(format) || BarcodeFormat.EAN_8.Equals(format) || BarcodeFormat.EAN_13.Equals(format)))
            {
                return(null);
            }
            // Really neither of these should happen:
            System.String rawText = result.Text;
            if (rawText == null)
            {
                return(null);
            }

            int length = rawText.Length;

            for (int x = 0; x < length; x++)
            {
                char c = rawText[x];
                if (c < '0' || c > '9')
                {
                    return(null);
                }
            }
            // Not actually checking the checksum again here

            System.String normalizedProductID;
            // Expand UPC-E for purposes of searching

            normalizedProductID = rawText;


            return(new ProductParsedResult(rawText, normalizedProductID));
        }
示例#11
0
        public ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Hashtable hints)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (format != BarcodeFormat.QR_CODE)
            {
                throw new System.ArgumentException("Can only encode QR_CODE, but got " + format);
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;

            if (hints != null)
            {
                ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel)hints[EncodeHintType.ERROR_CORRECTION];
                if (requestedECLevel != null)
                {
                    errorCorrectionLevel = requestedECLevel;
                }
            }

            QRCode code = new QRCode();

            Encoder.encode(contents, errorCorrectionLevel, hints, code);
            return(renderResult(code, width, height));
        }
 // public override ByteMatrix encode(string contents, BarcodeFormat format, int width, int height, Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
 public override ByteMatrix encode(string contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
 {
     if (format != BarcodeFormat.CODE_39)
     {
         throw new ArgumentException("Can only encode CODE_39, but got " + format);
     }
     return(base.encode(contents, format, width, height, hints));
 }
示例#13
0
 public override ByteMatrix encode(string contents, BarcodeFormat format, int width, int height, Hashtable hints)
 {
     if (format != BarcodeFormat.CODE_39)
     {
         throw new ArgumentException("Can only encode CODE_39, but got " + format);
     }
     return(base.encode(contents, format, width, height, hints));
 }
示例#14
0
		private const int codeWidth = 3 + (7 * 6) + 5 + (7 * 6) + 3; // end guard
		
		public override ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Hashtable hints)
		{
			if (format != BarcodeFormat.EAN_13)
			{
				throw new System.ArgumentException("Can only encode EAN_13, but got " + format);
			}
			
			return base.encode(contents, format, width, height, hints);
		}
示例#15
0
        private const int codeWidth = 3 + (7 * 4) + 5 + (7 * 4) + 3;         // end guard

        public override ByteMatrix encode(string contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary <Object, Object> hints)
        {
            if (format != BarcodeFormat.EAN_8)
            {
                throw new System.ArgumentException("Can only encode EAN_8, but got " + format);
            }

            return(base.encode(contents, format, width, height, hints));
        }
示例#16
0
        private const int codeWidth = 3 + (7 * 6) + 5 + (7 * 6) + 3;         // end guard

        public override ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, Dictionary <object, object> hints)
        {
            if (format != BarcodeFormat.EAN_13)
            {
                throw new System.ArgumentException("Can only encode EAN_13, but got " + format);
            }

            return(base.encode(contents, format, width, height, hints));
        }
示例#17
0
        private const int CODE_WIDTH = 3 + (7 * 6) + 5 + (7 * 6) + 3; // end guard -  right bars -  middle guard -  left bars -  start guard

        #endregion Fields

        #region Methods

        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public com.google.zxing.common.BitMatrix encode(String contents, com.google.zxing.BarcodeFormat format, int width, int height, java.util.Map<com.google.zxing.EncodeHintType,?> hints) throws com.google.zxing.WriterException
        public override BitMatrix encode(string contents, BarcodeFormat format, int width, int height, IDictionary<EncodeHintType, object> hints)
        {
            if (format != BarcodeFormat.EAN_13)
            {
              throw new System.ArgumentException("Can only encode EAN_13, but got " + format);
            }

            return base.encode(contents, format, width, height, hints);
        }
示例#18
0
        // public virtual ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public virtual ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            sbyte[] code = encode(contents);
            return(renderResult(code, width, height));
        }
示例#19
0
        public virtual ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, System.Collections.Generic.Dictionary <Object,Object> hints)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            sbyte[] code = encode(contents);
            return renderResult(code, width, height);
        }
示例#20
0
        public virtual ByteMatrix encode1(String contents, BarcodeFormat format, int width, int height, Dictionary<object, object> hints)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new Exception("ArgumentException: Found empty contents");
            }

            if (width < 0 || height < 0)
            {
                throw new Exception("ArgumentException: Requested dimensions are too small: " + width + 'x' + height);
            }

            sbyte[] code = encode2(contents);
            return renderResult(code, width, height);
        }
示例#21
0
        public virtual ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height, Dictionary <object, object> hints)
        {
            if (contents == null || contents.Length == 0)
            {
                throw new System.ArgumentException("Found empty contents");
            }

            if (width < 0 || height < 0)
            {
                throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            sbyte[] code = encode(contents);
            return(renderResult(code, width, height));
        }
示例#22
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public com.google.zxing.common.BitMatrix encode(String contents, com.google.zxing.BarcodeFormat format, int width, int height, java.util.Map<com.google.zxing.EncodeHintType,?> hints) throws com.google.zxing.WriterException
        public BitMatrix encode(string contents, BarcodeFormat format, int width, int height, IDictionary<EncodeHintType, object> hints)
        {
            if (contents.Length == 0)
            {
              throw new System.ArgumentException("Found empty contents");
            }

            if (format != BarcodeFormat.QR_CODE)
            {
              throw new System.ArgumentException("Can only encode QR_CODE, but got " + format);
            }

            if (width < 0 || height < 0)
            {
              throw new System.ArgumentException("Requested dimensions are too small: " + width + 'x' + height);
            }

            ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
            int quietZone = QUIET_ZONE_SIZE;
            if (hints != null)
            {
            //ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel) hints[EncodeHintType.ERROR_CORRECTION];
            ErrorCorrectionLevel requestedECLevel = null;
            if (hints.ContainsKey(EncodeHintType.ERROR_CORRECTION))
            {
                requestedECLevel = (ErrorCorrectionLevel)hints[EncodeHintType.ERROR_CORRECTION];
            }
            if (requestedECLevel != null)
            {
                errorCorrectionLevel = requestedECLevel;
            }

            //int? quietZoneInt = (int?) hints[EncodeHintType.MARGIN];
            int? quietZoneInt = null;
            if (hints.ContainsKey(EncodeHintType.MARGIN))
            {
                quietZoneInt = (int?) hints[EncodeHintType.MARGIN];
            }

            if (quietZoneInt != null)
            {
                quietZone = (int)quietZoneInt;
            }
            }

            QRCode code = Encoder.encode(contents, errorCorrectionLevel, hints);
            return renderResult(code, width, height, quietZone);
        }
示例#23
0
        /// <summary>
        /// See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a>
        /// </summary>
        public override ParsedResult parse(Result result)
        {
            BarcodeFormat format = result.BarcodeFormat;

            if (format != BarcodeFormat.EAN_13)
            {
                return(null);
            }
            string rawText = getMassagedText(result);
            int    length  = rawText.Length;

            if (length != 13)
            {
                return(null);
            }
            if (!rawText.StartsWith("978") && !rawText.StartsWith("979"))
            {
                return(null);
            }

            return(new ISBNParsedResult(rawText));
        }
示例#24
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public com.google.zxing.common.BitMatrix encode(String contents, com.google.zxing.BarcodeFormat format, int width, int height) throws com.google.zxing.WriterException
 public BitMatrix encode(string contents, BarcodeFormat format, int width, int height)
 {
     return encode(contents, format, width, height, null);
 }
示例#25
0
 public virtual ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height)
 {
     return(encode(contents, format, width, height, null));
 }
 public ByteMatrix encode(System.String contents, BarcodeFormat format, int width, int height)
 {
     return encode(contents, format, width, height, null);
 }
示例#27
0
 public ByteMatrix encode(string contents, BarcodeFormat format, int width, int height)
 {
     return(encode(contents, format, width, height, null));
 }
示例#28
0
 public override ByteMatrix encode(string contents, BarcodeFormat format, int width, int height, Hashtable hints)  {
       if (format != BarcodeFormat.CODE_39) {
           throw new ArgumentException("Can only encode CODE_39, but got " + format);
       }
       return base.encode(contents, format, width, height, hints);
 }
示例#29
0
 public virtual ByteMatrix encode(String contents, BarcodeFormat format, int width, int height)
 {
     return encode1(contents, format, width, height, null);
 }