Blame IlmImfUtil/ImfImageLevel.cpp

Packit Service 6754ca
///////////////////////////////////////////////////////////////////////////
Packit Service 6754ca
//
Packit Service 6754ca
// Copyright (c) 2014, Industrial Light & Magic, a division of Lucas
Packit Service 6754ca
// Digital Ltd. LLC
Packit Service 6754ca
// 
Packit Service 6754ca
// All rights reserved.
Packit Service 6754ca
// 
Packit Service 6754ca
// Redistribution and use in source and binary forms, with or without
Packit Service 6754ca
// modification, are permitted provided that the following conditions are
Packit Service 6754ca
// met:
Packit Service 6754ca
// *       Redistributions of source code must retain the above copyright
Packit Service 6754ca
// notice, this list of conditions and the following disclaimer.
Packit Service 6754ca
// *       Redistributions in binary form must reproduce the above
Packit Service 6754ca
// copyright notice, this list of conditions and the following disclaimer
Packit Service 6754ca
// in the documentation and/or other materials provided with the
Packit Service 6754ca
// distribution.
Packit Service 6754ca
// *       Neither the name of Industrial Light & Magic nor the names of
Packit Service 6754ca
// its contributors may be used to endorse or promote products derived
Packit Service 6754ca
// from this software without specific prior written permission. 
Packit Service 6754ca
// 
Packit Service 6754ca
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit Service 6754ca
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit Service 6754ca
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit Service 6754ca
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit Service 6754ca
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit Service 6754ca
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit Service 6754ca
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit Service 6754ca
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit Service 6754ca
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit Service 6754ca
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit Service 6754ca
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service 6754ca
//
Packit Service 6754ca
///////////////////////////////////////////////////////////////////////////
Packit Service 6754ca
Packit Service 6754ca
//----------------------------------------------------------------------------
Packit Service 6754ca
//
Packit Service 6754ca
//      class ImageLevel
Packit Service 6754ca
//
Packit Service 6754ca
//----------------------------------------------------------------------------
Packit Service 6754ca
Packit Service 6754ca
#include "ImfImageLevel.h"
Packit Service 6754ca
#include <Iex.h>
Packit Service 6754ca
#include <cassert>
Packit Service 6754ca
Packit Service 6754ca
using namespace IMATH_NAMESPACE;
Packit Service 6754ca
using namespace IEX_NAMESPACE;
Packit Service 6754ca
using namespace std;
Packit Service 6754ca
Packit Service 6754ca
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
ImageLevel::ImageLevel
Packit Service 6754ca
    (Image& image,
Packit Service 6754ca
     int xLevelNumber,
Packit Service 6754ca
     int yLevelNumber)
Packit Service 6754ca
:
Packit Service 6754ca
    _image (image),
Packit Service 6754ca
    _xLevelNumber (xLevelNumber),
Packit Service 6754ca
    _yLevelNumber (yLevelNumber),
Packit Service 6754ca
    _dataWindow (Box2i (V2i (0, 0), V2i (-1, -1)))
Packit Service 6754ca
{
Packit Service 6754ca
    // empty
Packit Service 6754ca
}
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
ImageLevel::~ImageLevel ()
Packit Service 6754ca
{
Packit Service 6754ca
    // empty
Packit Service 6754ca
}
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
void			
Packit Service 6754ca
ImageLevel::resize (const Imath::Box2i& dataWindow)
Packit Service 6754ca
{
Packit Service 6754ca
    if (dataWindow.max.x < dataWindow.min.x - 1||
Packit Service 6754ca
        dataWindow.max.y < dataWindow.min.y - 1)
Packit Service 6754ca
    {
Packit Service 6754ca
        THROW (ArgExc,
Packit Service 6754ca
               "Cannot reset data window for image level to "
Packit Service 6754ca
               "(" << dataWindow.min.x << ", " << dataWindow.min.y << ") - "
Packit Service 6754ca
               "(" << dataWindow.max.x << ", " << dataWindow.max.y << "). "
Packit Service 6754ca
               "The new data window is invalid.");
Packit Service 6754ca
    }
Packit Service 6754ca
Packit Service 6754ca
    _dataWindow = dataWindow;
Packit Service 6754ca
}
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
void
Packit Service 6754ca
ImageLevel::shiftPixels (int dx, int dy)
Packit Service 6754ca
{
Packit Service 6754ca
    _dataWindow.min.x += dx;
Packit Service 6754ca
    _dataWindow.min.y += dy;
Packit Service 6754ca
    _dataWindow.max.x += dx;
Packit Service 6754ca
    _dataWindow.max.y += dy;
Packit Service 6754ca
}
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
void
Packit Service 6754ca
ImageLevel::throwChannelExists (const string& name) const
Packit Service 6754ca
{
Packit Service 6754ca
    THROW (ArgExc, "Cannot insert a new image channel with "
Packit Service 6754ca
                   "name \"" << name << "\" into an image level. "
Packit Service 6754ca
                   "A channel with the same name exists already.");
Packit Service 6754ca
}
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
void
Packit Service 6754ca
ImageLevel::throwBadChannelName (const string& name) const
Packit Service 6754ca
{
Packit Service 6754ca
    THROW (ArgExc, "Attempt to access non-existent "
Packit Service 6754ca
                   "image channel \"" << name << "\".");
Packit Service 6754ca
}
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
void
Packit Service 6754ca
ImageLevel::throwBadChannelNameOrType (const string& name) const
Packit Service 6754ca
{
Packit Service 6754ca
    THROW (ArgExc, "Image channel \"" << name << "\" does not exist "
Packit Service 6754ca
                   "or is not of the expected type.");
Packit Service 6754ca
}
Packit Service 6754ca
Packit Service 6754ca
Packit Service 6754ca
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT