Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/3rdparty/openexr/IlmImf/ImfFrameBuffer.cpp
16337 views
1
///////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
4
// Digital Ltd. LLC
5
//
6
// All rights reserved.
7
//
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
10
// met:
11
// * Redistributions of source code must retain the above copyright
12
// notice, this list of conditions and the following disclaimer.
13
// * Redistributions in binary form must reproduce the above
14
// copyright notice, this list of conditions and the following disclaimer
15
// in the documentation and/or other materials provided with the
16
// distribution.
17
// * Neither the name of Industrial Light & Magic nor the names of
18
// its contributors may be used to endorse or promote products derived
19
// from this software without specific prior written permission.
20
//
21
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
//
33
///////////////////////////////////////////////////////////////////////////
34
35
36
37
//-----------------------------------------------------------------------------
38
//
39
// class Slice
40
// class FrameBuffer
41
//
42
//-----------------------------------------------------------------------------
43
44
#include <ImfFrameBuffer.h>
45
#include "Iex.h"
46
47
48
using namespace std;
49
50
namespace Imf {
51
52
Slice::Slice (PixelType t,
53
char *b,
54
size_t xst,
55
size_t yst,
56
int xsm,
57
int ysm,
58
double fv,
59
bool xtc,
60
bool ytc)
61
:
62
type (t),
63
base (b),
64
xStride (xst),
65
yStride (yst),
66
xSampling (xsm),
67
ySampling (ysm),
68
fillValue (fv),
69
xTileCoords (xtc),
70
yTileCoords (ytc)
71
{
72
// empty
73
}
74
75
76
void
77
FrameBuffer::insert (const char name[], const Slice &slice)
78
{
79
if (name[0] == 0)
80
{
81
THROW (Iex::ArgExc,
82
"Frame buffer slice name cannot be an empty string.");
83
}
84
85
_map[name] = slice;
86
}
87
88
89
void
90
FrameBuffer::insert (const string &name, const Slice &slice)
91
{
92
insert (name.c_str(), slice);
93
}
94
95
96
Slice &
97
FrameBuffer::operator [] (const char name[])
98
{
99
SliceMap::iterator i = _map.find (name);
100
101
if (i == _map.end())
102
{
103
THROW (Iex::ArgExc,
104
"Cannot find frame buffer slice \"" << name << "\".");
105
}
106
107
return i->second;
108
}
109
110
111
const Slice &
112
FrameBuffer::operator [] (const char name[]) const
113
{
114
SliceMap::const_iterator i = _map.find (name);
115
116
if (i == _map.end())
117
{
118
THROW (Iex::ArgExc,
119
"Cannot find frame buffer slice \"" << name << "\".");
120
}
121
122
return i->second;
123
}
124
125
126
Slice &
127
FrameBuffer::operator [] (const string &name)
128
{
129
return this->operator[] (name.c_str());
130
}
131
132
133
const Slice &
134
FrameBuffer::operator [] (const string &name) const
135
{
136
return this->operator[] (name.c_str());
137
}
138
139
140
Slice *
141
FrameBuffer::findSlice (const char name[])
142
{
143
SliceMap::iterator i = _map.find (name);
144
return (i == _map.end())? 0: &i->second;
145
}
146
147
148
const Slice *
149
FrameBuffer::findSlice (const char name[]) const
150
{
151
SliceMap::const_iterator i = _map.find (name);
152
return (i == _map.end())? 0: &i->second;
153
}
154
155
156
Slice *
157
FrameBuffer::findSlice (const string &name)
158
{
159
return findSlice (name.c_str());
160
}
161
162
163
const Slice *
164
FrameBuffer::findSlice (const string &name) const
165
{
166
return findSlice (name.c_str());
167
}
168
169
170
FrameBuffer::Iterator
171
FrameBuffer::begin ()
172
{
173
return _map.begin();
174
}
175
176
177
FrameBuffer::ConstIterator
178
FrameBuffer::begin () const
179
{
180
return _map.begin();
181
}
182
183
184
FrameBuffer::Iterator
185
FrameBuffer::end ()
186
{
187
return _map.end();
188
}
189
190
191
FrameBuffer::ConstIterator
192
FrameBuffer::end () const
193
{
194
return _map.end();
195
}
196
197
198
FrameBuffer::Iterator
199
FrameBuffer::find (const char name[])
200
{
201
return _map.find (name);
202
}
203
204
205
FrameBuffer::ConstIterator
206
FrameBuffer::find (const char name[]) const
207
{
208
return _map.find (name);
209
}
210
211
212
FrameBuffer::Iterator
213
FrameBuffer::find (const string &name)
214
{
215
return find (name.c_str());
216
}
217
218
219
FrameBuffer::ConstIterator
220
FrameBuffer::find (const string &name) const
221
{
222
return find (name.c_str());
223
}
224
225
226
} // namespace Imf
227
228