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
void insert (const std::string &name,
126
const Channel &channel);
128
//------------------------------------------------------------------
129
// Access to existing channels:
131
// [n] Returns a reference to the channel with name n.
132
// If no channel with name n exists, an Iex::ArgExc
135
// findChannel(n) Returns a pointer to the channel with name n,
136
// or 0 if no channel with name n exists.
138
//------------------------------------------------------------------
140
Channel & operator [] (const char name[]);
141
const Channel & operator [] (const char name[]) const;
143
Channel & operator [] (const std::string &name);
144
const Channel & operator [] (const std::string &name) const;
146
Channel * findChannel (const char name[]);
147
const Channel * findChannel (const char name[]) const;
149
Channel * findChannel (const std::string &name);
150
const Channel * findChannel (const std::string &name) const;
153
//-------------------------------------------
154
// Iterator-style access to existing channels
155
//-------------------------------------------
157
typedef std::map <Name, Channel> ChannelMap;
163
ConstIterator begin () const;
166
ConstIterator end () const;
168
Iterator find (const char name[]);
169
ConstIterator find (const char name[]) const;
171
Iterator find (const std::string &name);
172
ConstIterator find (const std::string &name) const;
175
//-----------------------------------------------------------------
176
// Support for image layers:
178
// In an image file with many channels it is sometimes useful to
179
// group the channels into "layers", that is, into sets of channels
180
// that logically belong together. Grouping channels into layers
181
// is done using a naming convention: channel C in layer L is
184
// For example, a computer graphic image may contain separate
185
// R, G and B channels for light that originated at each of
186
// several different virtual light sources. The channels in
187
// this image might be called "light1.R", "light1.G", "light1.B",
188
// "light2.R", "light2.G", "light2.B", etc.
190
// Note that this naming convention allows layers to be nested;
191
// for example, "light1.specular.R" identifies the "R" channel
192
// in the "specular" sub-layer of layer "light1".
194
// Channel names that don't contain a "." or that contain a
195
// "." only at the beginning or at the end are not considered
196
// to be part of any layer.
198
// layers(lns) sorts the channels in this ChannelList
199
// into layers and stores the names of
200
// all layers, sorted alphabetically,
201
// into string set lns.
203
// channelsInLayer(ln,f,l) stores a pair of iterators in f and l
204
// such that the loop
206
// for (ConstIterator i = f; i != l; ++i)
209
// iterates over all channels in layer ln.
210
// channelsInLayer (ln, l, p) calls
211
// channelsWithPrefix (ln + ".", l, p).
213
//-----------------------------------------------------------------
215
void layers (std::set <std::string> &layerNames) const;
217
void channelsInLayer (const std::string &layerName,
221
void channelsInLayer (const std::string &layerName,
222
ConstIterator &first,
223
ConstIterator &last) const;
226
//-------------------------------------------------------------------
227
// Find all channels whose name begins with a given prefix:
229
// channelsWithPrefix(p,f,l) stores a pair of iterators in f and l
230
// such that the following loop iterates over all channels whose name
231
// begins with string p:
233
// for (ConstIterator i = f; i != l; ++i)
236
//-------------------------------------------------------------------
238
void channelsWithPrefix (const char prefix[],
242
void channelsWithPrefix (const char prefix[],
243
ConstIterator &first,
244
ConstIterator &last) const;
246
void channelsWithPrefix (const std::string &prefix,
250
void channelsWithPrefix (const std::string &prefix,
251
ConstIterator &first,
252
ConstIterator &last) const;
258
bool operator == (const ChannelList &other) const;
270
class ChannelList::Iterator
275
Iterator (const ChannelList::ChannelMap::iterator &i);
277
Iterator & operator ++ ();
278
Iterator operator ++ (int);
280
const char * name () const;
281
Channel & channel () const;
285
friend class ChannelList::ConstIterator;
287
ChannelList::ChannelMap::iterator _i;
291
class ChannelList::ConstIterator
296
ConstIterator (const ChannelList::ChannelMap::const_iterator &i);
297
ConstIterator (const ChannelList::Iterator &other);
299
ConstIterator & operator ++ ();
300
ConstIterator operator ++ (int);
302
const char * name () const;
303
const Channel & channel () const;
307
friend bool operator == (const ConstIterator &, const ConstIterator &);
308
friend bool operator != (const ConstIterator &, const ConstIterator &);
310
ChannelList::ChannelMap::const_iterator _i;
319
ChannelList::Iterator::Iterator (): _i()
326
ChannelList::Iterator::Iterator (const ChannelList::ChannelMap::iterator &i):
333
inline ChannelList::Iterator &
334
ChannelList::Iterator::operator ++ ()
341
inline ChannelList::Iterator
342
ChannelList::Iterator::operator ++ (int)
344
Iterator tmp = *this;
351
ChannelList::Iterator::name () const
358
ChannelList::Iterator::channel () const
365
ChannelList::ConstIterator::ConstIterator (): _i()
371
ChannelList::ConstIterator::ConstIterator
372
(const ChannelList::ChannelMap::const_iterator &i): _i (i)
379
ChannelList::ConstIterator::ConstIterator (const ChannelList::Iterator &other):
385
inline ChannelList::ConstIterator &
386
ChannelList::ConstIterator::operator ++ ()
393
inline ChannelList::ConstIterator
394
ChannelList::ConstIterator::operator ++ (int)
396
ConstIterator tmp = *this;
403
ChannelList::ConstIterator::name () const
408
inline const Channel &
409
ChannelList::ConstIterator::channel () const
416
operator == (const ChannelList::ConstIterator &x,
417
const ChannelList::ConstIterator &y)
424
operator != (const ChannelList::ConstIterator &x,
425
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
void insert (const std::string &name,
126
const Channel &channel);
128
//------------------------------------------------------------------
129
// Access to existing channels:
131
// [n] Returns a reference to the channel with name n.
132
// If no channel with name n exists, an Iex::ArgExc
135
// findChannel(n) Returns a pointer to the channel with name n,
136
// or 0 if no channel with name n exists.
138
//------------------------------------------------------------------
140
Channel & operator [] (const char name[]);
141
const Channel & operator [] (const char name[]) const;
143
Channel & operator [] (const std::string &name);
144
const Channel & operator [] (const std::string &name) const;
146
Channel * findChannel (const char name[]);
147
const Channel * findChannel (const char name[]) const;
149
Channel * findChannel (const std::string &name);
150
const Channel * findChannel (const std::string &name) const;
153
//-------------------------------------------
154
// Iterator-style access to existing channels
155
//-------------------------------------------
157
typedef std::map <Name, Channel> ChannelMap;
163
ConstIterator begin () const;
166
ConstIterator end () const;
168
Iterator find (const char name[]);
169
ConstIterator find (const char name[]) const;
171
Iterator find (const std::string &name);
172
ConstIterator find (const std::string &name) const;
175
//-----------------------------------------------------------------
176
// Support for image layers:
178
// In an image file with many channels it is sometimes useful to
179
// group the channels into "layers", that is, into sets of channels
180
// that logically belong together. Grouping channels into layers
181
// is done using a naming convention: channel C in layer L is
184
// For example, a computer graphic image may contain separate
185
// R, G and B channels for light that originated at each of
186
// several different virtual light sources. The channels in
187
// this image might be called "light1.R", "light1.G", "light1.B",
188
// "light2.R", "light2.G", "light2.B", etc.
190
// Note that this naming convention allows layers to be nested;
191
// for example, "light1.specular.R" identifies the "R" channel
192
// in the "specular" sub-layer of layer "light1".
194
// Channel names that don't contain a "." or that contain a
195
// "." only at the beginning or at the end are not considered
196
// to be part of any layer.
198
// layers(lns) sorts the channels in this ChannelList
199
// into layers and stores the names of
200
// all layers, sorted alphabetically,
201
// into string set lns.
203
// channelsInLayer(ln,f,l) stores a pair of iterators in f and l
204
// such that the loop
206
// for (ConstIterator i = f; i != l; ++i)
209
// iterates over all channels in layer ln.
210
// channelsInLayer (ln, l, p) calls
211
// channelsWithPrefix (ln + ".", l, p).
213
//-----------------------------------------------------------------
215
void layers (std::set <std::string> &layerNames) const;
217
void channelsInLayer (const std::string &layerName,
221
void channelsInLayer (const std::string &layerName,
222
ConstIterator &first,
223
ConstIterator &last) const;
226
//-------------------------------------------------------------------
227
// Find all channels whose name begins with a given prefix:
229
// channelsWithPrefix(p,f,l) stores a pair of iterators in f and l
230
// such that the following loop iterates over all channels whose name
231
// begins with string p:
233
// for (ConstIterator i = f; i != l; ++i)
236
//-------------------------------------------------------------------
238
void channelsWithPrefix (const char prefix[],
242
void channelsWithPrefix (const char prefix[],
243
ConstIterator &first,
244
ConstIterator &last) const;
246
void channelsWithPrefix (const std::string &prefix,
250
void channelsWithPrefix (const std::string &prefix,
251
ConstIterator &first,
252
ConstIterator &last) const;
258
bool operator == (const ChannelList &other) const;
270
class ChannelList::Iterator
275
Iterator (const ChannelList::ChannelMap::iterator &i);
277
Iterator & operator ++ ();
278
Iterator operator ++ (int);
280
const char * name () const;
281
Channel & channel () const;
285
friend class ChannelList::ConstIterator;
287
ChannelList::ChannelMap::iterator _i;
291
class ChannelList::ConstIterator
296
ConstIterator (const ChannelList::ChannelMap::const_iterator &i);
297
ConstIterator (const ChannelList::Iterator &other);
299
ConstIterator & operator ++ ();
300
ConstIterator operator ++ (int);
302
const char * name () const;
303
const Channel & channel () const;
307
friend bool operator == (const ConstIterator &, const ConstIterator &);
308
friend bool operator != (const ConstIterator &, const ConstIterator &);
310
ChannelList::ChannelMap::const_iterator _i;
319
ChannelList::Iterator::Iterator (): _i()
326
ChannelList::Iterator::Iterator (const ChannelList::ChannelMap::iterator &i):
333
inline ChannelList::Iterator &
334
ChannelList::Iterator::operator ++ ()
341
inline ChannelList::Iterator
342
ChannelList::Iterator::operator ++ (int)
344
Iterator tmp = *this;
351
ChannelList::Iterator::name () const
358
ChannelList::Iterator::channel () const
365
ChannelList::ConstIterator::ConstIterator (): _i()
371
ChannelList::ConstIterator::ConstIterator
372
(const ChannelList::ChannelMap::const_iterator &i): _i (i)
379
ChannelList::ConstIterator::ConstIterator (const ChannelList::Iterator &other):
385
inline ChannelList::ConstIterator &
386
ChannelList::ConstIterator::operator ++ ()
393
inline ChannelList::ConstIterator
394
ChannelList::ConstIterator::operator ++ (int)
396
ConstIterator tmp = *this;
403
ChannelList::ConstIterator::name () const
408
inline const Channel &
409
ChannelList::ConstIterator::channel () const
416
operator == (const ChannelList::ConstIterator &x,
417
const ChannelList::ConstIterator &y)
424
operator != (const ChannelList::ConstIterator &x,
425
const ChannelList::ConstIterator &y)