Beatmup
image_resolution.h
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2019, lnstadrum
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 #pragma once
20 #include "../basic_types.h"
21 #include "../geometry.h"
22 
23 
24 namespace Beatmup {
25  /**
26  Represents image size in pixels.
27  */
29  private:
30  unsigned int width, height; //!< width and height in pixels
31  public:
33  ImageResolution(unsigned int width, unsigned int height);
34 
35  bool operator==(const ImageResolution&) const;
36  bool operator!=(const ImageResolution&) const;
37  msize numPixels() const;
38  float megaPixels() const;
39  float getAspectRatio() const;
40  float getInvAspectRatio() const;
41 
42  /**
43  \return `true` if the image width is greater than the height.
44  */
45  bool fat() const;
46 
48  return IntRectangle(0, 0, width - 1, height - 1);
49  }
51  return IntRectangle(0, 0, width, height);
52  }
53 
54  unsigned int getWidth() const { return width; }
55  unsigned int getHeight() const { return height; }
56 
57  void set(unsigned int width, unsigned int height);
58 
59  operator IntPoint() const { return IntPoint(width, height); }
60  };
61 }
Represents image size in pixels.
unsigned int height
width and height in pixels
unsigned int getWidth() const
bool operator==(const ImageResolution &) const
void set(unsigned int width, unsigned int height)
IntRectangle halfOpenedRectangle() const
bool operator!=(const ImageResolution &) const
unsigned int getHeight() const
IntRectangle closedRectangle() const
uint32_t msize
memory size
Definition: basic_types.h:30
CustomRectangle< int > IntRectangle
Definition: geometry.h:630
CustomPoint< int > IntPoint
Definition: geometry.h:629