Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fxbarcode / src / include / BC_DataMatrixDetector.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _BC_DATAMATRIXDETECTOR_H_\r
8 #define _BC_DATAMATRIXDETECTOR_H_\r
9 class CBC_CommonBitMatrix;\r
10 class CBC_WhiteRectangleDetector;\r
11 class CBC_ResultPoint;\r
12 class CBC_QRDetectorResult;\r
13 class CBC_DataMatrixDetector;\r
14 class ResultPointsAndTransitions;\r
15 class CBC_ResultPointsAndTransitions : public CFX_Object\r
16 {\r
17 public:\r
18     CBC_ResultPointsAndTransitions(CBC_ResultPoint *from, CBC_ResultPoint *to, FX_INT32 transitions)\r
19     {\r
20         m_from = from;\r
21         m_to = to;\r
22         m_transitions = transitions;\r
23     }\r
24     ~CBC_ResultPointsAndTransitions()\r
25     {\r
26     }\r
27     CBC_ResultPoint *GetFrom()\r
28     {\r
29         return m_from;\r
30     }\r
31     CBC_ResultPoint *GetTo()\r
32     {\r
33         return m_to;\r
34     }\r
35     FX_INT32 GetTransitions()\r
36     {\r
37         return m_transitions;\r
38     }\r
39 private:\r
40     CBC_ResultPoint *m_from;\r
41     CBC_ResultPoint *m_to;\r
42     FX_INT32 m_transitions;\r
43 };\r
44 class CBC_DataMatrixDetector\r
45 {\r
46 public:\r
47     CBC_DataMatrixDetector(CBC_CommonBitMatrix *image);\r
48     virtual ~CBC_DataMatrixDetector();\r
49     CBC_QRDetectorResult *Detect(FX_INT32 &e);\r
50     CBC_ResultPoint *CorrectTopRightRectangular(CBC_ResultPoint *bottomLeft,\r
51             CBC_ResultPoint *bottomRight,\r
52             CBC_ResultPoint *topLeft,\r
53             CBC_ResultPoint *topRight,\r
54             FX_INT32 dimensionTop, FX_INT32 dimensionRight);\r
55     CBC_ResultPoint *CorrectTopRight(CBC_ResultPoint *bottomLeft,\r
56                                      CBC_ResultPoint *bottomRight,\r
57                                      CBC_ResultPoint *topLeft,\r
58                                      CBC_ResultPoint *topRight,\r
59                                      FX_INT32 dimension);\r
60     CBC_CommonBitMatrix *SampleGrid(CBC_CommonBitMatrix *image,\r
61                                     CBC_ResultPoint *topLeft,\r
62                                     CBC_ResultPoint *bottomLeft,\r
63                                     CBC_ResultPoint *bottomRight,\r
64                                     CBC_ResultPoint *topRight,\r
65                                     FX_INT32 dimensionX, FX_INT32 dimensionY, FX_INT32 &e);\r
66     CBC_ResultPointsAndTransitions *TransitionsBetween(CBC_ResultPoint *from, CBC_ResultPoint *to);\r
67     FX_BOOL IsValid(CBC_ResultPoint *p);\r
68     FX_INT32 Distance(CBC_ResultPoint *a, CBC_ResultPoint *b);\r
69     void Increment(CFX_MapPtrTemplate<CBC_ResultPoint*, FX_INT32> &table, CBC_ResultPoint *key);\r
70     FX_INT32 Round(FX_FLOAT d);\r
71     void OrderBestPatterns(CFX_PtrArray *patterns);\r
72     virtual void Init(FX_INT32 &e);\r
73 private:\r
74     CBC_CommonBitMatrix *m_image;\r
75     CBC_WhiteRectangleDetector *m_rectangleDetector;\r
76     const static FX_INT32 INTEGERS[5];\r
77 };\r
78 #endif\r