|
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 |
// OpenEXR file I/O for deep images.
|
|
Packit Service |
6754ca |
//
|
|
Packit Service |
6754ca |
//----------------------------------------------------------------------------
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
#include "ImfDeepImageIO.h"
|
|
Packit Service |
6754ca |
#include <ImfDeepScanLineInputFile.h>
|
|
Packit Service |
6754ca |
#include <ImfDeepScanLineOutputFile.h>
|
|
Packit Service |
6754ca |
#include <ImfDeepTiledInputFile.h>
|
|
Packit Service |
6754ca |
#include <ImfDeepTiledOutputFile.h>
|
|
Packit Service |
6754ca |
#include <ImfMultiPartInputFile.h>
|
|
Packit Service |
6754ca |
#include <ImfHeader.h>
|
|
Packit Service |
6754ca |
#include <ImfChannelList.h>
|
|
Packit Service |
6754ca |
#include <ImfTestFile.h>
|
|
Packit Service |
6754ca |
#include <ImfPartType.h>
|
|
Packit Service |
6754ca |
#include <Iex.h>
|
|
Packit Service |
6754ca |
#include <cstring>
|
|
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 |
void
|
|
Packit Service |
6754ca |
saveDeepImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
const Header &hdr,
|
|
Packit Service |
6754ca |
const DeepImage &img,
|
|
Packit Service |
6754ca |
DataWindowSource dws)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
if (img.levelMode() != ONE_LEVEL || hdr.hasTileDescription())
|
|
Packit Service |
6754ca |
saveDeepTiledImage (fileName, hdr, img, dws);
|
|
Packit Service |
6754ca |
else
|
|
Packit Service |
6754ca |
saveDeepScanLineImage (fileName, hdr, img, dws);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
saveDeepImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
const DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
Header hdr;
|
|
Packit Service |
6754ca |
hdr.displayWindow() = img.dataWindow();
|
|
Packit Service |
6754ca |
saveDeepImage (fileName, hdr, img);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
loadDeepImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
Header &hdr,
|
|
Packit Service |
6754ca |
DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
bool tiled, deep, multiPart;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
if (!isOpenExrFile (fileName.c_str(), tiled, deep, multiPart))
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
THROW (ArgExc, "Cannot load image file " << fileName << ". "
|
|
Packit Service |
6754ca |
"The file is not an OpenEXR file.");
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
if (multiPart)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
THROW (ArgExc, "Cannot load image file " << fileName << ". "
|
|
Packit Service |
6754ca |
"Multi-part file loading is not supported.");
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
if (!deep)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
THROW (ArgExc, "Cannot load flat image file " << fileName << " "
|
|
Packit Service |
6754ca |
"as a deep image.");
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
//XXX TODO: the tiled flag obtained above is unreliable;
|
|
Packit Service |
6754ca |
// open the file as a multi-part file and inspect the header.
|
|
Packit Service |
6754ca |
// Can the IlmImf library be fixed?
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
MultiPartInputFile mpi (fileName.c_str());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
tiled = (mpi.parts() > 0 &&
|
|
Packit Service |
6754ca |
mpi.header(0).hasType() &&
|
|
Packit Service |
6754ca |
isTiled (mpi.header(0).type()));
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
if (tiled)
|
|
Packit Service |
6754ca |
loadDeepTiledImage (fileName, hdr, img);
|
|
Packit Service |
6754ca |
else
|
|
Packit Service |
6754ca |
loadDeepScanLineImage (fileName, hdr, img);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
loadDeepImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
Header hdr;
|
|
Packit Service |
6754ca |
loadDeepImage (fileName, hdr, img);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
saveDeepScanLineImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
const Header &hdr,
|
|
Packit Service |
6754ca |
const DeepImage &img,
|
|
Packit Service |
6754ca |
DataWindowSource dws)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
Header newHdr;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (Header::ConstIterator i = hdr.begin(); i != hdr.end(); ++i)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
if (strcmp (i.name(), "dataWindow") &&
|
|
Packit Service |
6754ca |
strcmp (i.name(), "tiles") &&
|
|
Packit Service |
6754ca |
strcmp (i.name(), "channels"))
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
newHdr.insert (i.name(), i.attribute());
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
newHdr.dataWindow() = dataWindowForFile (hdr, img, dws);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
//XXX TODO: setting the compression to, for example, ZIP_COMPRESSION,
|
|
Packit Service |
6754ca |
//then the IlmImf library will save the file, but later it will not be
|
|
Packit Service |
6754ca |
//able to read it. Fix the library!
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
newHdr.compression() = ZIPS_COMPRESSION;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
const DeepImageLevel &level = img.level();
|
|
Packit Service |
6754ca |
DeepFrameBuffer fb;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
fb.insertSampleCountSlice (level.sampleCounts().slice());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (DeepImageLevel::ConstIterator i = level.begin(); i != level.end(); ++i)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
newHdr.channels().insert (i.name(), i.channel().channel());
|
|
Packit Service |
6754ca |
fb.insert (i.name(), i.channel().slice());
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
DeepScanLineOutputFile out (fileName.c_str(), newHdr);
|
|
Packit Service |
6754ca |
out.setFrameBuffer (fb);
|
|
Packit Service |
6754ca |
out.writePixels (newHdr.dataWindow().max.y - newHdr.dataWindow().min.y + 1);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
saveDeepScanLineImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
const DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
Header hdr;
|
|
Packit Service |
6754ca |
hdr.displayWindow() = img.dataWindow();
|
|
Packit Service |
6754ca |
saveDeepScanLineImage (fileName, hdr, img);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
loadDeepScanLineImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
Header &hdr,
|
|
Packit Service |
6754ca |
DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
DeepScanLineInputFile in (fileName.c_str());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
const ChannelList &cl = in.header().channels();
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
img.clearChannels();
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (ChannelList::ConstIterator i = cl.begin(); i != cl.end(); ++i)
|
|
Packit Service |
6754ca |
img.insertChannel (i.name(), i.channel());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
img.resize (in.header().dataWindow(), ONE_LEVEL, ROUND_DOWN);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
DeepImageLevel &level = img.level();
|
|
Packit Service |
6754ca |
DeepFrameBuffer fb;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
fb.insertSampleCountSlice (level.sampleCounts().slice());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (DeepImageLevel::ConstIterator i = level.begin(); i != level.end(); ++i)
|
|
Packit Service |
6754ca |
fb.insert (i.name(), i.channel().slice());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
in.setFrameBuffer (fb);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
SampleCountChannel::Edit edit (level.sampleCounts());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
in.readPixelSampleCounts
|
|
Packit Service |
6754ca |
(level.dataWindow().min.y, level.dataWindow().max.y);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
in.readPixels (level.dataWindow().min.y, level.dataWindow().max.y);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (Header::ConstIterator i = in.header().begin();
|
|
Packit Service |
6754ca |
i != in.header().end();
|
|
Packit Service |
6754ca |
++i)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
if (strcmp (i.name(), "tiles"))
|
|
Packit Service |
6754ca |
hdr.insert (i.name(), i.attribute());
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
loadDeepScanLineImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
Header hdr;
|
|
Packit Service |
6754ca |
loadDeepScanLineImage (fileName, hdr, img);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
namespace {
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
saveLevel (DeepTiledOutputFile &out, const DeepImage &img, int x, int y)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
const DeepImageLevel &level = img.level (x, y);
|
|
Packit Service |
6754ca |
DeepFrameBuffer fb;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
fb.insertSampleCountSlice (level.sampleCounts().slice());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (DeepImageLevel::ConstIterator i = level.begin(); i != level.end(); ++i)
|
|
Packit Service |
6754ca |
fb.insert (i.name(), i.channel().slice());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
out.setFrameBuffer (fb);
|
|
Packit Service |
6754ca |
out.writeTiles (0, out.numXTiles (x) - 1, 0, out.numYTiles (y) - 1, x, y);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
} // namespace
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
saveDeepTiledImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
const Header &hdr,
|
|
Packit Service |
6754ca |
const DeepImage &img,
|
|
Packit Service |
6754ca |
DataWindowSource dws)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
Header newHdr;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (Header::ConstIterator i = hdr.begin(); i != hdr.end(); ++i)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
if (strcmp (i.name(), "dataWindow") &&
|
|
Packit Service |
6754ca |
strcmp (i.name(), "tiles") &&
|
|
Packit Service |
6754ca |
strcmp (i.name(), "channels"))
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
newHdr.insert (i.name(), i.attribute());
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
if (hdr.hasTileDescription())
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
newHdr.setTileDescription
|
|
Packit Service |
6754ca |
(TileDescription (hdr.tileDescription().xSize,
|
|
Packit Service |
6754ca |
hdr.tileDescription().ySize,
|
|
Packit Service |
6754ca |
img.levelMode(),
|
|
Packit Service |
6754ca |
img.levelRoundingMode()));
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
else
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
newHdr.setTileDescription
|
|
Packit Service |
6754ca |
(TileDescription (64, // xSize
|
|
Packit Service |
6754ca |
64, // ySize
|
|
Packit Service |
6754ca |
img.levelMode(),
|
|
Packit Service |
6754ca |
img.levelRoundingMode()));
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
newHdr.dataWindow() = dataWindowForFile (hdr, img, dws);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
//XXX TODO: setting the compression to, for example, ZIP_COMPRESSION,
|
|
Packit Service |
6754ca |
//then the IlmImf library will save the file, but later it will not be
|
|
Packit Service |
6754ca |
//able to read it. Fix the library!
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
newHdr.compression() = ZIPS_COMPRESSION;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
const DeepImageLevel &level = img.level (0, 0);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (DeepImageLevel::ConstIterator i = level.begin(); i != level.end(); ++i)
|
|
Packit Service |
6754ca |
newHdr.channels().insert (i.name(), i.channel().channel());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
DeepTiledOutputFile out (fileName.c_str(), newHdr);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
switch (img.levelMode())
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
case ONE_LEVEL:
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
saveLevel (out, img, 0, 0);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
break;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
case MIPMAP_LEVELS:
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (int x = 0; x < out.numLevels(); ++x)
|
|
Packit Service |
6754ca |
saveLevel (out, img, x, x);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
break;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
case RIPMAP_LEVELS:
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (int y = 0; y < out.numYLevels(); ++y)
|
|
Packit Service |
6754ca |
for (int x = 0; x < out.numXLevels(); ++x)
|
|
Packit Service |
6754ca |
saveLevel (out, img, x, y);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
break;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
default:
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
assert (false);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
saveDeepTiledImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
const DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
Header hdr;
|
|
Packit Service |
6754ca |
hdr.displayWindow() = img.dataWindow();
|
|
Packit Service |
6754ca |
saveDeepTiledImage (fileName, hdr, img);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
namespace {
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
loadLevel (DeepTiledInputFile &in, DeepImage &img, int x, int y)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
DeepImageLevel &level = img.level (x, y);
|
|
Packit Service |
6754ca |
DeepFrameBuffer fb;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
fb.insertSampleCountSlice (level.sampleCounts().slice());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (DeepImageLevel::ConstIterator i = level.begin(); i != level.end(); ++i)
|
|
Packit Service |
6754ca |
fb.insert (i.name(), i.channel().slice());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
in.setFrameBuffer (fb);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
SampleCountChannel::Edit edit (level.sampleCounts());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
in.readPixelSampleCounts
|
|
Packit Service |
6754ca |
(0, in.numXTiles (x) - 1, 0, in.numYTiles (y) - 1, x, y);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
in.readTiles (0, in.numXTiles (x) - 1, 0, in.numYTiles (y) - 1, x, y);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
} // namespace
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
loadDeepTiledImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
Header &hdr,
|
|
Packit Service |
6754ca |
DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
DeepTiledInputFile in (fileName.c_str());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
const ChannelList &cl = in.header().channels();
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
img.clearChannels();
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (ChannelList::ConstIterator i = cl.begin(); i != cl.end(); ++i)
|
|
Packit Service |
6754ca |
img.insertChannel (i.name(), i.channel());
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
img.resize (in.header().dataWindow(),
|
|
Packit Service |
6754ca |
in.header().tileDescription().mode,
|
|
Packit Service |
6754ca |
in.header().tileDescription().roundingMode);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
switch (img.levelMode())
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
case ONE_LEVEL:
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
loadLevel (in, img, 0, 0);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
break;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
case MIPMAP_LEVELS:
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (int x = 0; x < img.numLevels(); ++x)
|
|
Packit Service |
6754ca |
loadLevel (in, img, x, x);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
break;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
case RIPMAP_LEVELS:
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (int y = 0; y < img.numYLevels(); ++y)
|
|
Packit Service |
6754ca |
for (int x = 0; x < img.numXLevels(); ++x)
|
|
Packit Service |
6754ca |
loadLevel (in, img, x, y);
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
break;
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
default:
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
assert (false);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
for (Header::ConstIterator i = in.header().begin();
|
|
Packit Service |
6754ca |
i != in.header().end();
|
|
Packit Service |
6754ca |
++i)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
hdr.insert (i.name(), i.attribute());
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
void
|
|
Packit Service |
6754ca |
loadDeepTiledImage
|
|
Packit Service |
6754ca |
(const string &fileName,
|
|
Packit Service |
6754ca |
DeepImage &img)
|
|
Packit Service |
6754ca |
{
|
|
Packit Service |
6754ca |
Header hdr;
|
|
Packit Service |
6754ca |
loadDeepTiledImage (fileName, hdr, img);
|
|
Packit Service |
6754ca |
}
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
|
|
Packit Service |
6754ca |
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|