Add support for EXR files
This commit is contained in:
parent
88c811fca5
commit
18c452a2a6
@ -13,7 +13,9 @@ ELSE (WIN32)
|
|||||||
|
|
||||||
FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h
|
FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h
|
||||||
/usr/include
|
/usr/include
|
||||||
/usr/local/include)
|
/usr/local/include
|
||||||
|
/usr/include/OpenEXR
|
||||||
|
/usr/local/include/OpenEXR)
|
||||||
|
|
||||||
FIND_LIBRARY(OPENEXR_HALF_LIBRARY
|
FIND_LIBRARY(OPENEXR_HALF_LIBRARY
|
||||||
NAMES Half
|
NAMES Half
|
||||||
@ -41,10 +43,10 @@ ELSE (WIN32)
|
|||||||
|
|
||||||
ENDIF (WIN32)
|
ENDIF (WIN32)
|
||||||
|
|
||||||
IF (OPENEXR_INCLUDE_DIR AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
|
IF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
|
||||||
SET(OPENEXR_FOUND TRUE)
|
SET(OPENEXR_FOUND TRUE)
|
||||||
SET(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} CACHE STRING "The libraries needed to use OpenEXR")
|
SET(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} CACHE STRING "The libraries needed to use OpenEXR")
|
||||||
ENDIF (OPENEXR_INCLUDE_DIR AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
|
ENDIF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
MARK_AS_ADVANCED(
|
||||||
OPENEXR_INCLUDE_DIR
|
OPENEXR_INCLUDE_DIR
|
||||||
|
@ -1019,26 +1019,31 @@ FloatImage * nv::ImageIO::loadFloatEXR(const char * fileName, Stream & s)
|
|||||||
int width = box.max.x - box.min.y + 1;
|
int width = box.max.x - box.min.y + 1;
|
||||||
int height = box.max.x - box.min.y + 1;
|
int height = box.max.x - box.min.y + 1;
|
||||||
|
|
||||||
Array2D<Rgba> pixels;
|
const Imf::ChannelList & channels = inputFile.header().channels();
|
||||||
pixels.resizeErase (height, width);
|
|
||||||
|
|
||||||
inputFile.setFrameBuffer (&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
|
// Count channels.
|
||||||
inputFile.readPixels (box.min.y, box.max.y);
|
uint channelCount= 0;
|
||||||
|
for (ChannelList::ConstIterator it = channels.begin(); it != channels.end(); ++it)
|
||||||
|
{
|
||||||
|
channelCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate FloatImage.
|
||||||
AutoPtr<FloatImage> fimage(new FloatImage());
|
AutoPtr<FloatImage> fimage(new FloatImage());
|
||||||
fimage->allocate(spp, width, height);
|
fimage->allocate(channelCount, width, height);
|
||||||
|
|
||||||
for (int y = 0; y < height; y++)
|
// Describe image's layout with a framebuffer.
|
||||||
|
FrameBuffer frameBuffer;
|
||||||
|
uint i = 0;
|
||||||
|
for (ChannelList::ConstIterator it = channels.begin(); it != channels.end(); ++it, ++i)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < width; x++)
|
frameBuffer.insert(it.name(), Slice(FLOAT, fimage->channel(i), sizeof(float), sizeof(float) * width));
|
||||||
{
|
|
||||||
fimage->setPixel(imagePixel.r, x, y, 0);
|
|
||||||
fimage->setPixel(imagePixel.g, x, y, 1);
|
|
||||||
fimage->setPixel(imagePixel.b, x, y, 2);
|
|
||||||
fimage->setPixel(imagePixel.a, x, y, 3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read it.
|
||||||
|
inputFile.setFrameBuffer (frameBuffer);
|
||||||
|
inputFile.readPixels (box.min.y, box.max.y);
|
||||||
|
|
||||||
return fimage.release();
|
return fimage.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user