forked from funkey/gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHorizontalFlip.h
60 lines (37 loc) · 1002 Bytes
/
HorizontalFlip.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef HORIZONTAL_FLIP_H__
#define HORIZONTAL_FLIP_H__
#include <boost/concept_check.hpp>
#include <gui/IsImage.h>
namespace gui {
namespace detail {
/**
* Image wrapper to flip the content of an image horizontally.
*/
template <typename Image>
class horizontal_flip_impl {
public:
typedef horizontal_flip_impl<Image> type;
typedef typename Image::value_type value_type;
horizontal_flip_impl(const Image& ra) :
_ra(ra) {}
const value_type& operator()(unsigned int x, unsigned int y) const {
return _ra(x, _ra.height() - 1 - y);
}
const unsigned int width() const {
return _ra.width();
}
const unsigned int height() const {
return _ra.height();
}
private:
const Image& _ra;
};
} // namespace detail
template <typename Image>
typename detail::horizontal_flip_impl<Image>::type
horizontal_flip(const Image& image) {
BOOST_CONCEPT_ASSERT((IsImage<Image>));
return detail::horizontal_flip_impl<Image>(image);
}
} // namespace gui
#endif // HORIZONTAL_FLIP_H__