📄 bars2symean.h
字号:
//
// Given an array of bar code widths read an EAN bar
// code, if present.
//
// Copyright (C) 2006 by Jon A. Webb
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#ifndef Bars2SymEan_h
#define Bars2SymEan_h
#include "Bars2Sym.h"
#include <e32cons.h>
#include <e32math.h>
namespace Barcode
{
class CBars2SymEan: public CBars2Sym
{
// Lifecycle
public:
IMPORT_C static CBars2SymEan* NewL();
~CBars2SymEan(void);
private:
// First-phase constructor
CBars2SymEan();
// Second-phase constructor
void ConstructL();
// Operations
public:
// FindBarsL
// Given a barcode image produce an array
// representing the string encoded, or return false if nothing was found.
//
// Input
// pPositions is an array of bar widths
// Output
// pCode is the decoded string
IMPORT_C bool DecodeL(
Core::CImage image,
CodeType*& pCode);
private:
// DecodeFirstDigit
// Decode the first digit using the UPC lookup table
// and record the digit for use when determining which
// parity to use when decoding other digits.
// bars is the array of bar widths.
// pos is the position of the bars for this digit in the array.
// Returns true if the digit was decoded successfully.
// Returns decoded digit in 'digit'.
bool DecodeFirstDigit(CArrayFix<char>& bars, int pos, TChar& digit);
// DecodeOtherDigits
// Decode the other digits using the appropriate parity table
// from the first digit.
// bars is the array of bar widths.
// pos is the position of the bars for this digit in the array.
// Returns true if the digit was decoded successfully.
// Returns decoded digit in 'digit'.
bool DecodeOtherDigits(CArrayFix<char>& bars, int pos, int digitPos, TChar& digit);
// EncodeBars
// Encodes the four bars starting at position pos in bars
// as a bit pattern for lookup in the iLookup tables.
// Returns the encoded value.
int EncodeBars(CArrayFix<char>& bars, int pos);
// Accessors
public:
const TDesC& Name() const;
private:
// Attributes
// This is the even parity digit lookup table
char iLookupEven[128];
// This is the odd parity digit lookup table
char iLookupOdd[128];
// This is the UPC lookup table (used for first digit)
char iLookupUpc[128];
// this records the first digit
int iFirstDigit;
// this is the mapping from first
// digit and digit position
// to whether this digit uses odd parity or not
bool iParityOdd[10][6];
};
};
#endif // Bars2SymEan_h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -