scantools  1.0.4
Graphics manipulation with a view towards scanned documents
JP2Box.h
1 /*
2  * Copyright © 2017 Stefan Kebekus <stefan.kebekus@math.uni-freiburg.de>
3  *
4  * This program is free software: you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation, either version 3 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #ifndef JP2BOX
20 #define JP2BOX 1
21 
22 #include <QIODevice>
23 
24 
25 /* Data structure used to interpret JP2 and JPX files
26 
27  According to their specification, JP2 and JPX files are organised in
28  'boxes'. This class can be used to read a box and access its content.
29 */
30 
31 class JP2Box
32 {
33  public:
35  JP2Box();
36 
47  JP2Box(QIODevice &device, quint32 TBox=0);
48 
57  JP2Box subBox(quint32 TBox=0);
58 
60  void clear();
61 
63  bool hasError() const {return !error.isEmpty();}
64 
66  bool isNull() const {return TBox == 0;}
67 
69  quint32 TBox{};
70 
72  QByteArray content;
73 
75  QString error;
76 
77  private:
78  void read(QIODevice &device, quint32 TBox=0);
79 };
80 
81 #endif