diff --git a/shadowsocks-csharp/3rd/zxing/BarcodeReader.cs b/shadowsocks-csharp/3rd/zxing/BarcodeReader.cs
new file mode 100755
index 0000000..5363a4d
--- /dev/null
+++ b/shadowsocks-csharp/3rd/zxing/BarcodeReader.cs
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2012 ZXing.Net 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;
+#if !PORTABLE
+#if !(SILVERLIGHT || NETFX_CORE)
+#if !UNITY
+using System.Drawing;
+using ZXing.QrCode;
+#else
+using UnityEngine;
+#endif
+#elif NETFX_CORE
+using Windows.UI.Xaml.Media.Imaging;
+#else
+using System.Windows.Media.Imaging;
+#endif
+#endif
+#if MONOANDROID
+using Android.Graphics;
+#endif
+
+namespace ZXing
+{
+ ///
+ /// A smart class to decode the barcode inside a bitmap object
+ ///
+#if MONOTOUCH
+ public class BarcodeReader : BarcodeReaderGeneric, IBarcodeReader, IMultipleBarcodeReader
+ {
+ private static readonly Func defaultCreateLuminanceSource =
+ (img) => new RGBLuminanceSource(img);
+#else
+#if !PORTABLE
+#if !(SILVERLIGHT || NETFX_CORE)
+#if !UNITY
+ public class BarcodeReader : BarcodeReaderGeneric, IBarcodeReader
+ {
+ private static readonly Func defaultCreateLuminanceSource =
+ (bitmap) => new BitmapLuminanceSource(bitmap);
+#else
+ public class BarcodeReader : BarcodeReaderGeneric, IBarcodeReader, IMultipleBarcodeReader
+ {
+ private static readonly Func defaultCreateLuminanceSource =
+ (rawColor32, width, height) => new Color32LuminanceSource(rawColor32, width, height);
+#endif
+#else
+ public class BarcodeReader : BarcodeReaderGeneric, IBarcodeReader, IMultipleBarcodeReader
+ {
+ private static readonly Func defaultCreateLuminanceSource =
+ (bitmap) => new BitmapLuminanceSource(bitmap);
+#endif
+#else
+ public class BarcodeReader : BarcodeReaderGeneric, IBarcodeReader, IMultipleBarcodeReader
+ {
+ private static readonly Func defaultCreateLuminanceSource =
+ (data) => null;
+#endif
+#endif
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public BarcodeReader()
+ : this(new QRCodeReader(), defaultCreateLuminanceSource, null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Sets the reader which should be used to find and decode the barcode.
+ /// If null then MultiFormatReader is used
+ /// Sets the function to create a luminance source object for a bitmap.
+ /// If null, an exception is thrown when Decode is called
+ /// Sets the function to create a binarizer object for a luminance source.
+ /// If null then HybridBinarizer is used
+ public BarcodeReader(Reader reader,
+#if MONOTOUCH
+ Func createLuminanceSource,
+#elif MONOANDROID
+ Func createLuminanceSource,
+#else
+#if !(SILVERLIGHT || NETFX_CORE)
+#if !UNITY
+#if !PORTABLE
+ Func createLuminanceSource,
+#else
+ Func createLuminanceSource,
+#endif
+#else
+ Func createLuminanceSource,
+#endif
+#else
+ Func createLuminanceSource,
+#endif
+#endif
+ Func createBinarizer
+ )
+ : base(reader, createLuminanceSource ?? defaultCreateLuminanceSource, createBinarizer)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Sets the reader which should be used to find and decode the barcode.
+ /// If null then MultiFormatReader is used
+ /// Sets the function to create a luminance source object for a bitmap.
+ /// If null, an exception is thrown when Decode is called
+ /// Sets the function to create a binarizer object for a luminance source.
+ /// If null then HybridBinarizer is used
+ public BarcodeReader(Reader reader,
+#if MONOTOUCH
+ Func createLuminanceSource,
+#elif MONOANDROID
+ Func createLuminanceSource,
+#else
+#if !(SILVERLIGHT || NETFX_CORE)
+#if !UNITY
+#if !PORTABLE
+ Func createLuminanceSource,
+#else
+ Func createLuminanceSource,
+#endif
+#else
+ Func createLuminanceSource,
+#endif
+#else
+ Func createLuminanceSource,
+#endif
+#endif
+ Func createBinarizer,
+ Func createRGBLuminanceSource
+ )
+ : base(reader, createLuminanceSource ?? defaultCreateLuminanceSource, createBinarizer, createRGBLuminanceSource)
+ {
+ }
+ }
+}
diff --git a/shadowsocks-csharp/3rd/zxing/BarcodeReaderGeneric.cs b/shadowsocks-csharp/3rd/zxing/BarcodeReaderGeneric.cs
new file mode 100755
index 0000000..3ce4656
--- /dev/null
+++ b/shadowsocks-csharp/3rd/zxing/BarcodeReaderGeneric.cs
@@ -0,0 +1,436 @@
+/*
+ * Copyright 2012 ZXing.Net 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 System.Collections.Generic;
+
+using ZXing.Common;
+using ZXing.QrCode;
+
+namespace ZXing
+{
+ ///
+ /// A smart class to decode the barcode inside a bitmap object
+ ///
+ public class BarcodeReaderGeneric : IBarcodeReaderGeneric
+ {
+ private static readonly Func defaultCreateBinarizer =
+ (luminanceSource) => new HybridBinarizer(luminanceSource);
+
+ protected static readonly Func defaultCreateRGBLuminanceSource =
+ (rawBytes, width, height, format) => new RGBLuminanceSource(rawBytes, width, height, format);
+
+ private Reader reader;
+ private readonly Func createRGBLuminanceSource;
+#if !UNITY
+ private readonly Func createLuminanceSource;
+#else
+ private readonly Func createLuminanceSource;
+#endif
+ private readonly Func createBinarizer;
+ private bool usePreviousState;
+ private DecodingOptions options;
+
+ ///
+ /// Gets or sets the options.
+ ///
+ ///
+ /// The options.
+ ///
+ public DecodingOptions Options
+ {
+ get { return options ?? (options = new DecodingOptions()); }
+ set { options = value; }
+ }
+
+ ///
+ /// Gets the reader which should be used to find and decode the barcode.
+ ///
+ ///
+ /// The reader.
+ ///
+ protected Reader Reader
+ {
+ get
+ {
+ return reader ?? (reader = new QRCodeReader());
+ }
+ }
+
+ ///
+ /// Gets or sets a method which is called if an important point is found
+ ///
+ ///
+ /// The result point callback.
+ ///
+ public event Action ResultPointFound
+ {
+ add
+ {
+ if (!Options.Hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK))
+ {
+ var callback = new ResultPointCallback(OnResultPointFound);
+ Options.Hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK] = callback;
+ }
+ explicitResultPointFound += value;
+ usePreviousState = false;
+ }
+ remove
+ {
+ explicitResultPointFound -= value;
+ if (explicitResultPointFound == null)
+ Options.Hints.Remove(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
+ usePreviousState = false;
+ }
+ }
+
+ private event Action explicitResultPointFound;
+
+ ///
+ /// event is executed if a result was found via decode
+ ///
+ public event Action ResultFound;
+
+ ///
+ /// Gets or sets a flag which cause a deeper look into the bitmap
+ ///
+ ///
+ /// true if [try harder]; otherwise, false.
+ ///
+ [Obsolete("Please use the Options.TryHarder property instead.")]
+ public bool TryHarder
+ {
+ get { return Options.TryHarder; }
+ set { Options.TryHarder = value; }
+ }
+
+ ///
+ /// Image is a pure monochrome image of a barcode.
+ ///
+ ///
+ /// true if monochrome image of a barcode; otherwise, false.
+ ///
+ [Obsolete("Please use the Options.PureBarcode property instead.")]
+ public bool PureBarcode
+ {
+ get { return Options.PureBarcode; }
+ set { Options.PureBarcode = value; }
+ }
+
+ ///
+ /// Specifies what character encoding to use when decoding, where applicable (type String)
+ ///
+ ///
+ /// The character set.
+ ///
+ [Obsolete("Please use the Options.CharacterSet property instead.")]
+ public string CharacterSet
+ {
+ get { return Options.CharacterSet; }
+ set { Options.CharacterSet = value; }
+ }
+
+ ///
+ /// Image is known to be of one of a few possible formats.
+ /// Maps to a {@link java.util.List} of {@link BarcodeFormat}s.
+ ///
+ ///
+ /// The possible formats.
+ ///
+ [Obsolete("Please use the Options.PossibleFormats property instead.")]
+ public IList PossibleFormats
+ {
+ get { return Options.PossibleFormats; }
+ set { Options.PossibleFormats = value; }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the image should be automatically rotated.
+ /// Rotation is supported for 90, 180 and 270 degrees
+ ///
+ ///
+ /// true if image should be rotated; otherwise, false.
+ ///
+ public bool AutoRotate { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether the image should be automatically inverted
+ /// if no result is found in the original image.
+ /// ATTENTION: Please be carefully because it slows down the decoding process if it is used
+ ///
+ ///
+ /// true if image should be inverted; otherwise, false.
+ ///
+ public bool TryInverted { get; set; }
+
+#if !UNITY
+ ///
+ /// Optional: Gets or sets the function to create a luminance source object for a bitmap.
+ /// If null a platform specific default LuminanceSource is used
+ ///
+ ///
+ /// The function to create a luminance source object.
+ ///
+ protected Func CreateLuminanceSource
+#else
+ ///
+ /// Optional: Gets or sets the function to create a luminance source object for a bitmap.
+ /// If null a platform specific default LuminanceSource is used
+ ///
+ ///
+ /// The function to create a luminance source object.
+ ///
+ protected Func CreateLuminanceSource
+#endif
+ {
+ get
+ {
+ return createLuminanceSource;
+ }
+ }
+
+ ///
+ /// Optional: Gets or sets the function to create a binarizer object for a luminance source.
+ /// If null then HybridBinarizer is used
+ ///
+ ///
+ /// The function to create a binarizer object.
+ ///
+ protected Func CreateBinarizer
+ {
+ get
+ {
+ return createBinarizer ?? defaultCreateBinarizer;
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public BarcodeReaderGeneric()
+ : this(new QRCodeReader(), null, defaultCreateBinarizer)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Sets the reader which should be used to find and decode the barcode.
+ /// If null then MultiFormatReader is used
+ /// Sets the function to create a luminance source object for a bitmap.
+ /// If null, an exception is thrown when Decode is called
+ /// Sets the function to create a binarizer object for a luminance source.
+ /// If null then HybridBinarizer is used
+ public BarcodeReaderGeneric(Reader reader,
+#if !UNITY
+ Func createLuminanceSource,
+#else
+ Func createLuminanceSource,
+#endif
+ Func createBinarizer
+ )
+ : this(reader, createLuminanceSource, createBinarizer, null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Sets the reader which should be used to find and decode the barcode.
+ /// If null then MultiFormatReader is used
+ /// Sets the function to create a luminance source object for a bitmap.
+ /// If null, an exception is thrown when Decode is called
+ /// Sets the function to create a binarizer object for a luminance source.
+ /// If null then HybridBinarizer is used
+ /// Sets the function to create a luminance source object for a rgb array.
+ /// If null the RGBLuminanceSource is used. The handler is only called when Decode with a byte[] array is called.
+ public BarcodeReaderGeneric(Reader reader,
+#if !UNITY
+ Func createLuminanceSource,
+#else
+ Func createLuminanceSource,
+#endif
+ Func createBinarizer,
+ Func createRGBLuminanceSource
+ )
+ {
+ this.reader = reader ?? new QRCodeReader();
+ this.createLuminanceSource = createLuminanceSource;
+ this.createBinarizer = createBinarizer ?? defaultCreateBinarizer;
+ this.createRGBLuminanceSource = createRGBLuminanceSource ?? defaultCreateRGBLuminanceSource;
+ Options.ValueChanged += (o, args) => usePreviousState = false;
+ usePreviousState = false;
+ }
+
+#if !PORTABLE
+#if !UNITY
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The barcode bitmap.
+ /// the result data or null
+ public Result Decode(T barcodeBitmap)
+#else
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// raw bytes of the image in RGB order
+ ///
+ ///
+ ///
+ /// the result data or null
+ ///
+ public Result Decode(T rawRGB, int width, int height)
+#endif
+ {
+ if (CreateLuminanceSource == null)
+ {
+ throw new InvalidOperationException("You have to declare a luminance source delegate.");
+ }
+
+#if !UNITY
+ if (barcodeBitmap == null)
+ throw new ArgumentNullException("barcodeBitmap");
+#else
+ if (rawRGB == null)
+ throw new ArgumentNullException("rawRGB");
+#endif
+
+#if !UNITY
+ var luminanceSource = CreateLuminanceSource(barcodeBitmap);
+#else
+ var luminanceSource = CreateLuminanceSource(rawRGB, width, height);
+#endif
+
+ return Decode(luminanceSource);
+ }
+#endif
+
+ ///
+ /// Tries to decode a barcode within an image which is given by a luminance source.
+ /// That method gives a chance to prepare a luminance source completely before calling
+ /// the time consuming decoding method. On the other hand there is a chance to create
+ /// a luminance source which is independent from external resources (like Bitmap objects)
+ /// and the decoding call can be made in a background thread.
+ ///
+ /// The luminance source.
+ ///
+ virtual public Result Decode(LuminanceSource luminanceSource)
+ {
+ var result = default(Result);
+ var binarizer = CreateBinarizer(luminanceSource);
+ var binaryBitmap = new BinaryBitmap(binarizer);
+ var multiformatReader = Reader as QRCodeReader;
+ var rotationCount = 0;
+ var rotationMaxCount = 1;
+
+ if (AutoRotate)
+ {
+ Options.Hints[DecodeHintType.TRY_HARDER_WITHOUT_ROTATION] = true;
+ rotationMaxCount = 4;
+ }
+ else
+ {
+ if (Options.Hints.ContainsKey(DecodeHintType.TRY_HARDER_WITHOUT_ROTATION))
+ Options.Hints.Remove(DecodeHintType.TRY_HARDER_WITHOUT_ROTATION);
+ }
+
+ for (; rotationCount < rotationMaxCount; rotationCount++)
+ {
+ result = Reader.decode(binaryBitmap, Options.Hints);
+ usePreviousState = true;
+
+
+ if (result != null ||
+ !luminanceSource.RotateSupported ||
+ !AutoRotate)
+ break;
+
+ binaryBitmap = new BinaryBitmap(CreateBinarizer(luminanceSource.rotateCounterClockwise()));
+ }
+
+ if (result != null)
+ {
+ if (result.ResultMetadata == null)
+ {
+ result.putMetadata(ResultMetadataType.ORIENTATION, rotationCount * 90);
+ }
+ else if (!result.ResultMetadata.ContainsKey(ResultMetadataType.ORIENTATION))
+ {
+ result.ResultMetadata[ResultMetadataType.ORIENTATION] = rotationCount * 90;
+ }
+ else
+ {
+ // perhaps the core decoder rotates the image already (can happen if TryHarder is specified)
+ result.ResultMetadata[ResultMetadataType.ORIENTATION] = ((int)(result.ResultMetadata[ResultMetadataType.ORIENTATION]) + rotationCount * 90) % 360;
+ }
+
+ OnResultFound(result);
+ }
+
+ return result;
+ }
+
+
+ protected void OnResultsFound(IEnumerable results)
+ {
+ if (ResultFound != null)
+ {
+ foreach (var result in results)
+ {
+ ResultFound(result);
+ }
+ }
+ }
+
+ protected void OnResultFound(Result result)
+ {
+ if (ResultFound != null)
+ {
+ ResultFound(result);
+ }
+ }
+
+ protected void OnResultPointFound(ResultPoint resultPoint)
+ {
+ if (explicitResultPointFound != null)
+ {
+ explicitResultPointFound(resultPoint);
+ }
+ }
+
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The image as byte[] array.
+ /// The width.
+ /// The height.
+ /// The format.
+ ///
+ /// the result data or null
+ ///
+ public Result Decode(byte[] rawRGB, int width, int height, RGBLuminanceSource.BitmapFormat format)
+ {
+ if (rawRGB == null)
+ throw new ArgumentNullException("rawRGB");
+
+ var luminanceSource = createRGBLuminanceSource(rawRGB, width, height, format);
+
+ return Decode(luminanceSource);
+ }
+
+ }
+}
diff --git a/shadowsocks-csharp/3rd/zxing/IBarcodeReader.cs b/shadowsocks-csharp/3rd/zxing/IBarcodeReader.cs
new file mode 100755
index 0000000..66d90ff
--- /dev/null
+++ b/shadowsocks-csharp/3rd/zxing/IBarcodeReader.cs
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2012 ZXing.Net 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 System.Collections.Generic;
+
+#if !(SILVERLIGHT || NETFX_CORE)
+#if !UNITY
+#if !PORTABLE
+using System.Drawing;
+#endif
+#else
+using UnityEngine;
+#endif
+#elif NETFX_CORE
+using Windows.UI.Xaml.Media.Imaging;
+#else
+using System.Windows.Media.Imaging;
+#endif
+
+using ZXing.Common;
+
+namespace ZXing
+{
+ ///
+ /// Interface for a smart class to decode the barcode inside a bitmap object
+ ///
+ public interface IBarcodeReader
+ {
+ ///
+ /// event is executed when a result point was found
+ ///
+ event Action ResultPointFound;
+
+ ///
+ /// event is executed when a result was found via decode
+ ///
+ event Action ResultFound;
+
+ ///
+ /// Gets or sets a flag which cause a deeper look into the bitmap
+ ///
+ ///
+ /// true if [try harder]; otherwise, false.
+ ///
+ [Obsolete("Please use the Options.TryHarder property instead.")]
+ bool TryHarder { get; set; }
+
+ ///
+ /// Image is a pure monochrome image of a barcode.
+ ///
+ ///
+ /// true if monochrome image of a barcode; otherwise, false.
+ ///
+ [Obsolete("Please use the Options.PureBarcode property instead.")]
+ bool PureBarcode { get; set; }
+
+ ///
+ /// Specifies what character encoding to use when decoding, where applicable (type String)
+ ///
+ ///
+ /// The character set.
+ ///
+ [Obsolete("Please use the Options.CharacterSet property instead.")]
+ string CharacterSet { get; set; }
+
+ ///
+ /// Image is known to be of one of a few possible formats.
+ /// Maps to a {@link java.util.List} of {@link BarcodeFormat}s.
+ ///
+ ///
+ /// The possible formats.
+ ///
+ [Obsolete("Please use the Options.PossibleFormats property instead.")]
+ IList PossibleFormats { get; set; }
+
+ ///
+ /// Specifies some options which influence the decoding process
+ ///
+ DecodingOptions Options { get; set; }
+
+ ///
+ /// Decodes the specified barcode bitmap which is given by a generic byte array with the order RGB24.
+ ///
+ /// The image as RGB24 array.
+ /// The width.
+ /// The height.
+ /// The format.
+ ///
+ /// the result data or null
+ ///
+ Result Decode(byte[] rawRGB, int width, int height, RGBLuminanceSource.BitmapFormat format);
+
+ ///
+ /// Tries to decode a barcode within an image which is given by a luminance source.
+ /// That method gives a chance to prepare a luminance source completely before calling
+ /// the time consuming decoding method. On the other hand there is a chance to create
+ /// a luminance source which is independent from external resources (like Bitmap objects)
+ /// and the decoding call can be made in a background thread.
+ ///
+ /// The luminance source.
+ ///
+ Result Decode(LuminanceSource luminanceSource);
+
+#if MONOTOUCH
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The barcode bitmap.
+ /// the result data or null
+ Result Decode(MonoTouch.UIKit.UIImage barcodeImage);
+#elif MONOANDROID
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The barcode bitmap.
+ /// the result data or null
+ Result Decode(Android.Graphics.Bitmap barcodeImage);
+#else
+#if !PORTABLE
+#if !(SILVERLIGHT || NETFX_CORE)
+#if !UNITY
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The barcode bitmap.
+ /// the result data or null
+ Result Decode(Bitmap barcodeBitmap);
+#else
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The image as Color32 array.
+ /// the result data or null
+ Result Decode(Color32[] rawColor32, int width, int height);
+#endif
+#else
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The barcode bitmap.
+ /// the result data or null
+ Result Decode(WriteableBitmap barcodeBitmap);
+#endif
+#endif
+#endif
+ }
+}
diff --git a/shadowsocks-csharp/3rd/zxing/IBarcodeReaderGeneric.cs b/shadowsocks-csharp/3rd/zxing/IBarcodeReaderGeneric.cs
new file mode 100755
index 0000000..1860988
--- /dev/null
+++ b/shadowsocks-csharp/3rd/zxing/IBarcodeReaderGeneric.cs
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2012 ZXing.Net 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 System.Collections.Generic;
+
+using ZXing.Common;
+
+namespace ZXing
+{
+ ///
+ /// Interface for a smart class to decode the barcode inside a bitmap object
+ ///
+ /// gives the type of the input data
+ public interface IBarcodeReaderGeneric
+ {
+ ///
+ /// event is executed when a result point was found
+ ///
+ event Action ResultPointFound;
+
+ ///
+ /// event is executed when a result was found via decode
+ ///
+ event Action ResultFound;
+
+ ///
+ /// Gets or sets a flag which cause a deeper look into the bitmap
+ ///
+ ///
+ /// true if [try harder]; otherwise, false.
+ ///
+ [Obsolete("Please use the Options.TryHarder property instead.")]
+ bool TryHarder { get; set; }
+
+ ///
+ /// Image is a pure monochrome image of a barcode.
+ ///
+ ///
+ /// true if monochrome image of a barcode; otherwise, false.
+ ///
+ [Obsolete("Please use the Options.PureBarcode property instead.")]
+ bool PureBarcode { get; set; }
+
+ ///
+ /// Specifies what character encoding to use when decoding, where applicable (type String)
+ ///
+ ///
+ /// The character set.
+ ///
+ [Obsolete("Please use the Options.CharacterSet property instead.")]
+ string CharacterSet { get; set; }
+
+ ///
+ /// Image is known to be of one of a few possible formats.
+ /// Maps to a {@link java.util.List} of {@link BarcodeFormat}s.
+ ///
+ ///
+ /// The possible formats.
+ ///
+ [Obsolete("Please use the Options.PossibleFormats property instead.")]
+ IList PossibleFormats { get; set; }
+
+ ///
+ /// Specifies some options which influence the decoding process
+ ///
+ DecodingOptions Options { get; set; }
+
+ ///
+ /// Decodes the specified barcode bitmap which is given by a generic byte array.
+ ///
+ /// The barcode bitmap.
+ /// The width.
+ /// The height.
+ /// The format.
+ ///
+ /// the result data or null
+ ///
+ Result Decode(byte[] rawRGB, int width, int height, RGBLuminanceSource.BitmapFormat format);
+
+ ///
+ /// Tries to decode a barcode within an image which is given by a luminance source.
+ /// That method gives a chance to prepare a luminance source completely before calling
+ /// the time consuming decoding method. On the other hand there is a chance to create
+ /// a luminance source which is independent from external resources (like Bitmap objects)
+ /// and the decoding call can be made in a background thread.
+ ///
+ /// The luminance source.
+ ///
+ Result Decode(LuminanceSource luminanceSource);
+
+#if !PORTABLE
+#if !UNITY
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The barcode bitmap.
+ /// the result data or null
+ Result Decode(T barcodeBitmap);
+#else
+ ///
+ /// Decodes the specified barcode bitmap.
+ ///
+ /// The barcode bitmap.
+ /// the result data or null
+ Result Decode(T rawRGB, int width, int height);
+#endif
+#endif
+ }
+}
diff --git a/shadowsocks-csharp/3rd/zxing/RGBLuminanceSource.cs b/shadowsocks-csharp/3rd/zxing/RGBLuminanceSource.cs
new file mode 100755
index 0000000..6af439e
--- /dev/null
+++ b/shadowsocks-csharp/3rd/zxing/RGBLuminanceSource.cs
@@ -0,0 +1,314 @@
+/*
+* Copyright 2012 ZXing.Net 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;
+
+namespace ZXing
+{
+ ///
+ /// Luminance source class which support different formats of images.
+ ///
+ public partial class RGBLuminanceSource : BaseLuminanceSource
+ {
+ ///
+ /// enumeration of supported bitmap format which the RGBLuminanceSource can process
+ ///
+ public enum BitmapFormat
+ {
+ ///
+ /// format of the byte[] isn't known. RGBLuminanceSource tries to determine the best possible value
+ ///
+ Unknown,
+ ///
+ /// grayscale array, the byte array is a luminance array with 1 byte per pixel
+ ///
+ Gray8,
+ ///
+ /// 3 bytes per pixel with the channels red, green and blue
+ ///
+ RGB24,
+ ///
+ /// 4 bytes per pixel with the channels red, green and blue
+ ///
+ RGB32,
+ ///
+ /// 4 bytes per pixel with the channels alpha, red, green and blue
+ ///
+ ARGB32,
+ ///
+ /// 3 bytes per pixel with the channels blue, green and red
+ ///
+ BGR24,
+ ///
+ /// 4 bytes per pixel with the channels blue, green and red
+ ///
+ BGR32,
+ ///
+ /// 4 bytes per pixel with the channels blue, green, red and alpha
+ ///
+ BGRA32,
+ ///
+ /// 2 bytes per pixel, 5 bit red, 6 bits green and 5 bits blue
+ ///
+ RGB565,
+ ///
+ /// 4 bytes per pixel with the channels red, green, blue and alpha
+ ///
+ RGBA32,
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The width.
+ /// The height.
+ protected RGBLuminanceSource(int width, int height)
+ : base(width, height)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ /// It supports a byte array with 3 bytes per pixel (RGB24).
+ ///
+ /// The RGB raw bytes.
+ /// The width.
+ /// The height.
+ public RGBLuminanceSource(byte[] rgbRawBytes, int width, int height)
+ : this(rgbRawBytes, width, height, BitmapFormat.RGB24)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ /// It supports a byte array with 1 byte per pixel (Gray8).
+ /// That means the whole array consists of the luminance values (grayscale).
+ ///
+ /// The luminance array.
+ /// The width.
+ /// The height.
+ /// if set to true [is8 bit].
+ [Obsolete("Use RGBLuminanceSource(luminanceArray, width, height, BitmapFormat.Gray8)")]
+ public RGBLuminanceSource(byte[] luminanceArray, int width, int height, bool is8Bit)
+ : this(luminanceArray, width, height, BitmapFormat.Gray8)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ /// It supports a byte array with 3 bytes per pixel (RGB24).
+ ///
+ /// The RGB raw bytes.
+ /// The width.
+ /// The height.
+ /// The bitmap format.
+ public RGBLuminanceSource(byte[] rgbRawBytes, int width, int height, BitmapFormat bitmapFormat)
+ : base(width, height)
+ {
+ CalculateLuminance(rgbRawBytes, bitmapFormat);
+ }
+
+ ///
+ /// Should create a new luminance source with the right class type.
+ /// The method is used in methods crop and rotate.
+ ///
+ /// The new luminances.
+ /// The width.
+ /// The height.
+ ///
+ protected override LuminanceSource CreateLuminanceSource(byte[] newLuminances, int width, int height)
+ {
+ return new RGBLuminanceSource(width, height) { luminances = newLuminances };
+ }
+
+ private static BitmapFormat DetermineBitmapFormat(byte[] rgbRawBytes, int width, int height)
+ {
+ var square = width*height;
+ var byteperpixel = rgbRawBytes.Length/square;
+
+ switch (byteperpixel)
+ {
+ case 1:
+ return BitmapFormat.Gray8;
+ case 2:
+ return BitmapFormat.RGB565;
+ case 3:
+ return BitmapFormat.RGB24;
+ case 4:
+ return BitmapFormat.RGB32;
+ default:
+ throw new ArgumentException("The bitmap format could not be determined. Please specify the correct value.");
+ }
+ }
+
+ protected void CalculateLuminance(byte[] rgbRawBytes, BitmapFormat bitmapFormat)
+ {
+ if (bitmapFormat == BitmapFormat.Unknown)
+ {
+ bitmapFormat = DetermineBitmapFormat(rgbRawBytes, Width, Height);
+ }
+ switch (bitmapFormat)
+ {
+ case BitmapFormat.Gray8:
+ Buffer.BlockCopy(rgbRawBytes, 0, luminances, 0, rgbRawBytes.Length < luminances.Length ? rgbRawBytes.Length : luminances.Length);
+ break;
+ case BitmapFormat.RGB24:
+ CalculateLuminanceRGB24(rgbRawBytes);
+ break;
+ case BitmapFormat.BGR24:
+ CalculateLuminanceBGR24(rgbRawBytes);
+ break;
+ case BitmapFormat.RGB32:
+ CalculateLuminanceRGB32(rgbRawBytes);
+ break;
+ case BitmapFormat.BGR32:
+ CalculateLuminanceBGR32(rgbRawBytes);
+ break;
+ case BitmapFormat.RGBA32:
+ CalculateLuminanceRGBA32(rgbRawBytes);
+ break;
+ case BitmapFormat.ARGB32:
+ CalculateLuminanceARGB32(rgbRawBytes);
+ break;
+ case BitmapFormat.BGRA32:
+ CalculateLuminanceBGRA32(rgbRawBytes);
+ break;
+ case BitmapFormat.RGB565:
+ CalculateLuminanceRGB565(rgbRawBytes);
+ break;
+ default:
+ throw new ArgumentException("The bitmap format isn't supported.", bitmapFormat.ToString());
+ }
+ }
+
+ private void CalculateLuminanceRGB565(byte[] rgb565RawData)
+ {
+ var luminanceIndex = 0;
+ for (var index = 0; index < rgb565RawData.Length && luminanceIndex < luminances.Length; index += 2, luminanceIndex++)
+ {
+ var byte1 = rgb565RawData[index];
+ var byte2 = rgb565RawData[index + 1];
+
+ var b5 = byte1 & 0x1F;
+ var g5 = (((byte1 & 0xE0) >> 5) | ((byte2 & 0x03) << 3)) & 0x1F;
+ var r5 = (byte2 >> 2) & 0x1F;
+ var r8 = (r5 * 527 + 23) >> 6;
+ var g8 = (g5 * 527 + 23) >> 6;
+ var b8 = (b5 * 527 + 23) >> 6;
+
+ // cheap, not fully accurate conversion
+ //var pixel = (byte2 << 8) | byte1;
+ //b8 = (((pixel) & 0x001F) << 3);
+ //g8 = (((pixel) & 0x07E0) >> 2) & 0xFF;
+ //r8 = (((pixel) & 0xF800) >> 8);
+
+ luminances[luminanceIndex] = (byte)((RChannelWeight * r8 + GChannelWeight * g8 + BChannelWeight * b8) >> ChannelWeight);
+ }
+ }
+
+ private void CalculateLuminanceRGB24(byte[] rgbRawBytes)
+ {
+ for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++)
+ {
+ // Calculate luminance cheaply, favoring green.
+ int r = rgbRawBytes[rgbIndex++];
+ int g = rgbRawBytes[rgbIndex++];
+ int b = rgbRawBytes[rgbIndex++];
+ luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight);
+ }
+ }
+
+ private void CalculateLuminanceBGR24(byte[] rgbRawBytes)
+ {
+ for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++)
+ {
+ // Calculate luminance cheaply, favoring green.
+ int b = rgbRawBytes[rgbIndex++];
+ int g = rgbRawBytes[rgbIndex++];
+ int r = rgbRawBytes[rgbIndex++];
+ luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight);
+ }
+ }
+
+ private void CalculateLuminanceRGB32(byte[] rgbRawBytes)
+ {
+ for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++)
+ {
+ // Calculate luminance cheaply, favoring green.
+ int r = rgbRawBytes[rgbIndex++];
+ int g = rgbRawBytes[rgbIndex++];
+ int b = rgbRawBytes[rgbIndex++];
+ rgbIndex++;
+ luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight);
+ }
+ }
+
+ private void CalculateLuminanceBGR32(byte[] rgbRawBytes)
+ {
+ for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++)
+ {
+ // Calculate luminance cheaply, favoring green.
+ int b = rgbRawBytes[rgbIndex++];
+ int g = rgbRawBytes[rgbIndex++];
+ int r = rgbRawBytes[rgbIndex++];
+ rgbIndex++;
+ luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight);
+ }
+ }
+
+ private void CalculateLuminanceBGRA32(byte[] rgbRawBytes)
+ {
+ for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++)
+ {
+ // Calculate luminance cheaply, favoring green.
+ var b = rgbRawBytes[rgbIndex++];
+ var g = rgbRawBytes[rgbIndex++];
+ var r = rgbRawBytes[rgbIndex++];
+ var alpha = rgbRawBytes[rgbIndex++];
+ var luminance = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight);
+ luminances[luminanceIndex] = (byte)(((luminance * alpha) >> 8) + (255 * (255 - alpha) >> 8));
+ }
+ }
+
+ private void CalculateLuminanceRGBA32(byte[] rgbRawBytes)
+ {
+ for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++)
+ {
+ // Calculate luminance cheaply, favoring green.
+ var r = rgbRawBytes[rgbIndex++];
+ var g = rgbRawBytes[rgbIndex++];
+ var b = rgbRawBytes[rgbIndex++];
+ var alpha = rgbRawBytes[rgbIndex++];
+ var luminance = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight);
+ luminances[luminanceIndex] = (byte)(((luminance * alpha) >> 8) + (255 * (255 - alpha) >> 8));
+ }
+ }
+
+ private void CalculateLuminanceARGB32(byte[] rgbRawBytes)
+ {
+ for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++)
+ {
+ // Calculate luminance cheaply, favoring green.
+ var alpha = rgbRawBytes[rgbIndex++];
+ var r = rgbRawBytes[rgbIndex++];
+ var g = rgbRawBytes[rgbIndex++];
+ var b = rgbRawBytes[rgbIndex++];
+ var luminance = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight);
+ luminances[luminanceIndex] = (byte)(((luminance * alpha) >> 8) + (255 * (255 - alpha) >> 8));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs b/shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs
new file mode 100755
index 0000000..cb42eb5
--- /dev/null
+++ b/shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs
@@ -0,0 +1,128 @@
+/*
+* 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 System.Collections.Generic;
+
+namespace ZXing.Common
+{
+ /// Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1
+ /// of ISO 18004.
+ ///
+ ///
+ /// Sean Owen
+ public sealed class CharacterSetECI : ECI
+ {
+ internal static readonly IDictionary VALUE_TO_ECI;
+ internal static readonly IDictionary NAME_TO_ECI;
+
+ private readonly String encodingName;
+
+ public String EncodingName
+ {
+ get
+ {
+ return encodingName;
+ }
+
+ }
+
+ static CharacterSetECI()
+ {
+ VALUE_TO_ECI = new Dictionary();
+ NAME_TO_ECI = new Dictionary();
+ // TODO figure out if these values are even right!
+ addCharacterSet(0, "CP437");
+ addCharacterSet(1, new[] { "ISO-8859-1", "ISO8859_1" });
+ addCharacterSet(2, "CP437");
+ addCharacterSet(3, new[] { "ISO-8859-1", "ISO8859_1" });
+ addCharacterSet(4, new[] { "ISO-8859-2", "ISO8859_2" });
+ addCharacterSet(5, new[] { "ISO-8859-3", "ISO8859_3" });
+ addCharacterSet(6, new[] { "ISO-8859-4", "ISO8859_4" });
+ addCharacterSet(7, new[] { "ISO-8859-5", "ISO8859_5" });
+ addCharacterSet(8, new[] { "ISO-8859-6", "ISO8859_6" });
+ addCharacterSet(9, new[] { "ISO-8859-7", "ISO8859_7" });
+ addCharacterSet(10, new[] { "ISO-8859-8", "ISO8859_8" });
+ addCharacterSet(11, new[] { "ISO-8859-9", "ISO8859_9" });
+ addCharacterSet(12, new[] { "ISO-8859-4", "ISO-8859-10", "ISO8859_10" }); // use ISO-8859-4 because ISO-8859-16 isn't supported
+ addCharacterSet(13, new[] { "ISO-8859-11", "ISO8859_11" });
+ addCharacterSet(15, new[] { "ISO-8859-13", "ISO8859_13" });
+ addCharacterSet(16, new[] { "ISO-8859-1", "ISO-8859-14", "ISO8859_14" }); // use ISO-8859-1 because ISO-8859-16 isn't supported
+ addCharacterSet(17, new[] { "ISO-8859-15", "ISO8859_15" });
+ addCharacterSet(18, new[] { "ISO-8859-3", "ISO-8859-16", "ISO8859_16" }); // use ISO-8859-3 because ISO-8859-16 isn't supported
+ addCharacterSet(20, new[] { "SJIS", "Shift_JIS" });
+ addCharacterSet(21, new[] { "WINDOWS-1250", "CP1250" });
+ addCharacterSet(22, new[] { "WINDOWS-1251", "CP1251" });
+ addCharacterSet(23, new[] { "WINDOWS-1252", "CP1252" });
+ addCharacterSet(24, new[] { "WINDOWS-1256", "CP1256" });
+ addCharacterSet(25, new[] { "UTF-16BE", "UNICODEBIG" });
+ addCharacterSet(26, new[] { "UTF-8", "UTF8" });
+ addCharacterSet(27, "US-ASCII");
+ addCharacterSet(170, "US-ASCII");
+ addCharacterSet(28, "BIG5");
+ addCharacterSet(29, new[] { "GB18030", "GB2312", "EUC_CN", "GBK" });
+ addCharacterSet(30, new[] { "EUC-KR", "EUC_KR" });
+ }
+
+ private CharacterSetECI(int value, String encodingName)
+ : base(value)
+ {
+ this.encodingName = encodingName;
+ }
+
+ private static void addCharacterSet(int value, String encodingName)
+ {
+ var eci = new CharacterSetECI(value, encodingName);
+ VALUE_TO_ECI[value] = eci; // can't use valueOf
+ NAME_TO_ECI[encodingName] = eci;
+ }
+
+ private static void addCharacterSet(int value, String[] encodingNames)
+ {
+ var eci = new CharacterSetECI(value, encodingNames[0]);
+ VALUE_TO_ECI[value] = eci; // can't use valueOf
+ foreach (string t in encodingNames)
+ {
+ NAME_TO_ECI[t] = eci;
+ }
+ }
+
+ /// character set ECI value
+ ///
+ /// {@link CharacterSetECI} representing ECI of given value, or null if it is legal but
+ /// unsupported
+ ///
+ /// IllegalArgumentException if ECI value is invalid
+ public static CharacterSetECI getCharacterSetECIByValue(int value)
+ {
+ if (value < 0 || value >= 900)
+ {
+ return null;
+ }
+ return VALUE_TO_ECI[value];
+ }
+
+ /// character set ECI encoding name
+ ///
+ /// {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal
+ /// but unsupported
+ ///
+ public static CharacterSetECI getCharacterSetECIByName(String name)
+ {
+ return NAME_TO_ECI[name.ToUpper()];
+ }
+ }
+}
\ No newline at end of file
diff --git a/shadowsocks-csharp/3rd/zxing/common/DecodingOptions.cs b/shadowsocks-csharp/3rd/zxing/common/DecodingOptions.cs
new file mode 100755
index 0000000..9a58f9a
--- /dev/null
+++ b/shadowsocks-csharp/3rd/zxing/common/DecodingOptions.cs
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2013 ZXing.Net 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 System.Collections.Generic;
+using System.ComponentModel;
+
+namespace ZXing.Common
+{
+ ///
+ /// Defines an container for encoder options
+ ///
+ [Serializable]
+ public class DecodingOptions
+ {
+ ///
+ /// Gets the data container for all options
+ ///
+ [Browsable(false)]
+ public IDictionary Hints { get; private set; }
+
+ [field: NonSerialized]
+ public event Action