vips-cpp 8.16 libvips C++ binding

Loading...
Searching...
No Matches
VRegion8.h
1// VIPS region wrapper
2
3/*
4
5 This file is part of VIPS.
6
7 VIPS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301 USA
21
22 */
23
24/*
25
26 These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
27
28 */
29
30#ifndef VIPS_VREGION_H
31#define VIPS_VREGION_H
32
33#include <vips/vips.h>
34
35VIPS_NAMESPACE_START
36
40 class VRegion : public VObject {
41 public:
47 explicit VRegion(VipsRegion *region, VSteal steal = STEAL)
48 : VObject((VipsObject *) region, steal)
49 {
50 }
51
55 static VRegion
56 new_from_image(VImage image);
57
61 VipsRegion *
62 get_region() const
63 {
64 return (VipsRegion *) VObject::get_object();
65 }
66
70 void
71 prepare(const VipsRect *rect) const
72 {
73 if (vips_region_prepare(get_region(), rect))
74 throw VError();
75 }
76
80 void
81 prepare(int left, int top, int width, int height) const
82 {
83 VipsRect rect = { left, top, width, height };
84
85 prepare(&rect);
86 }
87
91 VipsRect
92 valid() const
93 {
94 return get_region()->valid;
95 }
96
100 VipsPel *
101 addr() const
102 {
103 return addr(0);
104 }
105
109 VipsPel *
110 addr(size_t i) const
111 {
112 return &VIPS_REGION_ADDR_TOPLEFT(get_region())[i];
113 }
114
118 VipsPel *
119 addr(int x, int y) const
120 {
121 return VIPS_REGION_ADDR(get_region(), x, y);
122 }
123
127 size_t
128 stride() const
129 {
130 return VIPS_REGION_LSKIP(get_region());
131 }
132
136 VipsPel
137 operator[](size_t i) const
138 {
139 return *addr(i);
140 }
141
145 VipsPel
146 operator()(int x, int y) const
147 {
148 return *addr(x, y);
149 }
150};
151
152VIPS_NAMESPACE_END
153
154#endif /*VIPS_VREGION_H*/
VError
Definition VError8.h:45
VImage
Definition VImage8.h:398
VObject
Definition VImage8.h:67
VObject::get_object
VipsObject * get_object() const
Definition VImage8.h:170
VRegion
Definition VRegion8.h:40
VRegion::addr
VipsPel * addr(size_t i) const
Definition VRegion8.h:110
VRegion::stride
size_t stride() const
Definition VRegion8.h:128
VRegion::valid
VipsRect valid() const
Definition VRegion8.h:92
VRegion::addr
VipsPel * addr() const
Definition VRegion8.h:101
VRegion::operator()
VipsPel operator()(int x, int y) const
Definition VRegion8.h:146
VRegion::VRegion
VRegion(VipsRegion *region, VSteal steal=STEAL)
Definition VRegion8.h:47
VRegion::prepare
void prepare(const VipsRect *rect) const
Definition VRegion8.h:71
VRegion::get_region
VipsRegion * get_region() const
Definition VRegion8.h:62
VRegion::operator[]
VipsPel operator[](size_t i) const
Definition VRegion8.h:137
VRegion::addr
VipsPel * addr(int x, int y) const
Definition VRegion8.h:119
VRegion::prepare
void prepare(int left, int top, int width, int height) const
Definition VRegion8.h:81
VRegion::new_from_image
static VRegion new_from_image(VImage image)
Definition VRegion.cpp:14