Disabled external gits

This commit is contained in:
2022-04-07 18:46:57 +02:00
parent 88cb3426ad
commit 15e7120d6d
5316 changed files with 4563444 additions and 6 deletions

View File

@@ -0,0 +1,16 @@
Makefile
Makefile.in
config.h.in
config.h
config.log
config.status
configure
libtool
stamp-h
aclocal.m4
OpenEXR.pc
autom4te.cache
ltmain.sh
stamp-h.in
depcomp
.deps

View File

@@ -0,0 +1,26 @@
# yue.nicholas@gmail.com
ADD_EXECUTABLE ( exrenvmap
makeLatLongMap.cpp
readInputImage.cpp
resizeImage.cpp
makeCubeMap.cpp
main.cpp
blurImage.cpp
EnvmapImage.cpp
)
TARGET_LINK_LIBRARIES ( exrenvmap
IlmImf
IlmThread${ILMBASE_LIBSUFFIX}
Iex${ILMBASE_LIBSUFFIX}
Half
${PTHREAD_LIB}
${ZLIB_LIBRARIES}
)
INSTALL ( TARGETS
exrenvmap
DESTINATION
${CMAKE_INSTALL_PREFIX}/bin
)

View File

@@ -0,0 +1,275 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// class EnvmapImage
//
//-----------------------------------------------------------------------------
#include "EnvmapImage.h"
#include <ImathFun.h>
#include "namespaceAlias.h"
using namespace IMF;
using namespace IMATH;
EnvmapImage::EnvmapImage ():
_type (ENVMAP_LATLONG),
_dataWindow (V2i (0, 0), V2i (0, 0)),
_pixels (1, 1)
{
clear();
}
EnvmapImage::EnvmapImage (Envmap type, const Box2i &dataWindow):
_type (type),
_dataWindow (dataWindow),
_pixels (dataWindow.max.y - dataWindow.min.y + 1,
dataWindow.max.x - dataWindow.min.x + 1)
{
clear();
}
void
EnvmapImage::resize (Envmap type, const Box2i &dataWindow)
{
_pixels.resizeEraseUnsafe (dataWindow.max.y - dataWindow.min.y + 1,
dataWindow.max.x - dataWindow.min.x + 1);
_type = type;
_dataWindow = dataWindow;
clear();
}
void
EnvmapImage::clear ()
{
int w = _dataWindow.max.x - _dataWindow.min.x + 1;
int h = _dataWindow.max.y - _dataWindow.min.y + 1;
for (int y = 0; y < h; ++y)
{
for (int x = 0; x < w; ++x)
{
Rgba &p = _pixels[y][x];
p.r = 0;
p.g = 0;
p.b = 0;
p.a = 0;
}
}
}
Envmap
EnvmapImage::type () const
{
return _type;
}
const Box2i &
EnvmapImage::dataWindow () const
{
return _dataWindow;
}
Array2D<Rgba> &
EnvmapImage::pixels ()
{
return _pixels;
}
const Array2D<Rgba> &
EnvmapImage::pixels () const
{
return _pixels;
}
namespace {
V2f
dirToPosLatLong (const Box2i &dataWindow, const V3f &dir)
{
return LatLongMap::pixelPosition (dataWindow, dir);
}
V2f
dirToPosCube (const Box2i &dataWindow, const V3f &dir)
{
CubeMapFace face;
V2f posInFace;
CubeMap::faceAndPixelPosition (dir, dataWindow, face, posInFace);
return CubeMap::pixelPosition (face, dataWindow, posInFace);
}
} // namespace
Rgba
EnvmapImage::filteredLookup (V3f d, float r, int n) const
{
//
// Filtered environment map lookup: Take n by n point samples
// from the environment map, clustered around direction d, and
// combine the samples with a tent filter.
//
//
// Depending on the type of map, pick an appropriate function
// to convert 3D directions to 2D pixel poitions.
//
V2f (* dirToPos) (const Box2i &, const V3f &);
if (_type == ENVMAP_LATLONG)
dirToPos = dirToPosLatLong;
else
dirToPos = dirToPosCube;
//
// Pick two vectors, dx and dy, of length r, that are orthogonal
// to the lookup direction, d, and to each other.
//
d.normalize();
V3f dx, dy;
if (abs (d.x) > 0.707f)
dx = (d % V3f (0, 1, 0)).normalized() * r;
else
dx = (d % V3f (1, 0, 0)).normalized() * r;
dy = (d % dx).normalized() * r;
//
// Take n by n point samples from the map, and add them up.
// The directions for the point samples are all within the pyramid
// defined by the vectors d-dy-dx, d-dy+dx, d+dy-dx, d+dy+dx.
//
float wt = 0;
float cr = 0;
float cg = 0;
float cb = 0;
float ca = 0;
for (int y = 0; y < n; ++y)
{
float ry = float (2 * y + 2) / float (n + 1) - 1;
float wy = 1 - abs (ry);
V3f ddy (ry * dy);
for (int x = 0; x < n; ++x)
{
float rx = float (2 * x + 2) / float (n + 1) - 1;
float wx = 1 - abs (rx);
V3f ddx (rx * dx);
Rgba s = sample (dirToPos (_dataWindow, d + ddx + ddy));
float w = wx * wy;
wt += w;
cr += s.r * w;
cg += s.g * w;
cb += s.b * w;
ca += s.a * w;
}
}
wt = 1 / wt;
Rgba c;
c.r = cr * wt;
c.g = cg * wt;
c.b = cb * wt;
c.a = ca * wt;
return c;
}
Rgba
EnvmapImage::sample (const V2f &pos) const
{
//
// Point-sample the environment map image at 2D position pos.
// Interpolate bilinearly between the four nearest pixels.
//
int x1 = IMATH::floor (pos.x);
int x2 = x1 + 1;
float sx = x2 - pos.x;
float tx = 1 - sx;
x1 = clamp (x1, _dataWindow.min.x, _dataWindow.max.x) - _dataWindow.min.x;
x2 = clamp (x2, _dataWindow.min.x, _dataWindow.max.x) - _dataWindow.min.x;
int y1 = IMATH::floor (pos.y);
int y2 = y1 + 1;
float sy = y2 - pos.y;
float ty = 1 - sy;
y1 = clamp (y1, _dataWindow.min.y, _dataWindow.max.y) - _dataWindow.min.y;
y2 = clamp (y2, _dataWindow.min.y, _dataWindow.max.y) - _dataWindow.min.y;
Rgba p11 = _pixels[y1][x1];
Rgba p12 = _pixels[y1][x2];
Rgba p21 = _pixels[y2][x1];
Rgba p22 = _pixels[y2][x2];
Rgba p;
p.r = (p11.r * sx + p12.r * tx) * sy + (p21.r * sx + p22.r * tx) * ty;
p.g = (p11.g * sx + p12.g * tx) * sy + (p21.g * sx + p22.g * tx) * ty;
p.b = (p11.b * sx + p12.b * tx) * sy + (p21.b * sx + p22.b * tx) * ty;
p.a = (p11.a * sx + p12.a * tx) * sy + (p21.a * sx + p22.a * tx) * ty;
return p;
}

View File

@@ -0,0 +1,86 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_ENVMAP_IMAGE_H
#define INCLUDED_ENVMAP_IMAGE_H
//-----------------------------------------------------------------------------
//
// class EnvmapImage
//
//-----------------------------------------------------------------------------
#include "namespaceAlias.h"
#include <ImfArray.h>
#include <ImfRgba.h>
#include <ImfEnvmap.h>
#include <ImathBox.h>
class EnvmapImage
{
public:
EnvmapImage ();
EnvmapImage (IMF::Envmap type, const IMATH::Box2i &dataWindow);
void resize (IMF::Envmap type,
const IMATH::Box2i &dataWindow);
void clear ();
IMF::Envmap type () const;
const IMATH::Box2i & dataWindow () const;
IMF::Array2D<IMF::Rgba> & pixels ();
const IMF::Array2D<IMF::Rgba> &
pixels () const;
IMF::Rgba filteredLookup (IMATH::V3f direction,
float radius,
int numSamples) const;
private:
IMF::Rgba sample (const IMATH::V2f &pos) const;
IMF::Envmap _type;
IMATH::Box2i _dataWindow;
IMF::Array2D<IMF::Rgba> _pixels;
};
#endif

View File

@@ -0,0 +1,31 @@
## Process this file with automake to produce Makefile.in
bin_PROGRAMS = exrenvmap
INCLUDES = -I$(top_builddir) \
-I$(top_srcdir)/IlmImf -I$(top_srcdir)/config \
@ILMBASE_CXXFLAGS@
LDADD = @ILMBASE_LDFLAGS@ @ILMBASE_LIBS@\
$(top_builddir)/IlmImf/libIlmImf.la \
-lz
exrenvmap_SOURCES = main.cpp EnvmapImage.cpp EnvmapImage.h \
readInputImage.cpp readInputImage.h \
resizeImage.cpp resizeImage.h \
blurImage.cpp blurImage.h \
makeCubeMap.cpp makeCubeMap.h \
makeLatLongMap.cpp makeLatLongMap.h \
namespaceAlias.h
noinst_HEADERS = EnvmapImage.h makeCubeMap.h makeLatLongMap.h
EXTRA_DIST = main.cpp EnvmapImage.cpp EnvmapImage.h \
readInputImage.cpp readInputImage.h \
resizeImage.cpp resizeImage.h \
blurImage.cpp blurImage.h \
makeCubeMap.cpp makeCubeMap.h \
makeLatLongMap.cpp makeLatLongMap.h \
namespaceAlias.h \
CMakeLists.txt

View File

@@ -0,0 +1,430 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// function blurImage() -- performs a hemispherical blur
//
//-----------------------------------------------------------------------------
#include "blurImage.h"
#include "namespaceAlias.h"
#include <resizeImage.h>
#include <cstring>
#include "Iex.h"
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace IMF;
using namespace std;
using namespace IMATH;
inline int
toInt (float x)
{
return int (x + 0.5f);
}
inline double
sqr (double x)
{
return x * x;
}
void
blurImage (EnvmapImage &image1, bool verbose)
{
//
// Ideally we would blur the input image directly by convolving
// it with a 180-degree wide blur kernel. Unfortunately this
// is prohibitively expensive when the input image is large.
// In order to keep running times reasonable, we perform the
// blur on a small proxy image that will later be re-sampled
// to the desired output resolution.
//
// Here's how it works:
//
// * If the input image is in latitude-longitude format,
// convert it into a cube-face environment map.
//
// * Repeatedly resample the image, each time shrinking
// it to no less than half its current size, until the
// width of each cube face is MAX_IN_WIDTH pixels.
//
// * Multiply each pixel by a weight that is proportinal
// to the solid angle subtended by the pixel as seen
// from the center of the environment cube.
//
// * Create an output image in cube-face format.
// The cube faces of the output image are OUT_WIDTH
// pixels wide.
//
// * For each pixel of the output image:
//
// Set the output pixel's color to black
//
// Determine the direction, d2, from the center of the
// output environment cube to the center of the output
// pixel.
//
// For each pixel of the input image:
//
// Determine the direction, d1, from the center of
// the input environment cube to the center of the
// input pixel.
//
// Multiply the input pixel's color by max (0, d1.dot(d2))
// and add the result to the output pixel.
//
const int MAX_IN_WIDTH = 40;
const int OUT_WIDTH = 100;
if (verbose)
cout << "blurring map image" << endl;
EnvmapImage image2;
EnvmapImage *iptr1 = &image1;
EnvmapImage *iptr2 = &image2;
int w = image1.dataWindow().max.x - image1.dataWindow().min.x + 1;
int h = w * 6;
if (iptr1->type() == ENVMAP_LATLONG)
{
//
// Convert the input image from latitude-longitude
// to cube-face format.
//
if (verbose)
cout << " converting to cube-face format" << endl;
w /= 4;
h = w * 6;
Box2i dw (V2i (0, 0), V2i (w - 1, h - 1));
resizeCube (*iptr1, *iptr2, dw, 1, 7);
swap (iptr1, iptr2);
}
while (w > MAX_IN_WIDTH)
{
//
// Shrink the image.
//
if (w >= MAX_IN_WIDTH * 2)
w /= 2;
else
w = MAX_IN_WIDTH;
h = w * 6;
if (verbose)
{
cout << " resizing cube faces "
"to " << w << " by " << w << " pixels" << endl;
}
Box2i dw (V2i (0, 0), V2i (w - 1, h - 1));
resizeCube (*iptr1, *iptr2, dw, 1, 7);
swap (iptr1, iptr2);
}
if (verbose)
cout << " computing pixel weights" << endl;
{
//
// Multiply each pixel by a weight that is proportinal
// to the solid angle subtended by the pixel.
//
Box2i dw = iptr1->dataWindow();
int sof = CubeMap::sizeOfFace (dw);
Array2D<Rgba> &pixels = iptr1->pixels();
double weightTotal = 0;
for (int f = CUBEFACE_POS_X; f <= CUBEFACE_NEG_Z; ++f)
{
if (verbose)
cout << " face " << f << endl;
CubeMapFace face = CubeMapFace (f);
V3f faceDir (0, 0, 0);
int ix = 0, iy = 0, iz = 0;
switch (face)
{
case CUBEFACE_POS_X:
faceDir = V3f (1, 0, 0);
ix = 0;
iy = 1;
iz = 2;
break;
case CUBEFACE_NEG_X:
faceDir = V3f (-1, 0, 0);
ix = 0;
iy = 1;
iz = 2;
break;
case CUBEFACE_POS_Y:
faceDir = V3f (0, 1, 0);
ix = 1;
iy = 0;
iz = 2;
break;
case CUBEFACE_NEG_Y:
faceDir = V3f (0, -1, 0);
ix = 1;
iy = 0;
iz = 2;
break;
case CUBEFACE_POS_Z:
faceDir = V3f (0, 0, 1);
ix = 2;
iy = 0;
iz = 1;
break;
case CUBEFACE_NEG_Z:
faceDir = V3f (0, 0, -1);
ix = 2;
iy = 0;
iz = 1;
break;
}
for (int y = 0; y < sof; ++y)
{
bool yEdge = (y == 0 || y == sof - 1);
for (int x = 0; x < sof; ++x)
{
bool xEdge = (x == 0 || x == sof - 1);
V2f posInFace (x, y);
V3f dir =
CubeMap::direction (face, dw, posInFace).normalized();
V2f pos =
CubeMap::pixelPosition (face, dw, posInFace);
//
// The solid angle subtended by pixel (x,y), as seen
// from the center of the cube, is proportional to the
// square of the distance of the pixel from the center
// of the cube and proportional to the dot product of
// the viewing direction and the normal of the cube
// face that contains the pixel.
//
double weight =
(dir ^ faceDir) *
(sqr (dir[iy] / dir[ix]) + sqr (dir[iz] / dir[ix]) + 1);
//
// Pixels at the edges and corners of the
// cube are duplicated; we must adjust the
// pixel weights accordingly.
//
if (xEdge && yEdge)
weight /= 3;
else if (xEdge || yEdge)
weight /= 2;
Rgba &pixel = pixels[toInt (pos.y)][toInt (pos.x)];
pixel.r *= weight;
pixel.g *= weight;
pixel.b *= weight;
pixel.a *= weight;
weightTotal += weight;
}
}
}
//
// The weighting operation above has made the overall image darker.
// Apply a correction to recover the image's original brightness.
//
int w = dw.max.x - dw.min.x + 1;
int h = dw.max.y - dw.min.y + 1;
size_t numPixels = w * h;
double weight = numPixels / weightTotal;
Rgba *p = &pixels[0][0];
Rgba *end = p + numPixels;
while (p < end)
{
p->r *= weight;
p->g *= weight;
p->b *= weight;
p->a *= weight;
++p;
}
}
{
if (verbose)
cout << " generating blurred image" << endl;
Box2i dw1 = iptr1->dataWindow();
int sof1 = CubeMap::sizeOfFace (dw1);
Box2i dw2 (V2i (0, 0), V2i (OUT_WIDTH - 1, OUT_WIDTH * 6 - 1));
int sof2 = CubeMap::sizeOfFace (dw2);
iptr2->resize (ENVMAP_CUBE, dw2);
iptr2->clear ();
Array2D<Rgba> &pixels1 = iptr1->pixels();
Array2D<Rgba> &pixels2 = iptr2->pixels();
for (int f2 = CUBEFACE_POS_X; f2 <= CUBEFACE_NEG_Z; ++f2)
{
if (verbose)
cout << " face " << f2 << endl;
CubeMapFace face2 = CubeMapFace (f2);
for (int y2 = 0; y2 < sof2; ++y2)
{
for (int x2 = 0; x2 < sof2; ++x2)
{
V2f posInFace2 (x2, y2);
V3f dir2 = CubeMap::direction
(face2, dw2, posInFace2);
V2f pos2 = CubeMap::pixelPosition
(face2, dw2, posInFace2);
double weightTotal = 0;
double rTotal = 0;
double gTotal = 0;
double bTotal = 0;
double aTotal = 0;
Rgba &pixel2 =
pixels2[toInt (pos2.y)][toInt (pos2.x)];
for (int f1 = CUBEFACE_POS_X; f1 <= CUBEFACE_NEG_Z; ++f1)
{
CubeMapFace face1 = CubeMapFace (f1);
for (int y1 = 0; y1 < sof1; ++y1)
{
for (int x1 = 0; x1 < sof1; ++x1)
{
V2f posInFace1 (x1, y1);
V3f dir1 = CubeMap::direction
(face1, dw1, posInFace1);
V2f pos1 = CubeMap::pixelPosition
(face1, dw1, posInFace1);
double weight = dir1 ^ dir2;
if (weight <= 0)
continue;
Rgba &pixel1 =
pixels1[toInt (pos1.y)][toInt (pos1.x)];
weightTotal += weight;
rTotal += pixel1.r * weight;
gTotal += pixel1.g * weight;
bTotal += pixel1.b * weight;
aTotal += pixel1.a * weight;
}
}
}
pixel2.r = rTotal / weightTotal;
pixel2.g = gTotal / weightTotal;
pixel2.b = bTotal / weightTotal;
pixel2.a = aTotal / weightTotal;
}
}
}
swap (iptr1, iptr2);
}
//
// Depending on how many times we've re-sampled the image,
// the result is now either in image1 or in image2.
// If necessary, copy the result into image1.
//
if (iptr1 != &image1)
{
if (verbose)
cout << " copying" << endl;
Box2i dw = iptr1->dataWindow();
image1.resize (ENVMAP_CUBE, dw);
int w = dw.max.x - dw.min.x + 1;
int h = dw.max.y - dw.min.y + 1;
size_t size = w * h * sizeof (Rgba);
memcpy (&image1.pixels()[0][0], &iptr1->pixels()[0][0], size);
}
}

View File

@@ -0,0 +1,57 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_BLUR_IMAGE_H
#define INCLUDED_BLUR_IMAGE_H
//-----------------------------------------------------------------------------
//
// function blurImage() -- performs a hemispherical blur
//
// An environment map image is blurred by applying a 180-degree-wide
// filter kernel, such that point-sampling the blurred image at a
// location that corresponds to 3D direction N returns the color that
// a white diffuse reflector with surface normal N would have if it
// was illuminated using the original non-blurred image.
//
//-----------------------------------------------------------------------------
#include <readInputImage.h>
void
blurImage (EnvmapImage &image, bool verbose);
#endif

View File

@@ -0,0 +1,506 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// exrenvmap -- makes OpenEXR environment maps
//
//-----------------------------------------------------------------------------
#include <makeCubeMap.h>
#include <makeLatLongMap.h>
#include <blurImage.h>
#include <EnvmapImage.h>
#include <ImfEnvmap.h>
#include <ImfHeader.h>
#include <iostream>
#include <exception>
#include <string>
#include <string.h>
#include <stdlib.h>
#include "namespaceAlias.h"
using namespace IMF;
using namespace std;
namespace {
void
usageMessage (const char argv0[], bool verbose = false)
{
cerr << "usage: " << argv0 << " [options] infile outfile" << endl;
if (verbose)
{
cerr << "\n"
"Converts OpenEXR latitude-longitude environment maps\n"
"into cube-face environment maps or vice versa.\n"
"Reads an environment map image from infile, converts\n"
"it, and stores the result in outfile.\n"
"\n"
"If the input file name contains a '%' character, then an\n"
"input cube-face environment map is assembled from six\n"
"square sub-images that represent the six faces of the cube.\n"
"The names of the six image files are generated by replacing\n"
"the % with +X, -X, +Y, -Y, +Z and -Z respectively.\n"
"\n"
"If the output file name contains a '%' character and\n"
"the program has been instructed to produce a cube-face\n"
"environment map, then the output image is split into six\n"
"square sub-images that are saved in six separate output\n"
"files. The names of the files are generated by replacing\n"
"the % with +X, -X, +Y, -Y, +Z and -Z respectively.\n"
"\n"
"Options:\n"
"\n"
"-o produces a ONE_LEVEL output file (default)\n"
"\n"
"-m produces a MIPMAP_LEVELS output file (-m has\n"
" no effect if the output image is split into\n"
" multiple files)\n"
"\n"
"-c the output file will be a cube-face environment\n"
" map (default)\n"
"\n"
"-l the output file will be a latitude-longitude\n"
" environment map\n"
"\n"
"-ci the input file is interpreted as a cube-face\n"
" environment map, regardless of its envmap\n"
" attribute\n"
"\n"
"-li the input file is interpreted as a latitude-\n"
" longitude environment map, regardless of its\n"
" envmap attribute (-li has no effect if the\n"
" input image is assembled from multiple files)\n"
"\n"
"-w x sets the width of the output image to x pixels\n"
" (default is 256). The height of the output image\n"
" will be x*6 pixels for a cube-face map, or x/2\n"
" pixels for a latitude-longitude map.\n"
"\n"
"-f r n sets the antialiasing filter radius to r\n"
" (default is 1.0) and the sampling rate to\n"
" n by n (default is 5 by 5). Increasing r\n"
" makes the output image blurrier; decreasing r\n"
" makes the image sharper but may cause aliasing.\n"
" Increasing n improves antialiasing, but\n"
" generating the output image takes longer.\n"
"\n"
"-b blurs the environment map image by applying a\n"
" 180-degree-wide filter kernel such that point-\n"
" sampling the blurred image at a location that\n"
" corresponds to 3D direction N returns the color\n"
" that a white diffuse reflector with surface\n"
" normal N would have if it was illuminated using\n"
" the original non-blurred image.\n"
" Generating the blurred image can be fairly slow.\n"
"\n"
"-t x y sets the output file's tile size to x by y pixels\n"
" (default is 64 by 64)\n"
"\n"
"-p t b if the input image is a latitude-longitude map,\n"
" pad the image at the top and bottom with t*h\n"
" and b*h extra scan lines, where h is the height\n"
" of the input image. This is useful for images\n"
" from 360-degree panoramic scans that cover\n"
" less than 180 degrees vertically.\n"
"\n"
"-d sets level size rounding to ROUND_DOWN (default)\n"
"\n"
"-u sets level size rounding to ROUND_UP\n"
"\n"
"-z x sets the data compression method to x\n"
" (none/rle/zip/piz/pxr24/b44/b44a/dwaa/dwab,\n"
" default is zip)\n"
"\n"
"-v verbose mode\n"
"\n"
"-h prints this message\n";
cerr << endl;
}
exit (1);
}
Compression
getCompression (const string &str)
{
Compression c;
if (str == "no" || str == "none" || str == "NO" || str == "NONE")
{
c = NO_COMPRESSION;
}
else if (str == "rle" || str == "RLE")
{
c = RLE_COMPRESSION;
}
else if (str == "zip" || str == "ZIP")
{
c = ZIP_COMPRESSION;
}
else if (str == "piz" || str == "PIZ")
{
c = PIZ_COMPRESSION;
}
else if (str == "pxr24" || str == "PXR24")
{
c = PXR24_COMPRESSION;
}
else if (str == "b44" || str == "B44")
{
c = B44_COMPRESSION;
}
else if (str == "b44a" || str == "B44A")
{
c = B44A_COMPRESSION;
}
else if (str == "dwaa" || str == "DWAA")
{
c = DWAA_COMPRESSION;
}
else if (str == "dwab" || str == "DWAB")
{
c = DWAB_COMPRESSION;
}
else
{
cerr << "Unknown compression method \"" << str << "\"." << endl;
exit (1);
}
return c;
}
} // namespace
int
main(int argc, char **argv)
{
const char *inFile = 0;
const char *outFile = 0;
Envmap type = ENVMAP_CUBE;
Envmap overrideInputType = NUM_ENVMAPTYPES;
LevelMode levelMode = ONE_LEVEL;
LevelRoundingMode roundingMode = ROUND_DOWN;
Compression compression = ZIP_COMPRESSION;
int mapWidth = 256;
int tileWidth = 64;
int tileHeight = 64;
float padTop = 0;
float padBottom = 0;
float filterRadius = 1;
int numSamples = 5;
bool diffuseBlur = false;
bool verbose = false;
//
// Parse the command line.
//
if (argc < 2)
usageMessage (argv[0], true);
int i = 1;
while (i < argc)
{
if (!strcmp (argv[i], "-o"))
{
//
// generate a ONE_LEVEL image
//
levelMode = ONE_LEVEL;
i += 1;
}
else if (!strcmp (argv[i], "-m"))
{
//
// Generate a MIPMAP_LEVELS image
//
levelMode = MIPMAP_LEVELS;
i += 1;
}
else if (!strcmp (argv[i], "-c"))
{
//
// Generate a cube-face map
//
type = ENVMAP_CUBE;
i += 1;
}
else if (!strcmp (argv[i], "-l"))
{
//
// Generate a latitude-longitude map
//
type = ENVMAP_LATLONG;
i += 1;
}
else if (!strcmp (argv[i], "-ci"))
{
//
// Assume input is a cube-face map
//
overrideInputType = ENVMAP_CUBE;
i += 1;
}
else if (!strcmp (argv[i], "-li"))
{
//
// Assume input is a latitude-longitude map
//
overrideInputType = ENVMAP_LATLONG;
i += 1;
}
else if (!strcmp (argv[i], "-w"))
{
//
// Set output image width
//
if (i > argc - 2)
usageMessage (argv[0]);
mapWidth = strtol (argv[i + 1], 0, 0);
if (mapWidth <= 0)
{
cerr << "Output image width must be greater than zero." << endl;
return 1;
}
i += 2;
}
else if (!strcmp (argv[i], "-f"))
{
//
// Set filter radius and supersampling rate
//
if (i > argc - 3)
usageMessage (argv[0]);
filterRadius = strtod (argv[i + 1], 0);
numSamples = strtol (argv[i + 2], 0, 0);
if (filterRadius < 0)
{
cerr << "Filter radius must not be less than zero." << endl;
return 1;
}
if (numSamples <= 0)
{
cerr << "Sampling rate must be greater than zero." << endl;
return 1;
}
i += 3;
}
else if (!strcmp (argv[i], "-b"))
{
//
// Diffuse blur
//
diffuseBlur = true;
i += 1;
}
else if (!strcmp (argv[i], "-t"))
{
//
// Set tile size
//
if (i > argc - 3)
usageMessage (argv[0]);
tileWidth = strtol (argv[i + 1], 0, 0);
tileHeight = strtol (argv[i + 2], 0, 0);
if (tileWidth <= 0 || tileHeight <= 0)
{
cerr << "Tile size must be greater than zero." << endl;
return 1;
}
i += 3;
}
else if (!strcmp (argv[i], "-p"))
{
//
// Set top and bottom padding
//
if (i > argc - 3)
usageMessage (argv[0]);
padTop = strtod (argv[i + 1], 0);
padBottom = strtod (argv[i + 2], 0);
if (padTop < 0 || padBottom < 0)
{
cerr << "Padding must not be less than zero." << endl;
return 1;
}
i += 3;
}
else if (!strcmp (argv[i], "-d"))
{
//
// Round down
//
roundingMode = ROUND_DOWN;
i += 1;
}
else if (!strcmp (argv[i], "-u"))
{
//
// Round down
//
roundingMode = ROUND_UP;
i += 1;
}
else if (!strcmp (argv[i], "-z"))
{
//
// Set compression method
//
if (i > argc - 2)
usageMessage (argv[0]);
compression = getCompression (argv[i + 1]);
i += 2;
}
else if (!strcmp (argv[i], "-v"))
{
//
// Verbose mode
//
verbose = true;
i += 1;
}
else if (!strcmp (argv[i], "-h"))
{
//
// Print help message
//
usageMessage (argv[0], true);
}
else
{
//
// Image file name
//
if (inFile == 0)
inFile = argv[i];
else
outFile = argv[i];
i += 1;
}
}
if (inFile == 0 || outFile == 0)
usageMessage (argv[0]);
//
// Load inFile, convert it, and save the result in outFile.
//
int exitStatus = 0;
try
{
EnvmapImage image;
Header header;
RgbaChannels channels;
readInputImage (inFile, padTop, padBottom,
overrideInputType, verbose,
image, header, channels);
if (diffuseBlur)
blurImage (image, verbose);
if (type == ENVMAP_CUBE)
{
makeCubeMap (image, header, channels,
outFile,
tileWidth, tileHeight,
levelMode, roundingMode,
compression, mapWidth,
filterRadius, numSamples,
verbose);
}
else
{
makeLatLongMap (image, header, channels,
outFile,
tileWidth, tileHeight,
levelMode, roundingMode,
compression, mapWidth,
filterRadius, numSamples,
verbose);
}
}
catch (const exception &e)
{
cerr << e.what() << endl;
exitStatus = 1;
}
return exitStatus;
}

View File

@@ -0,0 +1,242 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// function makeCubeMap() -- makes cube-face environment maps
//
//-----------------------------------------------------------------------------
#include <makeCubeMap.h>
#include <resizeImage.h>
#include <ImfRgbaFile.h>
#include <ImfTiledRgbaFile.h>
#include <ImfStandardAttributes.h>
#include "Iex.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include "namespaceAlias.h"
using namespace IMF;
using namespace std;
using namespace IMATH;
namespace {
void
makeCubeMapSingleFile (EnvmapImage &image1,
Header &header,
RgbaChannels channels,
const char outFileName[],
int tileWidth,
int tileHeight,
LevelMode levelMode,
LevelRoundingMode roundingMode,
Compression compression,
int mapWidth,
float filterRadius,
int numSamples,
bool verbose)
{
if (levelMode == RIPMAP_LEVELS)
throw IEX::NoImplExc ("Cannot generate ripmap cube-face environments.");
//
// Open the file that will contain the cube-face map,
// and write the header.
//
int mapHeight = mapWidth * 6;
header.dataWindow() = Box2i (V2i (0, 0), V2i (mapWidth - 1, mapHeight - 1));
header.displayWindow() = header.dataWindow();
header.compression() = compression;
addEnvmap (header, ENVMAP_CUBE);
TiledRgbaOutputFile out (outFileName,
header,
channels,
tileWidth, tileHeight,
levelMode,
roundingMode);
if (verbose)
cout << "writing file " << outFileName << endl;
//
// Generate the pixels for the various levels of the cube-face map,
// and store them in the file. The pixels for the highest-resolution
// level are generated by resampling the original input image; for
// each of the other levels, the pixels are generated by resampling
// the previous level.
//
EnvmapImage image2;
EnvmapImage *iptr1 = &image1;
EnvmapImage *iptr2 = &image2;
for (int level = 0; level < out.numLevels(); ++level)
{
if (verbose)
cout << "level " << level << endl;
Box2i dw = out.dataWindowForLevel (level);
resizeCube (*iptr1, *iptr2, dw, filterRadius, numSamples);
out.setFrameBuffer (&iptr2->pixels()[0][0], 1, dw.max.x + 1);
for (int tileY = 0; tileY < out.numYTiles (level); ++tileY)
for (int tileX = 0; tileX < out.numXTiles (level); ++tileX)
out.writeTile (tileX, tileY, level);
swap (iptr1, iptr2);
}
if (verbose)
cout << "done." << endl;
}
void
makeCubeMapSixFiles (EnvmapImage &image1,
Header &header,
RgbaChannels channels,
const char outFileName[],
int tileWidth,
int tileHeight,
Compression compression,
int mapWidth,
float filterRadius,
int numSamples,
bool verbose)
{
static const char *faceNames[] =
{"+X", "-X", "+Y", "-Y", "+Z", "-Z"};
size_t pos = strchr (outFileName, '%') - outFileName;
int mapHeight = mapWidth * 6;
const Box2i dw (V2i (0, 0), V2i (mapWidth - 1, mapHeight - 1));
const Box2i faceDw (V2i (0, 0), V2i (mapWidth - 1, mapWidth - 1));
EnvmapImage image2;
resizeCube (image1, image2, dw, filterRadius, numSamples);
const Rgba *pixels = &(image2.pixels())[0][0];
for (int i = 0; i < 6; ++i)
{
string name = string (outFileName).replace (pos, 1, faceNames[i]);
if (verbose)
cout << "writing file " << name << endl;
TiledRgbaOutputFile out (name.c_str(),
tileWidth, tileHeight,
ONE_LEVEL, ROUND_DOWN,
faceDw, // displayWindow
faceDw, // dataWindow
channels,
1, // pixelAspectRatio
V2f (0, 0), // screenWindowCenter
1, // screenWindowWidth
INCREASING_Y, // lineOrder
compression);
out.setFrameBuffer (pixels, 1, dw.max.x + 1);
for (int tileY = 0; tileY < out.numYTiles(); ++tileY)
for (int tileX = 0; tileX < out.numXTiles(); ++tileX)
out.writeTile (tileX, tileY);
pixels += mapWidth * mapWidth;
}
if (verbose)
cout << "done." << endl;
}
} //namespace
void
makeCubeMap (EnvmapImage &image1,
Header &header,
RgbaChannels channels,
const char outFileName[],
int tileWidth,
int tileHeight,
LevelMode levelMode,
LevelRoundingMode roundingMode,
Compression compression,
int mapWidth,
float filterRadius,
int numSamples,
bool verbose)
{
if (strchr (outFileName, '%'))
{
makeCubeMapSixFiles (image1,
header,
channels,
outFileName,
tileWidth,
tileHeight,
compression,
mapWidth,
filterRadius,
numSamples,
verbose);
}
else
{
makeCubeMapSingleFile (image1,
header,
channels,
outFileName,
tileWidth,
tileHeight,
levelMode,
roundingMode,
compression,
mapWidth,
filterRadius,
numSamples,
verbose);
}
}

View File

@@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_MAKE_CUBE_MAP_H
#define INCLUDED_MAKE_CUBE_MAP_H
//-----------------------------------------------------------------------------
//
// function makeCubeMap() -- makes cube-face environment maps
//
//-----------------------------------------------------------------------------
#include "readInputImage.h"
#include "namespaceAlias.h"
#include <ImfTileDescription.h>
#include <ImfCompression.h>
void
makeCubeMap (EnvmapImage &image,
IMF::Header &header,
IMF::RgbaChannels channels,
const char outFileName[],
int tileWidth,
int tileHeight,
IMF::LevelMode levelMode,
IMF::LevelRoundingMode roundingMode,
IMF::Compression compression,
int mapWidth,
float filterRadius,
int numSamples,
bool verbose);
#endif

View File

@@ -0,0 +1,133 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// function makeLatLongMap() -- makes latitude-longitude environment maps
//
//-----------------------------------------------------------------------------
#include <makeLatLongMap.h>
#include <resizeImage.h>
#include <ImfRgbaFile.h>
#include <ImfTiledRgbaFile.h>
#include <ImfStandardAttributes.h>
#include "Iex.h"
#include <iostream>
#include <algorithm>
#include "namespaceAlias.h"
using namespace IMF;
using namespace std;
using namespace IMATH;
void
makeLatLongMap (EnvmapImage &image1,
Header &header,
RgbaChannels channels,
const char outFileName[],
int tileWidth,
int tileHeight,
LevelMode levelMode,
LevelRoundingMode roundingMode,
Compression compression,
int mapWidth,
float filterRadius,
int numSamples,
bool verbose)
{
if (levelMode == RIPMAP_LEVELS)
{
throw IEX::NoImplExc ("Cannot generate ripmap "
"latitude-longitude environments.");
}
//
// Open the file that will contain the latitude-longitude map,
// and write the header.
//
int mapHeight = mapWidth / 2;
header.dataWindow() = Box2i (V2i (0, 0), V2i (mapWidth - 1, mapHeight - 1));
header.displayWindow() = header.dataWindow();
header.compression() = compression;
addEnvmap (header, ENVMAP_LATLONG);
TiledRgbaOutputFile out (outFileName,
header,
channels,
tileWidth, tileHeight,
levelMode,
roundingMode);
if (verbose)
cout << "writing file " << outFileName << endl;
//
// Generate the pixels for the various levels of the latitude-longitude
// map, and store them in the file. The pixels for the highest-resolution
// level are generated by resampling the original input image; for each of
// the other levels, the pixels are generated by resampling the previous
// level.
//
EnvmapImage image2;
EnvmapImage *iptr1 = &image1;
EnvmapImage *iptr2 = &image2;
for (int level = 0; level < out.numLevels(); ++level)
{
if (verbose)
cout << "level " << level << endl;
Box2i dw = out.dataWindowForLevel (level);
resizeLatLong (*iptr1, *iptr2, dw, filterRadius, numSamples);
out.setFrameBuffer (&(iptr2->pixels()[0][0]), 1, dw.max.x + 1);
for (int tileY = 0; tileY < out.numYTiles (level); ++tileY)
for (int tileX = 0; tileX < out.numXTiles (level); ++tileX)
out.writeTile (tileX, tileY, level);
swap (iptr1, iptr2);
}
if (verbose)
cout << "done." << endl;
}

View File

@@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_MAKE_LATLONG_MAP_H
#define INCLUDED_MAKE_LATLONG_MAP_H
//-----------------------------------------------------------------------------
//
// function makeLatLongMap() -- makes latitude-longitude environment maps
//
//-----------------------------------------------------------------------------
#include <ImfTileDescription.h>
#include <ImfCompression.h>
#include <readInputImage.h>
#include "namespaceAlias.h"
void
makeLatLongMap (EnvmapImage &image,
IMF::Header &header,
IMF::RgbaChannels channels,
const char outFileName[],
int tileWidth,
int tileHeight,
IMF::LevelMode levelMode,
IMF::LevelRoundingMode roundingMode,
IMF::Compression compresssion,
int mapWidth,
float filterRadius,
int numSamples,
bool verbose);
#endif // INCLUDED_MAKE_LATLONG_MAP_H

View File

@@ -0,0 +1,45 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef NAMESPACEALIAS_H_
#define NAMESPACEALIAS_H_
#include "ImfNamespace.h"
#include "ImathNamespace.h"
#include "IexNamespace.h"
namespace IMF = OPENEXR_IMF_NAMESPACE;
namespace IMATH = IMATH_NAMESPACE;
namespace IEX = IEX_NAMESPACE;
#endif /* NAMESPACEALIAS_H_ */

View File

@@ -0,0 +1,236 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// function readInputImage() --
// reads an image file and constructs an EnvMapImage object
//
//-----------------------------------------------------------------------------
#include <makeCubeMap.h>
#include <ImfRgbaFile.h>
#include <ImfStandardAttributes.h>
#include <EnvmapImage.h>
#include "Iex.h"
#include "IexMacros.h"
#include <iostream>
#include <string>
#include <string.h>
#include "namespaceAlias.h"
using namespace IMF;
using namespace std;
using namespace IMATH;
namespace {
void
readSingleImage (const char inFileName[],
float padTop,
float padBottom,
Envmap overrideType,
bool verbose,
EnvmapImage &image,
Header &header,
RgbaChannels &channels)
{
//
// Read the input image, and if necessary,
// pad the image at the top and bottom.
//
RgbaInputFile in (inFileName);
if (verbose)
cout << "reading file " << inFileName << endl;
header = in.header();
channels = in.channels();
Envmap type = ENVMAP_LATLONG;
if (hasEnvmap (in.header()))
type = envmap (in.header());
if (overrideType == ENVMAP_LATLONG ||
overrideType == ENVMAP_CUBE)
{
type = overrideType;
addEnvmap (header, overrideType);
}
const Box2i &dw = in.dataWindow();
int w = dw.max.x - dw.min.x + 1;
int h = dw.max.y - dw.min.y + 1;
int pt = 0;
int pb = 0;
if (type == ENVMAP_LATLONG)
{
pt = int (padTop * h + 0.5f);
pb = int (padBottom * h + 0.5f);
}
Box2i paddedDw (V2i (dw.min.x, dw.min.y - pt),
V2i (dw.max.x, dw.max.y + pb));
image.resize (type, paddedDw);
Array2D<Rgba> &pixels = image.pixels();
in.setFrameBuffer (&pixels[-paddedDw.min.y][-paddedDw.min.x], 1, w);
in.readPixels (dw.min.y, dw.max.y);
for (int y = 0; y < pt; ++y)
for (int x = 0; x < w; ++x)
pixels[y][x] = pixels[pt][x];
for (int y = h + pt; y < h + pt + pb; ++y)
{
for (int x = 0; x < w; ++x)
pixels[y][x] = pixels[h + pt - 1][x];
}
}
void
readSixImages (const char inFileName[],
bool verbose,
EnvmapImage &image,
Header &header,
RgbaChannels &channels)
{
//
// Generate six file names by replacing the first '%' character in
// inFileName with +X, -X, ... -Z. Interpreting the corresponding
// image files as the six sides of a cube, assembe a single cube-
// face map image.
//
static const char *faceNames[] =
{"+X", "-X", "+Y", "-Y", "+Z", "-Z"};
size_t pos = strchr (inFileName, '%') - inFileName;
string name = string(inFileName).replace (pos, 1, faceNames[0]);
Box2i dw;
int w, h;
{
RgbaInputFile in (name.c_str());
if (verbose)
cout << "reading cube face size from file " << name << endl;
dw = in.dataWindow();
w = dw.max.x - dw.min.x + 1;
h = dw.max.y - dw.min.y + 1;
if (w != h)
{
THROW (IEX::InputExc,
"Cube face image " << name << " is not square.");
}
header = in.header();
channels = in.channels();
addEnvmap (header, ENVMAP_CUBE);
}
const Box2i imageDw (V2i (0, 0), V2i (w - 1, 6 * h - 1));
image.resize (ENVMAP_CUBE, imageDw);
Rgba *pixels = &(image.pixels()[0][0]);
for (int i = 0; i < 6; ++i)
{
string name = string(inFileName).replace (pos, 1, faceNames[i]);
RgbaInputFile in (name.c_str());
if (verbose)
cout << "reading file " << name << endl;
if (in.dataWindow() != dw)
{
THROW (IEX::InputExc,
"The data window of cube face " << name << " differs "
"from the data window of other cube faces.");
}
in.setFrameBuffer (pixels - dw.min.x - dw.min.y * w, 1, w);
in.readPixels (dw.min.y, dw.max.y);
pixels += w * h;
}
}
} // namespace
void
readInputImage (const char inFileName[],
float padTop,
float padBottom,
Envmap overrideType,
bool verbose,
EnvmapImage &image,
Header &header,
RgbaChannels &channels)
{
if (strchr (inFileName, '%'))
{
readSixImages (inFileName,
verbose,
image,
header,
channels);
}
else
{
readSingleImage (inFileName,
padTop,
padBottom,
overrideType,
verbose,
image,
header,
channels);
}
}

View File

@@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_READ_INPUT_IMAGE_H
#define INCLUDED_READ_INPUT_IMAGE_H
//-----------------------------------------------------------------------------
//
// function readInputImage() --
// reads an image file and constructs an EnvMapImage object
//
//-----------------------------------------------------------------------------
#include <ImfRgba.h>
#include <ImfEnvmap.h>
#include <ImfForward.h>
#include "namespaceAlias.h"
class EnvmapImage;
void
readInputImage (const char inFileName[],
float padTop,
float padBottom,
IMF::Envmap overrideType,
bool verbose,
EnvmapImage &image,
IMF::Header &header,
IMF::RgbaChannels &channels);
#endif

View File

@@ -0,0 +1,142 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// resizeLatLong(), resizeCube() -- functions that resample
// an environment map and convert it to latitude-longitude or
// cube-face format.
//
//-----------------------------------------------------------------------------
#include <resizeImage.h>
#include "Iex.h"
#include <string.h>
#include "namespaceAlias.h"
using namespace IMF;
using namespace std;
using namespace IMATH;
void
resizeLatLong (const EnvmapImage &image1,
EnvmapImage &image2,
const Box2i &image2DataWindow,
float filterRadius,
int numSamples)
{
int w = image2DataWindow.max.x - image2DataWindow.min.x + 1;
int h = image2DataWindow.max.y - image2DataWindow.min.y + 1;
float radius = 0.5f * 2 * M_PI * filterRadius / w;
image2.resize (ENVMAP_LATLONG, image2DataWindow);
image2.clear ();
Array2D<Rgba> &pixels = image2.pixels();
for (int y = 0; y < h; ++y)
{
for (int x = 0; x < w; ++x)
{
V3f dir = LatLongMap::direction (image2DataWindow, V2f (x, y));
pixels[y][x] = image1.filteredLookup (dir, radius, numSamples);
}
}
}
void
resizeCube (const EnvmapImage &image1,
EnvmapImage &image2,
const Box2i &image2DataWindow,
float filterRadius,
int numSamples)
{
if (image1.type() == ENVMAP_CUBE && image1.dataWindow() == image2DataWindow)
{
//
// Special case - the input image is a cube-face environment
// map with the same size as the output image. We can copy
// the input image without resampling.
//
image2.resize (ENVMAP_CUBE, image2DataWindow);
int w = image2DataWindow.max.x - image2DataWindow.min.x + 1;
int h = image2DataWindow.max.y - image2DataWindow.min.y + 1;
memcpy (&(image2.pixels()[0][0]),
&(image1.pixels()[0][0]),
sizeof (Rgba) * w * h);
return;
}
//
// Resampe the input image
//
int sof = CubeMap::sizeOfFace (image2DataWindow);
float radius = 1.5f * filterRadius / sof;
image2.resize (ENVMAP_CUBE, image2DataWindow);
image2.clear ();
Array2D<Rgba> &pixels = image2.pixels();
for (int f = CUBEFACE_POS_X; f <= CUBEFACE_NEG_Z; ++f)
{
CubeMapFace face = CubeMapFace (f);
for (int y = 0; y < sof; ++y)
{
for (int x = 0; x < sof; ++x)
{
V2f posInFace (x, y);
V3f dir =
CubeMap::direction (face, image2DataWindow, posInFace);
V2f pos =
CubeMap::pixelPosition (face, image2DataWindow, posInFace);
pixels[int (pos.y + 0.5f)][int (pos.x + 0.5f)] =
image1.filteredLookup (dir, radius, numSamples);
}
}
}
}

View File

@@ -0,0 +1,64 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_RESIZE_IMAGE_H
#define INCLUDED_RESIZE_IMAGE_H
//-----------------------------------------------------------------------------
//
// resizeLatLong(), resizeCube() -- functions that resample
// an environment map and convert it to latitude-longitude or
// cube-face format.
//
//-----------------------------------------------------------------------------
#include "EnvmapImage.h"
void
resizeLatLong (const EnvmapImage &image1,
EnvmapImage &image2,
const IMATH::Box2i &image2DataWindow,
float filterRadius,
int numSamples);
void
resizeCube (const EnvmapImage &image1,
EnvmapImage &image2,
const IMATH::Box2i &image2DataWindow,
float filterRadius,
int numSamples);
#endif