remove some class
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementations of this interface can decode an image of a barcode in some format into
|
||||
/// the String it encodes. For example, <see cref="ZXing.QrCode.QRCodeReader" /> can
|
||||
/// decode a QR code. The decoder may optionally receive hints from the caller which may help
|
||||
/// it decode more quickly or accurately.
|
||||
///
|
||||
/// See <see cref="MultiFormatReader" />, which attempts to determine what barcode
|
||||
/// format is present within the image as well, and then decodes it accordingly.
|
||||
/// </summary>
|
||||
/// <author>Sean Owen</author>
|
||||
/// <author>dswitkin@google.com (Daniel Switkin)</author>
|
||||
public interface Reader
|
||||
{
|
||||
/// <summary>
|
||||
/// Locates and decodes a barcode in some format within an image.
|
||||
/// </summary>
|
||||
/// <param name="image">image of barcode to decode</param>
|
||||
/// <returns>String which the barcode encodes</returns>
|
||||
Result decode(BinaryBitmap image);
|
||||
|
||||
/// <summary> 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.
|
||||
/// </summary>
|
||||
/// <param name="image">image of barcode to decode</param>
|
||||
/// <param name="hints">passed as a <see cref="IDictionary{TKey, TValue}" /> from <see cref="DecodeHintType" />
|
||||
/// to arbitrary data. The
|
||||
/// meaning of the data depends upon the hint type. The implementation may or may not do
|
||||
/// anything with these hints.
|
||||
/// </param>
|
||||
/// <returns>String which the barcode encodes</returns>
|
||||
Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints);
|
||||
|
||||
/// <summary>
|
||||
/// Resets any internal state the implementation has after a decode, to prepare it
|
||||
/// for reuse.
|
||||
/// </summary>
|
||||
void reset();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <author>Sean Owen</author>
|
||||
[Serializable]
|
||||
public class ReaderException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance.
|
||||
/// </summary>
|
||||
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<String,Integer> throwers = new HashMap<String,Integer>(32);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReaderException"/> class.
|
||||
/// </summary>
|
||||
protected ReaderException()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an container for encoder options
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DecodingOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the data container for all options
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public IDictionary<DecodeHintType, object> Hints { get; private set; }
|
||||
|
||||
[field: NonSerialized]
|
||||
public event Action<object, EventArgs> ValueChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a flag which cause a deeper look into the bitmap
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if [try harder]; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Image is a pure monochrome image of a barcode.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if monochrome image of a barcode; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies what character encoding to use when decoding, where applicable (type String)
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The character set.
|
||||
/// </value>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Image is known to be of one of a few possible formats.
|
||||
/// Maps to a {@link java.util.List} of {@link BarcodeFormat}s.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The possible formats.
|
||||
/// </value>
|
||||
public IList<BarcodeFormat> PossibleFormats
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS))
|
||||
return (IList<BarcodeFormat>)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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if Code39 could be detected try to use extended mode for full ASCII character set
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Don't fail if a Code39 is detected but can't be decoded in extended mode.
|
||||
/// Return the raw Code39 result instead. Maps to <see cref="bool" />.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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 <see cref="bool" />.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EncodingOptions"/> class.
|
||||
/// </summary>
|
||||
public DecodingOptions()
|
||||
{
|
||||
var hints = new ChangeNotifyDictionary<DecodeHintType, object>();
|
||||
Hints = hints;
|
||||
UseCode39ExtendedMode = true;
|
||||
UseCode39RelaxedExtendedMode = true;
|
||||
hints.ValueChanged += (o, args) => { if (ValueChanged != null) ValueChanged(this, EventArgs.Empty); };
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
private class ChangeNotifyDictionary<TKey, TValue>: IDictionary<TKey, TValue>
|
||||
{
|
||||
private readonly IDictionary<TKey, TValue> values;
|
||||
|
||||
[field: NonSerialized]
|
||||
public event Action<object, EventArgs> ValueChanged;
|
||||
|
||||
public ChangeNotifyDictionary()
|
||||
{
|
||||
values = new Dictionary<TKey, TValue>();
|
||||
}
|
||||
|
||||
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<TKey> 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<TValue> Values
|
||||
{
|
||||
get { return values.Values; }
|
||||
}
|
||||
|
||||
public TValue this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return values[key];
|
||||
}
|
||||
set
|
||||
{
|
||||
values[key] = value;
|
||||
OnValueChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
values.Add(item);
|
||||
OnValueChanged();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
values.Clear();
|
||||
OnValueChanged();
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
return values.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<TKey, TValue>[] 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<TKey, TValue> item)
|
||||
{
|
||||
var result = values.Remove(item);
|
||||
OnValueChanged();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
|
||||
{
|
||||
return values.GetEnumerator();
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return ((System.Collections.IEnumerable)values).GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an container for encoder options
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class EncodingOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the data container for all options
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public IDictionary<EncodeHintType, object> Hints { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the height of the barcode image
|
||||
/// </summary>
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Hints.ContainsKey(EncodeHintType.HEIGHT))
|
||||
{
|
||||
return (int)Hints[EncodeHintType.HEIGHT];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
Hints[EncodeHintType.HEIGHT] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the width of the barcode image
|
||||
/// </summary>
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Hints.ContainsKey(EncodeHintType.WIDTH))
|
||||
{
|
||||
return (int)Hints[EncodeHintType.WIDTH];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
Hints[EncodeHintType.WIDTH] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Don't put the content string into the output image.
|
||||
/// </summary>
|
||||
public bool PureBarcode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Hints.ContainsKey(EncodeHintType.PURE_BARCODE))
|
||||
{
|
||||
return (bool)Hints[EncodeHintType.PURE_BARCODE];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
Hints[EncodeHintType.PURE_BARCODE] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public int Margin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Hints.ContainsKey(EncodeHintType.MARGIN))
|
||||
{
|
||||
return (int) Hints[EncodeHintType.MARGIN];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
Hints[EncodeHintType.MARGIN] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EncodingOptions"/> class.
|
||||
/// </summary>
|
||||
public EncodingOptions()
|
||||
{
|
||||
Hints = new Dictionary<EncodeHintType, object>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary> <p>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.</p>
|
||||
///
|
||||
/// </summary>
|
||||
/// <author> Sean Owen
|
||||
/// </author>
|
||||
/// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
|
||||
/// </author>
|
||||
public sealed class MonochromeRectangleDetector
|
||||
{
|
||||
private const int MAX_MODULES = 32;
|
||||
|
||||
private BitMatrix image;
|
||||
|
||||
public MonochromeRectangleDetector(BitMatrix image)
|
||||
{
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
/// <summary> <p>Detects a rectangular region of black and white -- mostly black -- with a region of mostly
|
||||
/// white, in an image.</p>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns> {@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
|
||||
/// </returns>
|
||||
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 };
|
||||
}
|
||||
|
||||
/// <summary> 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.
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="centerX">center's x component (horizontal)
|
||||
/// </param>
|
||||
/// <param name="deltaX">same as deltaY but change in x per step instead
|
||||
/// </param>
|
||||
/// <param name="left">minimum value of x
|
||||
/// </param>
|
||||
/// <param name="right">maximum value of x
|
||||
/// </param>
|
||||
/// <param name="centerY">center's y component (vertical)
|
||||
/// </param>
|
||||
/// <param name="deltaY">change in y per step. If scanning up this is negative; down, positive;
|
||||
/// left or right, 0
|
||||
/// </param>
|
||||
/// <param name="top">minimum value of y to search through (meaningless when di == 0)
|
||||
/// </param>
|
||||
/// <param name="bottom">maximum value of y
|
||||
/// </param>
|
||||
/// <param name="maxWhiteRun">maximum run of white pixels that can still be considered to be within
|
||||
/// the barcode
|
||||
/// </param>
|
||||
/// <returns> a {@link com.google.zxing.ResultPoint} encapsulating the corner that was found
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary> Computes the start and end of a region of pixels, either horizontally or vertically, that could
|
||||
/// be part of a Data Matrix barcode.
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="fixedDimension">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
|
||||
/// </param>
|
||||
/// <param name="maxWhiteRun">largest run of white pixels that can still be considered part of the
|
||||
/// barcode region
|
||||
/// </param>
|
||||
/// <param name="minDim">minimum pixel location, horizontally or vertically, to consider
|
||||
/// </param>
|
||||
/// <param name="maxDim">maximum pixel location, horizontally or vertically, to consider
|
||||
/// </param>
|
||||
/// <param name="horizontal">if true, we're scanning left-right, instead of up-down
|
||||
/// </param>
|
||||
/// <returns> int[] with start and end of found range, or null if no such range is found
|
||||
/// (e.g. only white was found)
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <author>David Olivier</author>
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a WhiteRectangleDetector instance
|
||||
/// </summary>
|
||||
/// <param name="image">The image.</param>
|
||||
/// <returns>null, if image is too small, otherwise a WhiteRectangleDetector instance</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a WhiteRectangleDetector instance
|
||||
/// </summary>
|
||||
/// <param name="image">The image.</param>
|
||||
/// <param name="initSize">Size of the init.</param>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
/// <returns>
|
||||
/// null, if image is too small, otherwise a WhiteRectangleDetector instance
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WhiteRectangleDetector"/> class.
|
||||
/// </summary>
|
||||
/// <param name="image">The image.</param>
|
||||
/// <exception cref="ArgumentException">if image is too small</exception>
|
||||
internal WhiteRectangleDetector(BitMatrix image)
|
||||
: this(image, INIT_SIZE, image.Width/2, image.Height/2)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WhiteRectangleDetector"/> class.
|
||||
/// </summary>
|
||||
/// <param name="image">The image.</param>
|
||||
/// <param name="initSize">Size of the init.</param>
|
||||
/// <param name="x">The x.</param>
|
||||
/// <param name="y">The y.</param>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <returns><see cref="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</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// recenters the points of a constant distance towards the center
|
||||
/// </summary>
|
||||
/// <param name="y">bottom most point</param>
|
||||
/// <param name="z">left most point</param>
|
||||
/// <param name="x">right most point</param>
|
||||
/// <param name="t">top most point</param>
|
||||
/// <returns><see cref="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</returns>
|
||||
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)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a segment contains a black point
|
||||
/// </summary>
|
||||
/// <param name="a">min value of the scanned coordinate</param>
|
||||
/// <param name="b">max value of the scanned coordinate</param>
|
||||
/// <param name="fixed">value of fixed coordinate</param>
|
||||
/// <param name="horizontal">set to true if scan must be horizontal, false if vertical</param>
|
||||
/// <returns>
|
||||
/// true if a black point has been found, else false.
|
||||
/// </returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
public delegate void Action();
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
public delegate void Action<in T1>(T1 param1);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
public delegate void Action<in T1, in T2>(T1 param1, T2 param2);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="T3">The type of the 3.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <param name="param3">The param3.</param>
|
||||
public delegate void Action<in T1, in T2, in T3>(T1 param1, T2 param2, T3 param3);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="T3">The type of the 3.</typeparam>
|
||||
/// <typeparam name="T4">The type of the 4.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <param name="param3">The param3.</param>
|
||||
/// <param name="param4">The param4.</param>
|
||||
public delegate void Action<in T1, in T2, in T3, in T4>(T1 param1, T2 param2, T3 param3, T4 param4);
|
||||
#else
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
public delegate void Action();
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
public delegate void Action<T1>(T1 param1);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
public delegate void Action<T1, T2>(T1 param1, T2 param2);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="T3">The type of the 3.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <param name="param3">The param3.</param>
|
||||
public delegate void Action<T1, T2, T3>(T1 param1, T2 param2, T3 param3);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="T3">The type of the 3.</typeparam>
|
||||
/// <typeparam name="T4">The type of the 4.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <param name="param3">The param3.</param>
|
||||
/// <param name="param4">The param4.</param>
|
||||
public delegate void Action<T1, T2, T3, T4>(T1 param1, T2 param2, T3 param3, T4 param4);
|
||||
#endif
|
||||
}
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<out TResult>();
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<in T1, out TResult>(T1 param1);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<in T1, in T2, out TResult>(T1 param1, T2 param2);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="T3">The type of the 3.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <param name="param3">The param3.</param>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<in T1, in T2, in T3, out TResult>(T1 param1, T2 param2, T3 param3);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="T3">The type of the 3.</typeparam>
|
||||
/// <typeparam name="T4">The type of the 4.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <param name="param3">The param3.</param>
|
||||
/// <param name="param4">The param4.</param>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, out TResult>(T1 param1, T2 param2, T3 param3, T4 param4);
|
||||
#else
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<TResult>();
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<T1, TResult>(T1 param1);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<T1, T2, TResult>(T1 param1, T2 param2);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="T3">The type of the 3.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <param name="param3">The param3.</param>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<T1, T2, T3, TResult>(T1 param1, T2 param2, T3 param3);
|
||||
/// <summary>
|
||||
/// for compatibility with .net 4.0
|
||||
/// </summary>
|
||||
/// <typeparam name="T1">The type of the 1.</typeparam>
|
||||
/// <typeparam name="T2">The type of the 2.</typeparam>
|
||||
/// <typeparam name="T3">The type of the 3.</typeparam>
|
||||
/// <typeparam name="T4">The type of the 4.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the result.</typeparam>
|
||||
/// <param name="param1">The param1.</param>
|
||||
/// <param name="param2">The param2.</param>
|
||||
/// <param name="param3">The param3.</param>
|
||||
/// <param name="param4">The param4.</param>
|
||||
/// <returns></returns>
|
||||
public delegate TResult Func<T1, T2, T3, T4, TResult>(T1 param1, T2 param2, T3 param3, T4 param4);
|
||||
#endif
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace ZXing.QrCode
|
||||
/// This implementation can detect and decode QR Codes in an image.
|
||||
/// <author>Sean Owen</author>
|
||||
/// </summary>
|
||||
public class QRCodeReader : Reader
|
||||
public class QRCodeReader
|
||||
{
|
||||
private static readonly ResultPoint[] NO_POINTS = new ResultPoint[0];
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The class holds the available options for the QrCodeWriter
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class QrCodeEncodingOptions : EncodingOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 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}.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies what character encoding to use where applicable (type {@link String})
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public bool DisableECI
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Hints.ContainsKey(EncodeHintType.DISABLE_ECI))
|
||||
{
|
||||
return (bool)Hints[EncodeHintType.DISABLE_ECI];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
Hints[EncodeHintType.DISABLE_ECI] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -80,14 +80,10 @@
|
||||
<Compile Include="3rd\zxing\common\BitSource.cs" />
|
||||
<Compile Include="3rd\zxing\common\CharacterSetECI.cs" />
|
||||
<Compile Include="3rd\zxing\common\DecoderResult.cs" />
|
||||
<Compile Include="3rd\zxing\common\DecodingOptions.cs" />
|
||||
<Compile Include="3rd\zxing\common\DefaultGridSampler.cs" />
|
||||
<Compile Include="3rd\zxing\common\DetectorResult.cs" />
|
||||
<Compile Include="3rd\zxing\common\detector\MathUtils.cs" />
|
||||
<Compile Include="3rd\zxing\common\detector\MonochromeRectangleDetector.cs" />
|
||||
<Compile Include="3rd\zxing\common\detector\WhiteRectangleDetector.cs" />
|
||||
<Compile Include="3rd\zxing\common\ECI.cs" />
|
||||
<Compile Include="3rd\zxing\common\EncodingOptions.cs" />
|
||||
<Compile Include="3rd\zxing\common\GlobalHistogramBinarizer.cs" />
|
||||
<Compile Include="3rd\zxing\common\GridSampler.cs" />
|
||||
<Compile Include="3rd\zxing\common\HybridBinarizer.cs" />
|
||||
@@ -100,9 +96,6 @@
|
||||
<Compile Include="3rd\zxing\DecodeHintType.cs" />
|
||||
<Compile Include="3rd\zxing\EncodeHintType.cs" />
|
||||
<Compile Include="3rd\zxing\LuminanceSource.cs" />
|
||||
<Compile Include="3rd\zxing\net2.0\Action.cs" />
|
||||
<Compile Include="3rd\zxing\net2.0\Func.cs" />
|
||||
<Compile Include="3rd\zxing\net2.0\TimeZoneInfo.cs" />
|
||||
<Compile Include="3rd\zxing\qrcode\decoder\BitMatrixParser.cs" />
|
||||
<Compile Include="3rd\zxing\qrcode\decoder\DataBlock.cs" />
|
||||
<Compile Include="3rd\zxing\qrcode\decoder\DataMask.cs" />
|
||||
@@ -125,11 +118,8 @@
|
||||
<Compile Include="3rd\zxing\qrcode\encoder\MaskUtil.cs" />
|
||||
<Compile Include="3rd\zxing\qrcode\encoder\MatrixUtil.cs" />
|
||||
<Compile Include="3rd\zxing\qrcode\encoder\QRCode.cs" />
|
||||
<Compile Include="3rd\zxing\qrcode\encoder\QrCodeEncodingOptions.cs" />
|
||||
<Compile Include="3rd\SimpleJson.cs" />
|
||||
<Compile Include="3rd\zxing\qrcode\QRCodeReader.cs" />
|
||||
<Compile Include="3rd\zxing\Reader.cs" />
|
||||
<Compile Include="3rd\zxing\ReaderException.cs" />
|
||||
<Compile Include="3rd\zxing\Result.cs" />
|
||||
<Compile Include="3rd\zxing\ResultMetadataType.cs" />
|
||||
<Compile Include="3rd\zxing\ResultPoint.cs" />
|
||||
|
||||
Reference in New Issue
Block a user