SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
size.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4#pragma once
5#include <cstdint>
6#include <ostream>
7
8namespace cv {
9 template<typename _Tp> class Size_;
10 typedef Size_<int> Size;
11}
12
13namespace slideio
14{
15 class Size
16 {
17 public:
18 Size() {
19 width = 0;
20 height = 0;
21 }
22 Size(int32_t _width, int32_t _height) {
23 width = _width;
24 height = _height;
25 }
26 Size(const Size& sz) {
27 width = sz.width;
28 height = sz.height;
29 }
30 Size(Size&& sz) noexcept {
31 width = sz.width;
32 height = sz.height;
33 sz.width = 0;
34 sz.height = 0;
35 }
36 Size(const cv::Size& cvSize);
37 ~Size() = default;
38 Size& operator = (const Size& sz) = default;
39 Size& operator = (Size&& sz) noexcept {
40 if (this != &sz) {
41 width = sz.width;
42 height = sz.height;
43 sz.width = 0;
44 sz.height = 0;
45 }
46 return *this;
47 }
48 Size& operator = (const cv::Size& cvSize);
49 operator cv::Size() const;
50 bool operator == (const Size& other) const {
51 return width == other.width && height == other.height;
52 }
53
54 int32_t area() const {
55 return width * height;
56 }
57 bool empty() const {
58 return width <= 0 || height <= 0;
59 }
60
61 friend std::ostream& operator<<(std::ostream& os, const Size& size) {
62 os << "Size (width: " << size.width << ", height: " << size.height << ")";
63 return os;
64 }
65
66 bool operator!=(const Size& size) const {
67 return !(*this == size);
68 }
69
70 int32_t width;
71 int32_t height;
72 };
73}
74
75#if defined(SLIDEIO_INTERNAL_HEADER)
76#include "size.inl"
77#endif
Definition: exceptions.hpp:15