From b8fbc208587f347d2ec9d5f9d208f7d2f2d7032c Mon Sep 17 00:00:00 2001 From: clowwindy Date: Tue, 13 Jan 2015 01:58:38 +0800 Subject: [PATCH] remove some class --- shadowsocks-csharp/3rd/zxing/Reader.cs | 59 --- .../3rd/zxing/ReaderException.cs | 71 --- .../3rd/zxing/common/DecodingOptions.cs | 370 --------------- .../3rd/zxing/common/EncodingOptions.cs | 121 ----- .../detector/MonochromeRectangleDetector.cs | 252 ---------- .../common/detector/WhiteRectangleDetector.cs | 433 ------------------ shadowsocks-csharp/3rd/zxing/net2.0/Action.cs | 102 ----- shadowsocks-csharp/3rd/zxing/net2.0/Func.cs | 122 ----- .../3rd/zxing/net2.0/TimeZoneInfo.cs | 29 -- .../3rd/zxing/qrcode/QRCodeReader.cs | 2 +- .../qrcode/encoder/QrCodeEncodingOptions.cs | 110 ----- .../View/QRCodeForm.Designer.cs | 2 +- shadowsocks-csharp/shadowsocks-csharp.csproj | 10 - 13 files changed, 2 insertions(+), 1681 deletions(-) delete mode 100755 shadowsocks-csharp/3rd/zxing/Reader.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/ReaderException.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/common/DecodingOptions.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/common/EncodingOptions.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/common/detector/MonochromeRectangleDetector.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/common/detector/WhiteRectangleDetector.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/net2.0/Action.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/net2.0/Func.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/net2.0/TimeZoneInfo.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/qrcode/encoder/QrCodeEncodingOptions.cs diff --git a/shadowsocks-csharp/3rd/zxing/Reader.cs b/shadowsocks-csharp/3rd/zxing/Reader.cs deleted file mode 100755 index b96267af..00000000 --- a/shadowsocks-csharp/3rd/zxing/Reader.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright 2007 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.Collections.Generic; - -namespace ZXing -{ - /// - /// Implementations of this interface can decode an image of a barcode in some format into - /// the String it encodes. For example, can - /// decode a QR code. The decoder may optionally receive hints from the caller which may help - /// it decode more quickly or accurately. - /// - /// See , which attempts to determine what barcode - /// format is present within the image as well, and then decodes it accordingly. - /// - /// Sean Owen - /// dswitkin@google.com (Daniel Switkin) - public interface Reader - { - /// - /// Locates and decodes a barcode in some format within an image. - /// - /// image of barcode to decode - /// String which the barcode encodes - Result decode(BinaryBitmap image); - - /// Locates and decodes a barcode in some format within an image. This method also accepts - /// hints, each possibly associated to some data, which may help the implementation decode. - /// - /// image of barcode to decode - /// passed as a from - /// to arbitrary data. The - /// meaning of the data depends upon the hint type. The implementation may or may not do - /// anything with these hints. - /// - /// String which the barcode encodes - Result decode(BinaryBitmap image, IDictionary hints); - - /// - /// Resets any internal state the implementation has after a decode, to prepare it - /// for reuse. - /// - void reset(); - } -} \ No newline at end of file diff --git a/shadowsocks-csharp/3rd/zxing/ReaderException.cs b/shadowsocks-csharp/3rd/zxing/ReaderException.cs deleted file mode 100755 index 90936b5c..00000000 --- a/shadowsocks-csharp/3rd/zxing/ReaderException.cs +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright 2007 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; - -namespace ZXing -{ - /// - /// The general exception class throw when something goes wrong during decoding of a barcode. - /// This includes, but is not limited to, failing checksums / error correction algorithms, being - /// unable to locate finder timing patterns, and so on. - /// - /// Sean Owen - [Serializable] - public class ReaderException : Exception - { - /// - /// Gets the instance. - /// - public static ReaderException Instance - { - get - { - return instance; - } - - } - - // TODO: Currently we throw up to 400 ReaderExceptions while scanning a single 240x240 image before - // rejecting it. This involves a lot of overhead and memory allocation, and affects both performance - // and latency on continuous scan clients. In the future, we should change all the decoders not to - // throw exceptions for routine events, like not finding a barcode on a given row. Instead, we - // should return error codes back to the callers, and simply delete this class. In the mean time, I - // have altered this class to be as lightweight as possible, by ignoring the exception string, and - // by disabling the generation of stack traces, which is especially time consuming. These are just - // temporary measures, pending the big cleanup. - - //UPGRADE_NOTE: Final was removed from the declaration of 'instance '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" - private static readonly ReaderException instance = new ReaderException(); - - // EXCEPTION TRACKING SUPPORT - // Identifies who is throwing exceptions and how often. To use: - // - // 1. Uncomment these lines and the code below which uses them. - // 2. Uncomment the two corresponding lines in j2se/CommandLineRunner.decode() - // 3. Change core to build as Java 1.5 temporarily - // private static int exceptionCount = 0; - // private static Map throwers = new HashMap(32); - - /// - /// Initializes a new instance of the class. - /// - protected ReaderException() - { - // do nothing - } - } -} \ No newline at end of file diff --git a/shadowsocks-csharp/3rd/zxing/common/DecodingOptions.cs b/shadowsocks-csharp/3rd/zxing/common/DecodingOptions.cs deleted file mode 100755 index 9a58f9af..00000000 --- a/shadowsocks-csharp/3rd/zxing/common/DecodingOptions.cs +++ /dev/null @@ -1,370 +0,0 @@ -/* - * 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 ValueChanged; - - /// - /// Gets or sets a flag which cause a deeper look into the bitmap - /// - /// - /// true if [try harder]; otherwise, false. - /// - public bool TryHarder - { - get - { - if (Hints.ContainsKey(DecodeHintType.TRY_HARDER)) - return (bool)Hints[DecodeHintType.TRY_HARDER]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.TRY_HARDER] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.TRY_HARDER)) - { - Hints.Remove(DecodeHintType.TRY_HARDER); - } - } - } - } - - /// - /// Image is a pure monochrome image of a barcode. - /// - /// - /// true if monochrome image of a barcode; otherwise, false. - /// - public bool PureBarcode - { - get - { - if (Hints.ContainsKey(DecodeHintType.PURE_BARCODE)) - return (bool)Hints[DecodeHintType.PURE_BARCODE]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.PURE_BARCODE] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.PURE_BARCODE)) - { - Hints.Remove(DecodeHintType.PURE_BARCODE); - } - } - } - } - - /// - /// Specifies what character encoding to use when decoding, where applicable (type String) - /// - /// - /// The character set. - /// - public string CharacterSet - { - get - { - if (Hints.ContainsKey(DecodeHintType.CHARACTER_SET)) - return (string)Hints[DecodeHintType.CHARACTER_SET]; - return null; - } - set - { - if (value != null) - { - Hints[DecodeHintType.CHARACTER_SET] = value; - } - else - { - if (Hints.ContainsKey(DecodeHintType.CHARACTER_SET)) - { - Hints.Remove(DecodeHintType.CHARACTER_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. - /// - public IList PossibleFormats - { - get - { - if (Hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS)) - return (IList)Hints[DecodeHintType.POSSIBLE_FORMATS]; - return null; - } - set - { - if (value != null) - { - Hints[DecodeHintType.POSSIBLE_FORMATS] = value; - } - else - { - if (Hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS)) - { - Hints.Remove(DecodeHintType.POSSIBLE_FORMATS); - } - } - } - } - - /// - /// if Code39 could be detected try to use extended mode for full ASCII character set - /// - public bool UseCode39ExtendedMode - { - get - { - if (Hints.ContainsKey(DecodeHintType.USE_CODE_39_EXTENDED_MODE)) - return (bool)Hints[DecodeHintType.USE_CODE_39_EXTENDED_MODE]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.USE_CODE_39_EXTENDED_MODE] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.USE_CODE_39_EXTENDED_MODE)) - { - Hints.Remove(DecodeHintType.USE_CODE_39_EXTENDED_MODE); - } - } - } - } - - /// - /// Don't fail if a Code39 is detected but can't be decoded in extended mode. - /// Return the raw Code39 result instead. Maps to . - /// - public bool UseCode39RelaxedExtendedMode - { - get - { - if (Hints.ContainsKey(DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE)) - return (bool)Hints[DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE)) - { - Hints.Remove(DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE); - } - } - } - } - - /// - /// If true, return the start and end digits in a Codabar barcode instead of stripping them. They - /// are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them - /// to not be. Doesn't matter what it maps to; use . - /// - public bool ReturnCodabarStartEnd - { - get - { - if (Hints.ContainsKey(DecodeHintType.RETURN_CODABAR_START_END)) - return (bool)Hints[DecodeHintType.RETURN_CODABAR_START_END]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.RETURN_CODABAR_START_END] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.RETURN_CODABAR_START_END)) - { - Hints.Remove(DecodeHintType.RETURN_CODABAR_START_END); - } - } - } - } - /// - /// Initializes a new instance of the class. - /// - public DecodingOptions() - { - var hints = new ChangeNotifyDictionary(); - Hints = hints; - UseCode39ExtendedMode = true; - UseCode39RelaxedExtendedMode = true; - hints.ValueChanged += (o, args) => { if (ValueChanged != null) ValueChanged(this, EventArgs.Empty); }; - } - - [Serializable] - private class ChangeNotifyDictionary: IDictionary - { - private readonly IDictionary values; - - [field: NonSerialized] - public event Action ValueChanged; - - public ChangeNotifyDictionary() - { - values = new Dictionary(); - } - - private void OnValueChanged() - { - if (ValueChanged != null) - ValueChanged(this, EventArgs.Empty); - } - - public void Add(TKey key, TValue value) - { - values.Add(key, value); - OnValueChanged(); - } - - public bool ContainsKey(TKey key) - { - return values.ContainsKey(key); - } - - public ICollection Keys - { - get { return values.Keys; } - } - - public bool Remove(TKey key) - { - var result = values.Remove(key); - OnValueChanged(); - return result; - } - - public bool TryGetValue(TKey key, out TValue value) - { - return values.TryGetValue(key, out value); - } - - public ICollection Values - { - get { return values.Values; } - } - - public TValue this[TKey key] - { - get - { - return values[key]; - } - set - { - values[key] = value; - OnValueChanged(); - } - } - - public void Add(KeyValuePair item) - { - values.Add(item); - OnValueChanged(); - } - - public void Clear() - { - values.Clear(); - OnValueChanged(); - } - - public bool Contains(KeyValuePair item) - { - return values.Contains(item); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - values.CopyTo(array, arrayIndex); - } - - public int Count - { - get { return values.Count; } - } - - public bool IsReadOnly - { - get { return values.IsReadOnly; } - } - - public bool Remove(KeyValuePair item) - { - var result = values.Remove(item); - OnValueChanged(); - - return result; - } - - public IEnumerator> GetEnumerator() - { - return values.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return ((System.Collections.IEnumerable)values).GetEnumerator(); - } - } - } -} diff --git a/shadowsocks-csharp/3rd/zxing/common/EncodingOptions.cs b/shadowsocks-csharp/3rd/zxing/common/EncodingOptions.cs deleted file mode 100755 index 683453ec..00000000 --- a/shadowsocks-csharp/3rd/zxing/common/EncodingOptions.cs +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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 System.ComponentModel; - -namespace ZXing.Common -{ - /// - /// Defines an container for encoder options - /// - [Serializable] - public class EncodingOptions - { - /// - /// Gets the data container for all options - /// - [Browsable(false)] - public IDictionary Hints { get; private set; } - - /// - /// Specifies the height of the barcode image - /// - public int Height - { - get - { - if (Hints.ContainsKey(EncodeHintType.HEIGHT)) - { - return (int)Hints[EncodeHintType.HEIGHT]; - } - return 0; - } - set - { - Hints[EncodeHintType.HEIGHT] = value; - } - } - - /// - /// Specifies the width of the barcode image - /// - public int Width - { - get - { - if (Hints.ContainsKey(EncodeHintType.WIDTH)) - { - return (int)Hints[EncodeHintType.WIDTH]; - } - return 0; - } - set - { - Hints[EncodeHintType.WIDTH] = value; - } - } - - /// - /// Don't put the content string into the output image. - /// - public bool PureBarcode - { - get - { - if (Hints.ContainsKey(EncodeHintType.PURE_BARCODE)) - { - return (bool)Hints[EncodeHintType.PURE_BARCODE]; - } - return false; - } - set - { - Hints[EncodeHintType.PURE_BARCODE] = value; - } - } - - /// - /// Specifies margin, in pixels, to use when generating the barcode. The meaning can vary - /// by format; for example it controls margin before and after the barcode horizontally for - /// most 1D formats. - /// - public int Margin - { - get - { - if (Hints.ContainsKey(EncodeHintType.MARGIN)) - { - return (int) Hints[EncodeHintType.MARGIN]; - } - return 0; - } - set - { - Hints[EncodeHintType.MARGIN] = value; - } - } - - /// - /// Initializes a new instance of the class. - /// - public EncodingOptions() - { - Hints = new Dictionary(); - } - } -} diff --git a/shadowsocks-csharp/3rd/zxing/common/detector/MonochromeRectangleDetector.cs b/shadowsocks-csharp/3rd/zxing/common/detector/MonochromeRectangleDetector.cs deleted file mode 100755 index 9fb4515f..00000000 --- a/shadowsocks-csharp/3rd/zxing/common/detector/MonochromeRectangleDetector.cs +++ /dev/null @@ -1,252 +0,0 @@ -/* -* Copyright 2009 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. -*/ - -namespace ZXing.Common.Detector -{ - ///

A somewhat generic detector that looks for a barcode-like rectangular region within an image. - /// It looks within a mostly white region of an image for a region of black and white, but mostly - /// black. It returns the four corners of the region, as best it can determine.

- /// - ///
- /// Sean Owen - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - public sealed class MonochromeRectangleDetector - { - private const int MAX_MODULES = 32; - - private BitMatrix image; - - public MonochromeRectangleDetector(BitMatrix image) - { - this.image = image; - } - - ///

Detects a rectangular region of black and white -- mostly black -- with a region of mostly - /// white, in an image.

- /// - ///
- /// {@link ResultPoint}[] describing the corners of the rectangular region. The first and - /// last points are opposed on the diagonal, as are the second and third. The first point will be - /// the topmost point and the last, the bottommost. The second point will be leftmost and the - /// third, the rightmost - /// - public ResultPoint[] detect() - { - int height = image.Height; - int width = image.Width; - int halfHeight = height >> 1; - int halfWidth = width >> 1; - int deltaY = System.Math.Max(1, height / (MAX_MODULES << 3)); - int deltaX = System.Math.Max(1, width / (MAX_MODULES << 3)); - - int top = 0; - int bottom = height; - int left = 0; - int right = width; - ResultPoint pointA = findCornerFromCenter(halfWidth, 0, left, right, halfHeight, -deltaY, top, bottom, halfWidth >> 1); - if (pointA == null) - return null; - top = (int)pointA.Y - 1; - ResultPoint pointB = findCornerFromCenter(halfWidth, -deltaX, left, right, halfHeight, 0, top, bottom, halfHeight >> 1); - if (pointB == null) - return null; - left = (int)pointB.X - 1; - ResultPoint pointC = findCornerFromCenter(halfWidth, deltaX, left, right, halfHeight, 0, top, bottom, halfHeight >> 1); - if (pointC == null) - return null; - right = (int)pointC.X + 1; - ResultPoint pointD = findCornerFromCenter(halfWidth, 0, left, right, halfHeight, deltaY, top, bottom, halfWidth >> 1); - if (pointD == null) - return null; - bottom = (int)pointD.Y + 1; - - // Go try to find point A again with better information -- might have been off at first. - pointA = findCornerFromCenter(halfWidth, 0, left, right, halfHeight, -deltaY, top, bottom, halfWidth >> 2); - if (pointA == null) - return null; - - return new ResultPoint[] { pointA, pointB, pointC, pointD }; - } - - /// Attempts to locate a corner of the barcode by scanning up, down, left or right from a center - /// point which should be within the barcode. - /// - /// - /// center's x component (horizontal) - /// - /// same as deltaY but change in x per step instead - /// - /// minimum value of x - /// - /// maximum value of x - /// - /// center's y component (vertical) - /// - /// change in y per step. If scanning up this is negative; down, positive; - /// left or right, 0 - /// - /// minimum value of y to search through (meaningless when di == 0) - /// - /// maximum value of y - /// - /// maximum run of white pixels that can still be considered to be within - /// the barcode - /// - /// a {@link com.google.zxing.ResultPoint} encapsulating the corner that was found - /// - private ResultPoint findCornerFromCenter(int centerX, int deltaX, int left, int right, int centerY, int deltaY, int top, int bottom, int maxWhiteRun) - { - int[] lastRange = null; - for (int y = centerY, x = centerX; y < bottom && y >= top && x < right && x >= left; y += deltaY, x += deltaX) - { - int[] range; - if (deltaX == 0) - { - // horizontal slices, up and down - range = blackWhiteRange(y, maxWhiteRun, left, right, true); - } - else - { - // vertical slices, left and right - range = blackWhiteRange(x, maxWhiteRun, top, bottom, false); - } - if (range == null) - { - if (lastRange == null) - { - return null; - } - // lastRange was found - if (deltaX == 0) - { - int lastY = y - deltaY; - if (lastRange[0] < centerX) - { - if (lastRange[1] > centerX) - { - // straddle, choose one or the other based on direction - return new ResultPoint(deltaY > 0 ? lastRange[0] : lastRange[1], lastY); - } - return new ResultPoint(lastRange[0], lastY); - } - else - { - return new ResultPoint(lastRange[1], lastY); - } - } - else - { - int lastX = x - deltaX; - if (lastRange[0] < centerY) - { - if (lastRange[1] > centerY) - { - return new ResultPoint(lastX, deltaX < 0 ? lastRange[0] : lastRange[1]); - } - return new ResultPoint(lastX, lastRange[0]); - } - else - { - return new ResultPoint(lastX, lastRange[1]); - } - } - } - lastRange = range; - } - return null; - } - - /// Computes the start and end of a region of pixels, either horizontally or vertically, that could - /// be part of a Data Matrix barcode. - /// - /// - /// if scanning horizontally, this is the row (the fixed vertical location) - /// where we are scanning. If scanning vertically it's the column, the fixed horizontal location - /// - /// largest run of white pixels that can still be considered part of the - /// barcode region - /// - /// minimum pixel location, horizontally or vertically, to consider - /// - /// maximum pixel location, horizontally or vertically, to consider - /// - /// if true, we're scanning left-right, instead of up-down - /// - /// int[] with start and end of found range, or null if no such range is found - /// (e.g. only white was found) - /// - private int[] blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim, bool horizontal) - { - int center = (minDim + maxDim) >> 1; - - // Scan left/up first - int start = center; - while (start >= minDim) - { - if (horizontal ? image[start, fixedDimension] : image[fixedDimension, start]) - { - start--; - } - else - { - int whiteRunStart = start; - do - { - start--; - } - while (start >= minDim && !(horizontal ? image[start, fixedDimension] : image[fixedDimension, start])); - int whiteRunSize = whiteRunStart - start; - if (start < minDim || whiteRunSize > maxWhiteRun) - { - start = whiteRunStart; - break; - } - } - } - start++; - - // Then try right/down - int end = center; - while (end < maxDim) - { - if (horizontal ? image[end, fixedDimension] : image[fixedDimension, end]) - { - end++; - } - else - { - int whiteRunStart = end; - do - { - end++; - } - while (end < maxDim && !(horizontal ? image[end, fixedDimension] : image[fixedDimension, end])); - int whiteRunSize = end - whiteRunStart; - if (end >= maxDim || whiteRunSize > maxWhiteRun) - { - end = whiteRunStart; - break; - } - } - } - end--; - - return end > start ? new int[] { start, end } : null; - } - } -} \ No newline at end of file diff --git a/shadowsocks-csharp/3rd/zxing/common/detector/WhiteRectangleDetector.cs b/shadowsocks-csharp/3rd/zxing/common/detector/WhiteRectangleDetector.cs deleted file mode 100755 index 9a4d4cd2..00000000 --- a/shadowsocks-csharp/3rd/zxing/common/detector/WhiteRectangleDetector.cs +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Copyright 2010 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; - -namespace ZXing.Common.Detector -{ - /// - /// Detects a candidate barcode-like rectangular region within an image. It - /// starts around the center of the image, increases the size of the candidate - /// region until it finds a white rectangular region. By keeping track of the - /// last black points it encountered, it determines the corners of the barcode. - /// - /// David Olivier - public sealed class WhiteRectangleDetector - { - private const int INIT_SIZE = 10; - private const int CORR = 1; - - private readonly BitMatrix image; - private readonly int height; - private readonly int width; - private readonly int leftInit; - private readonly int rightInit; - private readonly int downInit; - private readonly int upInit; - - /// - /// Creates a WhiteRectangleDetector instance - /// - /// The image. - /// null, if image is too small, otherwise a WhiteRectangleDetector instance - public static WhiteRectangleDetector Create(BitMatrix image) - { - if (image == null) - return null; - - var instance = new WhiteRectangleDetector(image); - - if (instance.upInit < 0 || instance.leftInit < 0 || instance.downInit >= instance.height || instance.rightInit >= instance.width) - { - return null; - } - - return instance; - } - - /// - /// Creates a WhiteRectangleDetector instance - /// - /// The image. - /// Size of the init. - /// The x. - /// The y. - /// - /// null, if image is too small, otherwise a WhiteRectangleDetector instance - /// - public static WhiteRectangleDetector Create(BitMatrix image, int initSize, int x, int y) - { - var instance = new WhiteRectangleDetector(image, initSize, x, y); - - if (instance.upInit < 0 || instance.leftInit < 0 || instance.downInit >= instance.height || instance.rightInit >= instance.width) - { - return null; - } - - return instance; - } - - - /// - /// Initializes a new instance of the class. - /// - /// The image. - /// if image is too small - internal WhiteRectangleDetector(BitMatrix image) - : this(image, INIT_SIZE, image.Width/2, image.Height/2) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image. - /// Size of the init. - /// The x. - /// The y. - internal WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y) - { - this.image = image; - height = image.Height; - width = image.Width; - int halfsize = initSize / 2; - leftInit = x - halfsize; - rightInit = x + halfsize; - upInit = y - halfsize; - downInit = y + halfsize; - } - - /// - /// Detects a candidate barcode-like rectangular region within an image. It - /// starts around the center of the image, increases the size of the candidate - /// region until it finds a white rectangular region. - /// - /// [] describing the corners of the rectangular - /// region. The first and last points are opposed on the diagonal, as - /// are the second and third. The first point will be the topmost - /// point and the last, the bottommost. The second point will be - /// leftmost and the third, the rightmost - public ResultPoint[] detect() - { - int left = leftInit; - int right = rightInit; - int up = upInit; - int down = downInit; - bool sizeExceeded = false; - bool aBlackPointFoundOnBorder = true; - bool atLeastOneBlackPointFoundOnBorder = false; - - bool atLeastOneBlackPointFoundOnRight = false; - bool atLeastOneBlackPointFoundOnBottom = false; - bool atLeastOneBlackPointFoundOnLeft = false; - bool atLeastOneBlackPointFoundOnTop = false; - - while (aBlackPointFoundOnBorder) - { - - aBlackPointFoundOnBorder = false; - - // ..... - // . | - // ..... - bool rightBorderNotWhite = true; - while ((rightBorderNotWhite || !atLeastOneBlackPointFoundOnRight) && right < width) - { - rightBorderNotWhite = containsBlackPoint(up, down, right, false); - if (rightBorderNotWhite) - { - right++; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnRight = true; - } - else if (!atLeastOneBlackPointFoundOnRight) - { - right++; - } - } - - if (right >= width) - { - sizeExceeded = true; - break; - } - - // ..... - // . . - // .___. - bool bottomBorderNotWhite = true; - while ((bottomBorderNotWhite || !atLeastOneBlackPointFoundOnBottom) && down < height) - { - bottomBorderNotWhite = containsBlackPoint(left, right, down, true); - if (bottomBorderNotWhite) - { - down++; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnBottom = true; - } - else if (!atLeastOneBlackPointFoundOnBottom) - { - down++; - } - } - - if (down >= height) - { - sizeExceeded = true; - break; - } - - // ..... - // | . - // ..... - bool leftBorderNotWhite = true; - while ((leftBorderNotWhite || !atLeastOneBlackPointFoundOnLeft) && left >= 0) - { - leftBorderNotWhite = containsBlackPoint(up, down, left, false); - if (leftBorderNotWhite) - { - left--; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnLeft = true; - } - else if (!atLeastOneBlackPointFoundOnLeft) - { - left--; - } - } - - if (left < 0) - { - sizeExceeded = true; - break; - } - - // .___. - // . . - // ..... - bool topBorderNotWhite = true; - while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) - { - topBorderNotWhite = containsBlackPoint(left, right, up, true); - if (topBorderNotWhite) - { - up--; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnTop = true; - } - else if (!atLeastOneBlackPointFoundOnTop) - { - up--; - } - } - - if (up < 0) - { - sizeExceeded = true; - break; - } - - if (aBlackPointFoundOnBorder) - { - atLeastOneBlackPointFoundOnBorder = true; - } - - } - - if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) - { - - int maxSize = right - left; - - ResultPoint z = null; - for (int i = 1; i < maxSize; i++) - { - z = getBlackPointOnSegment(left, down - i, left + i, down); - if (z != null) - { - break; - } - } - - if (z == null) - { - return null; - } - - ResultPoint t = null; - //go down right - for (int i = 1; i < maxSize; i++) - { - t = getBlackPointOnSegment(left, up + i, left + i, up); - if (t != null) - { - break; - } - } - - if (t == null) - { - return null; - } - - ResultPoint x = null; - //go down left - for (int i = 1; i < maxSize; i++) - { - x = getBlackPointOnSegment(right, up + i, right - i, up); - if (x != null) - { - break; - } - } - - if (x == null) - { - return null; - } - - ResultPoint y = null; - //go up left - for (int i = 1; i < maxSize; i++) - { - y = getBlackPointOnSegment(right, down - i, right - i, down); - if (y != null) - { - break; - } - } - - if (y == null) - { - return null; - } - - return centerEdges(y, z, x, t); - - } - else - { - return null; - } - } - - private ResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY) - { - int dist = MathUtils.round(MathUtils.distance(aX, aY, bX, bY)); - float xStep = (bX - aX) / dist; - float yStep = (bY - aY) / dist; - - for (int i = 0; i < dist; i++) - { - int x = MathUtils.round(aX + i * xStep); - int y = MathUtils.round(aY + i * yStep); - if (image[x, y]) - { - return new ResultPoint(x, y); - } - } - return null; - } - - /// - /// recenters the points of a constant distance towards the center - /// - /// bottom most point - /// left most point - /// right most point - /// top most point - /// [] describing the corners of the rectangular - /// region. The first and last points are opposed on the diagonal, as - /// are the second and third. The first point will be the topmost - /// point and the last, the bottommost. The second point will be - /// leftmost and the third, the rightmost - private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z, - ResultPoint x, ResultPoint t) - { - // - // t t - // z x - // x OR z - // y y - // - - float yi = y.X; - float yj = y.Y; - float zi = z.X; - float zj = z.Y; - float xi = x.X; - float xj = x.Y; - float ti = t.X; - float tj = t.Y; - - if (yi < width / 2.0f) - { - return new[] - { - new ResultPoint(ti - CORR, tj + CORR), - new ResultPoint(zi + CORR, zj + CORR), - new ResultPoint(xi - CORR, xj - CORR), - new ResultPoint(yi + CORR, yj - CORR) - }; - } - else - { - return new[] - { - new ResultPoint(ti + CORR, tj + CORR), - new ResultPoint(zi + CORR, zj - CORR), - new ResultPoint(xi - CORR, xj + CORR), - new ResultPoint(yi - CORR, yj - CORR) - }; - } - } - - /// - /// Determines whether a segment contains a black point - /// - /// min value of the scanned coordinate - /// max value of the scanned coordinate - /// value of fixed coordinate - /// set to true if scan must be horizontal, false if vertical - /// - /// true if a black point has been found, else false. - /// - private bool containsBlackPoint(int a, int b, int @fixed, bool horizontal) - { - if (horizontal) - { - for (int x = a; x <= b; x++) - { - if (image[x, @fixed]) - { - return true; - } - } - } - else - { - for (int y = a; y <= b; y++) - { - if (image[@fixed, y]) - { - return true; - } - } - } - return false; - } - } -} \ No newline at end of file diff --git a/shadowsocks-csharp/3rd/zxing/net2.0/Action.cs b/shadowsocks-csharp/3rd/zxing/net2.0/Action.cs deleted file mode 100755 index 88601bc1..00000000 --- a/shadowsocks-csharp/3rd/zxing/net2.0/Action.cs +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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. - */ - -namespace ZXing -{ -#if !WindowsCE - /// - /// for compatibility with .net 4.0 - /// - public delegate void Action(); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The param1. - public delegate void Action(T1 param1); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The param1. - /// The param2. - public delegate void Action(T1 param1, T2 param2); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the 3. - /// The param1. - /// The param2. - /// The param3. - public delegate void Action(T1 param1, T2 param2, T3 param3); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the 3. - /// The type of the 4. - /// The param1. - /// The param2. - /// The param3. - /// The param4. - public delegate void Action(T1 param1, T2 param2, T3 param3, T4 param4); -#else - /// - /// for compatibility with .net 4.0 - /// - public delegate void Action(); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The param1. - public delegate void Action(T1 param1); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The param1. - /// The param2. - public delegate void Action(T1 param1, T2 param2); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the 3. - /// The param1. - /// The param2. - /// The param3. - public delegate void Action(T1 param1, T2 param2, T3 param3); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the 3. - /// The type of the 4. - /// The param1. - /// The param2. - /// The param3. - /// The param4. - public delegate void Action(T1 param1, T2 param2, T3 param3, T4 param4); -#endif -} \ No newline at end of file diff --git a/shadowsocks-csharp/3rd/zxing/net2.0/Func.cs b/shadowsocks-csharp/3rd/zxing/net2.0/Func.cs deleted file mode 100755 index 2b2388f1..00000000 --- a/shadowsocks-csharp/3rd/zxing/net2.0/Func.cs +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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. - */ - -namespace ZXing -{ -#if !WindowsCE - /// - /// for compatibility with .net 4.0 - /// - /// The type of the result. - /// - public delegate TResult Func(); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the result. - /// The param1. - /// - public delegate TResult Func(T1 param1); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the result. - /// The param1. - /// The param2. - /// - public delegate TResult Func(T1 param1, T2 param2); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the 3. - /// The type of the result. - /// The param1. - /// The param2. - /// The param3. - /// - public delegate TResult Func(T1 param1, T2 param2, T3 param3); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the 3. - /// The type of the 4. - /// The type of the result. - /// The param1. - /// The param2. - /// The param3. - /// The param4. - /// - public delegate TResult Func(T1 param1, T2 param2, T3 param3, T4 param4); -#else - /// - /// for compatibility with .net 4.0 - /// - /// The type of the result. - /// - public delegate TResult Func(); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the result. - /// The param1. - /// - public delegate TResult Func(T1 param1); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the result. - /// The param1. - /// The param2. - /// - public delegate TResult Func(T1 param1, T2 param2); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the 3. - /// The type of the result. - /// The param1. - /// The param2. - /// The param3. - /// - public delegate TResult Func(T1 param1, T2 param2, T3 param3); - /// - /// for compatibility with .net 4.0 - /// - /// The type of the 1. - /// The type of the 2. - /// The type of the 3. - /// The type of the 4. - /// The type of the result. - /// The param1. - /// The param2. - /// The param3. - /// The param4. - /// - public delegate TResult Func(T1 param1, T2 param2, T3 param3, T4 param4); -#endif -} \ No newline at end of file diff --git a/shadowsocks-csharp/3rd/zxing/net2.0/TimeZoneInfo.cs b/shadowsocks-csharp/3rd/zxing/net2.0/TimeZoneInfo.cs deleted file mode 100755 index c96f52c2..00000000 --- a/shadowsocks-csharp/3rd/zxing/net2.0/TimeZoneInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -namespace System -{ - internal class TimeZoneInfo - { - internal static TimeZoneInfo Local = null; - - internal static DateTime ConvertTime(DateTime dateTime, TimeZoneInfo destinationTimeZone) - { - // TODO: fix it for .net 2.0 - return dateTime; - } - } -} diff --git a/shadowsocks-csharp/3rd/zxing/qrcode/QRCodeReader.cs b/shadowsocks-csharp/3rd/zxing/qrcode/QRCodeReader.cs index d4fcc770..597797bc 100755 --- a/shadowsocks-csharp/3rd/zxing/qrcode/QRCodeReader.cs +++ b/shadowsocks-csharp/3rd/zxing/qrcode/QRCodeReader.cs @@ -26,7 +26,7 @@ namespace ZXing.QrCode /// This implementation can detect and decode QR Codes in an image. /// Sean Owen /// - public class QRCodeReader : Reader + public class QRCodeReader { private static readonly ResultPoint[] NO_POINTS = new ResultPoint[0]; diff --git a/shadowsocks-csharp/3rd/zxing/qrcode/encoder/QrCodeEncodingOptions.cs b/shadowsocks-csharp/3rd/zxing/qrcode/encoder/QrCodeEncodingOptions.cs deleted file mode 100755 index 41e87a08..00000000 --- a/shadowsocks-csharp/3rd/zxing/qrcode/encoder/QrCodeEncodingOptions.cs +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 ZXing.Common; -using ZXing.QrCode.Internal; - -namespace ZXing.QrCode -{ - /// - /// The class holds the available options for the QrCodeWriter - /// - [Serializable] - public class QrCodeEncodingOptions : EncodingOptions - { - /// - /// Specifies what degree of error correction to use, for example in QR Codes. - /// Type depends on the encoder. For example for QR codes it's type - /// {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}. - /// - public ErrorCorrectionLevel ErrorCorrection - { - get - { - if (Hints.ContainsKey(EncodeHintType.ERROR_CORRECTION)) - { - return (ErrorCorrectionLevel) Hints[EncodeHintType.ERROR_CORRECTION]; - } - return null; - } - set - { - if (value == null) - { - if (Hints.ContainsKey(EncodeHintType.ERROR_CORRECTION)) - Hints.Remove(EncodeHintType.ERROR_CORRECTION); - } - else - { - Hints[EncodeHintType.ERROR_CORRECTION] = value; - } - } - } - - /// - /// Specifies what character encoding to use where applicable (type {@link String}) - /// - public string CharacterSet - { - get - { - if (Hints.ContainsKey(EncodeHintType.CHARACTER_SET)) - { - return (string) Hints[EncodeHintType.CHARACTER_SET]; - } - return null; - } - set - { - if (value == null) - { - if (Hints.ContainsKey(EncodeHintType.CHARACTER_SET)) - Hints.Remove(EncodeHintType.CHARACTER_SET); - } - else - { - Hints[EncodeHintType.CHARACTER_SET] = value; - } - } - } - - /// - /// Explicitly disables ECI segment when generating QR Code - /// That is against the specification of QR Code but some - /// readers have problems if the charset is switched from - /// ISO-8859-1 (default) to UTF-8 with the necessary ECI segment. - /// If you set the property to true you can use UTF-8 encoding - /// and the ECI segment is omitted. - /// - public bool DisableECI - { - get - { - if (Hints.ContainsKey(EncodeHintType.DISABLE_ECI)) - { - return (bool)Hints[EncodeHintType.DISABLE_ECI]; - } - return false; - } - set - { - Hints[EncodeHintType.DISABLE_ECI] = value; - } - } - } -} diff --git a/shadowsocks-csharp/View/QRCodeForm.Designer.cs b/shadowsocks-csharp/View/QRCodeForm.Designer.cs index d334c761..ca0a0006 100755 --- a/shadowsocks-csharp/View/QRCodeForm.Designer.cs +++ b/shadowsocks-csharp/View/QRCodeForm.Designer.cs @@ -37,7 +37,7 @@ this.pictureBox1.Location = new System.Drawing.Point(10, 10); this.pictureBox1.Margin = new System.Windows.Forms.Padding(0); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(240, 240); + this.pictureBox1.Size = new System.Drawing.Size(210, 210); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.pictureBox1.TabIndex = 1; this.pictureBox1.TabStop = false; diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index d132e788..cd5b2683 100755 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -80,14 +80,10 @@ - - - - @@ -100,9 +96,6 @@ - - - @@ -125,11 +118,8 @@ - - -