1
///////////////////////////////////////////////////////////////////////////
3
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
6
// All rights reserved.
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
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
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.
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.
33
///////////////////////////////////////////////////////////////////////////
37
#ifndef INCLUDED_IMF_CHANNEL_LIST_H
38
#define INCLUDED_IMF_CHANNEL_LIST_H
40
//-----------------------------------------------------------------------------
45
//-----------------------------------------------------------------------------
48
#include <ImfPixelType.h>
59
//------------------------------
60
// Data type; see ImfPixelType.h
61
//------------------------------
66
//--------------------------------------------
67
// Subsampling: pixel (x, y) is present in the
70
// x % xSampling == 0 && y % ySampling == 0
72
//--------------------------------------------
78
//--------------------------------------------------------------
79
// Hint to lossy compression methods that indicates whether
80
// human perception of the quantity represented by this channel
81
// is closer to linear or closer to logarithmic. Compression
82
// methods may optimize image quality by adjusting pixel data
83
// quantization acording to this hint.
84
// For example, perception of red, green, blue and luminance is
85
// approximately logarithmic; the difference between 0.1 and 0.2
86
// is perceived to be roughly the same as the difference between
87
// 1.0 and 2.0. Perception of chroma coordinates tends to be
88
// closer to linear than logarithmic; the difference between 0.1
89
// and 0.2 is perceived to be roughly the same as the difference
90
// between 1.0 and 1.1.
91
//--------------------------------------------------------------
100
Channel (PixelType type = HALF,
103
bool pLinear = false);
110
bool operator == (const Channel &other) const;
122
void insert (const char name[],
123
const Channel &channel);
125
//------------------------------------------------------------------
126
// Access to existing channels:
128
// [n] Returns a reference to the channel with name n.
129
// If no channel with name n exists, an Iex::ArgExc
132
// findChannel(n) Returns a pointer to the channel with name n,
133
// or 0 if no channel with name n exists.
135
//------------------------------------------------------------------
137
Channel & operator [] (const char name[]);
138
const Channel & operator [] (const char name[]) const;
140
Channel * findChannel (const char name[]);
141
const Channel * findChannel (const char name[]) const;
144
//-------------------------------------------
145
// Iterator-style access to existing channels
146
//-------------------------------------------
148
typedef std::map <Name, Channel> ChannelMap;
154
ConstIterator begin () const;
156
ConstIterator end () const;
157
Iterator find (const char name[]);
158
ConstIterator find (const char name[]) const;
161
//-----------------------------------------------------------------
162
// Support for image layers:
164
// In an image file with many channels it is sometimes useful to
165
// group the channels into "layers", that is, into sets of channels
166
// that logically belong together. Grouping channels into layers
167
// is done using a naming convention: channel C in layer L is
170
// For example, a computer graphic image may contain separate
171
// R, G and B channels for light that originated at each of
172
// several different virtual light sources. The channels in
173
// this image might be called "light1.R", "light1.G", "light1.B",
174
// "light2.R", "light2.G", "light2.B", etc.
176
// Note that this naming convention allows layers to be nested;
177
// for example, "light1.specular.R" identifies the "R" channel
178
// in the "specular" sub-layer of layer "light1".
180
// Channel names that don't contain a "." or that contain a
181
// "." only at the beginning or at the end are not considered
182
// to be part of any layer.
184
// layers(lns) sorts the channels in this ChannelList
185
// into layers and stores the names of
186
// all layers, sorted alphabetically,
187
// into string set lns.
189
// channelsInLayer(ln,f,l) stores a pair of iterators in f and l
190
// such that the loop
192
// for (ConstIterator i = f; i != l; ++i)
195
// iterates over all channels in layer ln.
196
// channelsInLayer (ln, l, p) calls
197
// channelsWithPrefix (ln + ".", l, p).
199
//-----------------------------------------------------------------
201
void layers (std::set <std::string> &layerNames) const;
203
void channelsInLayer (const std::string &layerName,
207
void channelsInLayer (const std::string &layerName,
208
ConstIterator &first,
209
ConstIterator &last) const;
212
//-------------------------------------------------------------------
213
// Find all channels whose name begins with a given prefix:
215
// channelsWithPrefix(p,f,l) stores a pair of iterators in f and l
216
// such that the following loop iterates over all channels whose name
217
// begins with string p:
219
// for (ConstIterator i = f; i != l; ++i)
222
//-------------------------------------------------------------------
224
void channelsWithPrefix (const char prefix[],
228
void channelsWithPrefix (const char prefix[],
229
ConstIterator &first,
230
ConstIterator &last) const;
236
bool operator == (const ChannelList &other) const;
248
class ChannelList::Iterator
253
Iterator (const ChannelList::ChannelMap::iterator &i);
255
Iterator & operator ++ ();
256
Iterator operator ++ (int);
258
const char * name () const;
259
Channel & channel () const;
263
friend class ChannelList::ConstIterator;
265
ChannelList::ChannelMap::iterator _i;
269
class ChannelList::ConstIterator
274
ConstIterator (const ChannelList::ChannelMap::const_iterator &i);
275
ConstIterator (const ChannelList::Iterator &other);
277
ConstIterator & operator ++ ();
278
ConstIterator operator ++ (int);
280
const char * name () const;
281
const Channel & channel () const;
285
friend bool operator == (const ConstIterator &, const ConstIterator &);
286
friend bool operator != (const ConstIterator &, const ConstIterator &);
288
ChannelList::ChannelMap::const_iterator _i;
297
ChannelList::Iterator::Iterator (): _i()
304
ChannelList::Iterator::Iterator (const ChannelList::ChannelMap::iterator &i):
311
inline ChannelList::Iterator &
312
ChannelList::Iterator::operator ++ ()
319
inline ChannelList::Iterator
320
ChannelList::Iterator::operator ++ (int)
322
Iterator tmp = *this;
329
ChannelList::Iterator::name () const
336
ChannelList::Iterator::channel () const
343
ChannelList::ConstIterator::ConstIterator (): _i()
349
ChannelList::ConstIterator::ConstIterator
350
(const ChannelList::ChannelMap::const_iterator &i): _i (i)
357
ChannelList::ConstIterator::ConstIterator (const ChannelList::Iterator &other):
363
inline ChannelList::ConstIterator &
364
ChannelList::ConstIterator::operator ++ ()
371
inline ChannelList::ConstIterator
372
ChannelList::ConstIterator::operator ++ (int)
374
ConstIterator tmp = *this;
381
ChannelList::ConstIterator::name () const
386
inline const Channel &
387
ChannelList::ConstIterator::channel () const
394
operator == (const ChannelList::ConstIterator &x,
395
const ChannelList::ConstIterator &y)
402
operator != (const ChannelList::ConstIterator &x,
403
const ChannelList::ConstIterator &y)
1
///////////////////////////////////////////////////////////////////////////
3
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
6
// All rights reserved.
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
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
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.
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.
33
///////////////////////////////////////////////////////////////////////////
37
#ifndef INCLUDED_IMF_CHANNEL_LIST_H
38
#define INCLUDED_IMF_CHANNEL_LIST_H
40
//-----------------------------------------------------------------------------
45
//-----------------------------------------------------------------------------
48
#include <ImfPixelType.h>
59
//------------------------------
60
// Data type; see ImfPixelType.h
61
//------------------------------
66
//--------------------------------------------
67
// Subsampling: pixel (x, y) is present in the
70
// x % xSampling == 0 && y % ySampling == 0
72
//--------------------------------------------
78
//--------------------------------------------------------------
79
// Hint to lossy compression methods that indicates whether
80
// human perception of the quantity represented by this channel
81
// is closer to linear or closer to logarithmic. Compression
82
// methods may optimize image quality by adjusting pixel data
83
// quantization acording to this hint.
84
// For example, perception of red, green, blue and luminance is
85
// approximately logarithmic; the difference between 0.1 and 0.2
86
// is perceived to be roughly the same as the difference between
87
// 1.0 and 2.0. Perception of chroma coordinates tends to be
88
// closer to linear than logarithmic; the difference between 0.1
89
// and 0.2 is perceived to be roughly the same as the difference
90
// between 1.0 and 1.1.
91
//--------------------------------------------------------------
100
Channel (PixelType type = HALF,
103
bool pLinear = false);
110
bool operator == (const Channel &other) const;
122
void insert (const char name[],
123
const Channel &channel);
125
//------------------------------------------------------------------
126
// Access to existing channels:
128
// [n] Returns a reference to the channel with name n.
129
// If no channel with name n exists, an Iex::ArgExc
132
// findChannel(n) Returns a pointer to the channel with name n,
133
// or 0 if no channel with name n exists.
135
//------------------------------------------------------------------
137
Channel & operator [] (const char name[]);
138
const Channel & operator [] (const char name[]) const;
140
Channel * findChannel (const char name[]);
141
const Channel * findChannel (const char name[]) const;
144
//-------------------------------------------
145
// Iterator-style access to existing channels
146
//-------------------------------------------
148
typedef std::map <Name, Channel> ChannelMap;
154
ConstIterator begin () const;
156
ConstIterator end () const;
157
Iterator find (const char name[]);
158
ConstIterator find (const char name[]) const;
161
//-----------------------------------------------------------------
162
// Support for image layers:
164
// In an image file with many channels it is sometimes useful to
165
// group the channels into "layers", that is, into sets of channels
166
// that logically belong together. Grouping channels into layers
167
// is done using a naming convention: channel C in layer L is
170
// For example, a computer graphic image may contain separate
171
// R, G and B channels for light that originated at each of
172
// several different virtual light sources. The channels in
173
// this image might be called "light1.R", "light1.G", "light1.B",
174
// "light2.R", "light2.G", "light2.B", etc.
176
// Note that this naming convention allows layers to be nested;
177
// for example, "light1.specular.R" identifies the "R" channel
178
// in the "specular" sub-layer of layer "light1".
180
// Channel names that don't contain a "." or that contain a
181
// "." only at the beginning or at the end are not considered
182
// to be part of any layer.
184
// layers(lns) sorts the channels in this ChannelList
185
// into layers and stores the names of
186
// all layers, sorted alphabetically,
187
// into string set lns.
189
// channelsInLayer(ln,f,l) stores a pair of iterators in f and l
190
// such that the loop
192
// for (ConstIterator i = f; i != l; ++i)
195
// iterates over all channels in layer ln.
196
// channelsInLayer (ln, l, p) calls
197
// channelsWithPrefix (ln + ".", l, p).
199
//-----------------------------------------------------------------
201
void layers (std::set <std::string> &layerNames) const;
203
void channelsInLayer (const std::string &layerName,
207
void channelsInLayer (const std::string &layerName,
208
ConstIterator &first,
209
ConstIterator &last) const;
212
//-------------------------------------------------------------------
213
// Find all channels whose name begins with a given prefix:
215
// channelsWithPrefix(p,f,l) stores a pair of iterators in f and l
216
// such that the following loop iterates over all channels whose name
217
// begins with string p:
219
// for (ConstIterator i = f; i != l; ++i)
222
//-------------------------------------------------------------------
224
void channelsWithPrefix (const char prefix[],
228
void channelsWithPrefix (const char prefix[],
229
ConstIterator &first,
230
ConstIterator &last) const;
236
bool operator == (const ChannelList &other) const;
248
class ChannelList::Iterator
253
Iterator (const ChannelList::ChannelMap::iterator &i);
255
Iterator & operator ++ ();
256
Iterator operator ++ (int);
258
const char * name () const;
259
Channel & channel () const;
263
friend class ChannelList::ConstIterator;
265
ChannelList::ChannelMap::iterator _i;
269
class ChannelList::ConstIterator
274
ConstIterator (const ChannelList::ChannelMap::const_iterator &i);
275
ConstIterator (const ChannelList::Iterator &other);
277
ConstIterator & operator ++ ();
278
ConstIterator operator ++ (int);
280
const char * name () const;
281
const Channel & channel () const;
285
friend bool operator == (const ConstIterator &, const ConstIterator &);
286
friend bool operator != (const ConstIterator &, const ConstIterator &);
288
ChannelList::ChannelMap::const_iterator _i;
297
ChannelList::Iterator::Iterator (): _i()
304
ChannelList::Iterator::Iterator (const ChannelList::ChannelMap::iterator &i):
311
inline ChannelList::Iterator &
312
ChannelList::Iterator::operator ++ ()
319
inline ChannelList::Iterator
320
ChannelList::Iterator::operator ++ (int)
322
Iterator tmp = *this;
329
ChannelList::Iterator::name () const
336
ChannelList::Iterator::channel () const
343
ChannelList::ConstIterator::ConstIterator (): _i()
349
ChannelList::ConstIterator::ConstIterator
350
(const ChannelList::ChannelMap::const_iterator &i): _i (i)
357
ChannelList::ConstIterator::ConstIterator (const ChannelList::Iterator &other):
363
inline ChannelList::ConstIterator &
364
ChannelList::ConstIterator::operator ++ ()
371
inline ChannelList::ConstIterator
372
ChannelList::ConstIterator::operator ++ (int)
374
ConstIterator tmp = *this;
381
ChannelList::ConstIterator::name () const
386
inline const Channel &
387
ChannelList::ConstIterator::channel () const
394
operator == (const ChannelList::ConstIterator &x,
395
const ChannelList::ConstIterator &y)
402
operator != (const ChannelList::ConstIterator &x,
403
const ChannelList::ConstIterator &y)