vips-cpp 8.13
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
40class VRegion : public VObject
41{
42public:
48 VRegion( VipsRegion *region, VSteal steal = STEAL ) :
49 VObject( (VipsObject *) region, steal )
50 {
51 }
52
56 static VRegion
57 new_from_image( VImage image );
58
62 VipsRegion *
63 get_region() const
64 {
65 return (VipsRegion *) VObject::get_object();
66 }
67
71 void
72 prepare( const VipsRect *rect ) const
73 {
74 if ( vips_region_prepare( get_region(), rect ) )
75 throw VError();
76 }
77
81 void
82 prepare( int left, int top, int width, int height ) const
83 {
84 VipsRect rect = { left, top, width, height };
85
86 prepare( &rect );
87 }
88
92 VipsRect
93 valid() const
94 {
95 return get_region()->valid;
96 }
97
101 VipsPel *
102 addr() const
103 {
104 return addr( 0 );
105 }
106
110 VipsPel *
111 addr( size_t i ) const
112 {
113 return &VIPS_REGION_ADDR_TOPLEFT( get_region() )[i];
114 }
115
119 VipsPel *
120 addr( int x, int y ) const
121 {
122 return VIPS_REGION_ADDR( get_region(), x, y );
123 }
124
128 size_t
129 stride() const
130 {
131 return VIPS_REGION_LSKIP( get_region() );
132 }
133
137 VipsPel
138 operator[]( size_t i ) const
139 {
140 return *addr( i );
141 }
142
146 VipsPel
147 operator()( int x, int y ) const
148 {
149 return *addr( x, y );
150 }
151};
152
153VIPS_NAMESPACE_END
154
155#endif /*VIPS_VREGION_H*/
Definition: VError8.h:46
Definition: VImage8.h:406
Definition: VImage8.h:68
VipsObject * get_object() const
Definition: VImage8.h:172
Definition: VRegion8.h:41
VipsPel * addr(size_t i) const
Definition: VRegion8.h:111
size_t stride() const
Definition: VRegion8.h:129
VipsRect valid() const
Definition: VRegion8.h:93
VipsPel * addr() const
Definition: VRegion8.h:102
VipsPel operator()(int x, int y) const
Definition: VRegion8.h:147
VRegion(VipsRegion *region, VSteal steal=STEAL)
Definition: VRegion8.h:48
void prepare(const VipsRect *rect) const
Definition: VRegion8.h:72
VipsRegion * get_region() const
Definition: VRegion8.h:63
VipsPel operator[](size_t i) const
Definition: VRegion8.h:138
VipsPel * addr(int x, int y) const
Definition: VRegion8.h:120
void prepare(int left, int top, int width, int height) const
Definition: VRegion8.h:82
static VRegion new_from_image(VImage image)
Definition: VRegion.cpp:14