Path: blob/master/3rdparty/openexr/IlmImf/ImfInputFile.h
16337 views
///////////////////////////////////////////////////////////////////////////1//2// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas3// Digital Ltd. LLC4//5// All rights reserved.6//7// Redistribution and use in source and binary forms, with or without8// modification, are permitted provided that the following conditions are9// met:10// * Redistributions of source code must retain the above copyright11// notice, this list of conditions and the following disclaimer.12// * Redistributions in binary form must reproduce the above13// copyright notice, this list of conditions and the following disclaimer14// in the documentation and/or other materials provided with the15// distribution.16// * Neither the name of Industrial Light & Magic nor the names of17// its contributors may be used to endorse or promote products derived18// from this software without specific prior written permission.19//20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.31//32///////////////////////////////////////////////////////////////////////////333435#ifndef INCLUDED_IMF_INPUT_FILE_H36#define INCLUDED_IMF_INPUT_FILE_H3738//-----------------------------------------------------------------------------39//40// class InputFile -- a scanline-based interface that can be used41// to read both scanline-based and tiled OpenEXR image files.42//43//-----------------------------------------------------------------------------4445#include <ImfHeader.h>46#include <ImfFrameBuffer.h>47#include <ImfTiledOutputFile.h>48#include <string>49#include <fstream>50#include <ImfThreading.h>5152namespace Imf {5354class TiledInputFile;55class ScanLineInputFile;565758class InputFile59{60public:6162//-----------------------------------------------------------63// A constructor that opens the file with the specified name.64// Destroying the InputFile object will close the file.65//66// numThreads determines the number of threads that will be67// used to read the file (see ImfThreading.h).68//-----------------------------------------------------------6970InputFile (const char fileName[], int numThreads = globalThreadCount());717273//-------------------------------------------------------------74// A constructor that attaches the new InputFile object to a75// file that has already been opened. Destroying the InputFile76// object will not close the file.77//78// numThreads determines the number of threads that will be79// used to read the file (see ImfThreading.h).80//-------------------------------------------------------------8182InputFile (IStream &is, int numThreads = globalThreadCount());838485//-----------86// Destructor87//-----------8889virtual ~InputFile ();909192//------------------------93// Access to the file name94//------------------------9596const char * fileName () const;979899//--------------------------100// Access to the file header101//--------------------------102103const Header & header () const;104105106//----------------------------------107// Access to the file format version108//----------------------------------109110int version () const;111112113//-----------------------------------------------------------114// Set the current frame buffer -- copies the FrameBuffer115// object into the InputFile object.116//117// The current frame buffer is the destination for the pixel118// data read from the file. The current frame buffer must be119// set at least once before readPixels() is called.120// The current frame buffer can be changed after each call121// to readPixels().122//-----------------------------------------------------------123124void setFrameBuffer (const FrameBuffer &frameBuffer);125126127//-----------------------------------128// Access to the current frame buffer129//-----------------------------------130131const FrameBuffer & frameBuffer () const;132133134//---------------------------------------------------------------135// Check if the file is complete:136//137// isComplete() returns true if all pixels in the data window are138// present in the input file, or false if any pixels are missing.139// (Another program may still be busy writing the file, or file140// writing may have been aborted prematurely.)141//---------------------------------------------------------------142143bool isComplete () const;144145146//---------------------------------------------------------------147// Read pixel data:148//149// readPixels(s1,s2) reads all scan lines with y coordinates150// in the interval [min (s1, s2), max (s1, s2)] from the file,151// and stores them in the current frame buffer.152//153// Both s1 and s2 must be within the interval154// [header().dataWindow().min.y, header().dataWindow().max.y]155//156// The scan lines can be read from the file in random order, and157// individual scan lines may be skipped or read multiple times.158// For maximum efficiency, the scan lines should be read in the159// order in which they were written to the file.160//161// readPixels(s) calls readPixels(s,s).162//163//---------------------------------------------------------------164165void readPixels (int scanLine1, int scanLine2);166void readPixels (int scanLine);167168169//----------------------------------------------170// Read a block of raw pixel data from the file,171// without uncompressing it (this function is172// used to implement OutputFile::copyPixels()).173//----------------------------------------------174175void rawPixelData (int firstScanLine,176const char *&pixelData,177int &pixelDataSize);178179//--------------------------------------------------180// Read a tile of raw pixel data from the file,181// without uncompressing it (this function is182// used to implement TiledOutputFile::copyPixels()).183//--------------------------------------------------184185void rawTileData (int &dx, int &dy,186int &lx, int &ly,187const char *&pixelData,188int &pixelDataSize);189190struct Data;191192private:193194InputFile (const InputFile &); // not implemented195InputFile & operator = (const InputFile &); // not implemented196197void initialize ();198TiledInputFile * tFile ();199200friend void TiledOutputFile::copyPixels (InputFile &);201202Data * _data;203};204205206} // namespace Imf207208#endif209210211