1 /*
2     Scan Tailor - Interactive post-processing tool for scanned pages.
3     Copyright (C) 2007-2009  Joseph Artsimovich <joseph_a@mail.ru>
4 
5     This program is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef IMAGEMETADATA_H_
20 #define IMAGEMETADATA_H_
21 
22 #include <QSize>
23 #include "Dpi.h"
24 
25 class ImageMetadata {
26   // Member-wise copying is OK.
27  public:
28   enum DpiStatus { DPI_OK, DPI_UNDEFINED, DPI_TOO_LARGE, DPI_TOO_SMALL, DPI_TOO_SMALL_FOR_THIS_PIXEL_SIZE };
29 
30   ImageMetadata() = default;
31 
ImageMetadata(QSize size,Dpi dpi)32   ImageMetadata(QSize size, Dpi dpi) : m_size(size), m_dpi(dpi) {}
33 
size()34   const QSize& size() const { return m_size; }
35 
setSize(const QSize & size)36   void setSize(const QSize& size) { m_size = size; }
37 
dpi()38   const Dpi& dpi() const { return m_dpi; }
39 
setDpi(const Dpi & dpi)40   void setDpi(const Dpi& dpi) { m_dpi = dpi; }
41 
42   bool isDpiOK() const;
43 
44   DpiStatus horizontalDpiStatus() const;
45 
46   DpiStatus verticalDpiStatus() const;
47 
48   bool operator==(const ImageMetadata& other) const;
49 
50   bool operator!=(const ImageMetadata& other) const { return !(*this == other); }
51 
52  private:
53   static DpiStatus dpiStatus(int pixel_size, int dpi);
54 
55   QSize m_size;
56   Dpi m_dpi;
57 };
58 
59 
60 #endif  // ifndef IMAGEMETADATA_H_
61