Path: blob/master/3rdparty/openexr/IlmImf/ImfFrameBuffer.cpp
16337 views
///////////////////////////////////////////////////////////////////////////1//2// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas3// Digital Ltd. LLC4//5// All rights reserved.6//7// Redistribution and use in source and binary forms, with or without8// modification, are permitted provided that the following conditions are9// met:10// * Redistributions of source code must retain the above copyright11// notice, this list of conditions and the following disclaimer.12// * Redistributions in binary form must reproduce the above13// copyright notice, this list of conditions and the following disclaimer14// in the documentation and/or other materials provided with the15// distribution.16// * Neither the name of Industrial Light & Magic nor the names of17// its contributors may be used to endorse or promote products derived18// from this software without specific prior written permission.19//20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.31//32///////////////////////////////////////////////////////////////////////////33343536//-----------------------------------------------------------------------------37//38// class Slice39// class FrameBuffer40//41//-----------------------------------------------------------------------------4243#include <ImfFrameBuffer.h>44#include "Iex.h"454647using namespace std;4849namespace Imf {5051Slice::Slice (PixelType t,52char *b,53size_t xst,54size_t yst,55int xsm,56int ysm,57double fv,58bool xtc,59bool ytc)60:61type (t),62base (b),63xStride (xst),64yStride (yst),65xSampling (xsm),66ySampling (ysm),67fillValue (fv),68xTileCoords (xtc),69yTileCoords (ytc)70{71// empty72}737475void76FrameBuffer::insert (const char name[], const Slice &slice)77{78if (name[0] == 0)79{80THROW (Iex::ArgExc,81"Frame buffer slice name cannot be an empty string.");82}8384_map[name] = slice;85}868788void89FrameBuffer::insert (const string &name, const Slice &slice)90{91insert (name.c_str(), slice);92}939495Slice &96FrameBuffer::operator [] (const char name[])97{98SliceMap::iterator i = _map.find (name);99100if (i == _map.end())101{102THROW (Iex::ArgExc,103"Cannot find frame buffer slice \"" << name << "\".");104}105106return i->second;107}108109110const Slice &111FrameBuffer::operator [] (const char name[]) const112{113SliceMap::const_iterator i = _map.find (name);114115if (i == _map.end())116{117THROW (Iex::ArgExc,118"Cannot find frame buffer slice \"" << name << "\".");119}120121return i->second;122}123124125Slice &126FrameBuffer::operator [] (const string &name)127{128return this->operator[] (name.c_str());129}130131132const Slice &133FrameBuffer::operator [] (const string &name) const134{135return this->operator[] (name.c_str());136}137138139Slice *140FrameBuffer::findSlice (const char name[])141{142SliceMap::iterator i = _map.find (name);143return (i == _map.end())? 0: &i->second;144}145146147const Slice *148FrameBuffer::findSlice (const char name[]) const149{150SliceMap::const_iterator i = _map.find (name);151return (i == _map.end())? 0: &i->second;152}153154155Slice *156FrameBuffer::findSlice (const string &name)157{158return findSlice (name.c_str());159}160161162const Slice *163FrameBuffer::findSlice (const string &name) const164{165return findSlice (name.c_str());166}167168169FrameBuffer::Iterator170FrameBuffer::begin ()171{172return _map.begin();173}174175176FrameBuffer::ConstIterator177FrameBuffer::begin () const178{179return _map.begin();180}181182183FrameBuffer::Iterator184FrameBuffer::end ()185{186return _map.end();187}188189190FrameBuffer::ConstIterator191FrameBuffer::end () const192{193return _map.end();194}195196197FrameBuffer::Iterator198FrameBuffer::find (const char name[])199{200return _map.find (name);201}202203204FrameBuffer::ConstIterator205FrameBuffer::find (const char name[]) const206{207return _map.find (name);208}209210211FrameBuffer::Iterator212FrameBuffer::find (const string &name)213{214return find (name.c_str());215}216217218FrameBuffer::ConstIterator219FrameBuffer::find (const string &name) const220{221return find (name.c_str());222}223224225} // namespace Imf226227228