PageRenderTime 40ms CodeModel.GetById 16ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/src/FreeImage/Source/OpenEXR/IlmImf/ImfInputFile.h

https://bitbucket.org/cabalistic/ogredeps/
C++ Header | 209 lines | 43 code | 51 blank | 115 comment | 0 complexity | 202fe3b1707715cf7f4d29267e7cad67 MD5 | raw file
  1///////////////////////////////////////////////////////////////////////////
  2//
  3// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
  4// Digital Ltd. LLC
  5// 
  6// All rights reserved.
  7// 
  8// Redistribution and use in source and binary forms, with or without
  9// modification, are permitted provided that the following conditions are
 10// met:
 11// *       Redistributions of source code must retain the above copyright
 12// notice, this list of conditions and the following disclaimer.
 13// *       Redistributions in binary form must reproduce the above
 14// copyright notice, this list of conditions and the following disclaimer
 15// in the documentation and/or other materials provided with the
 16// distribution.
 17// *       Neither the name of Industrial Light & Magic nor the names of
 18// its contributors may be used to endorse or promote products derived
 19// from this software without specific prior written permission. 
 20// 
 21// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 22// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 23// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 24// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 25// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 26// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 27// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 28// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 29// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 30// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 31// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32//
 33///////////////////////////////////////////////////////////////////////////
 34
 35
 36#ifndef INCLUDED_IMF_INPUT_FILE_H
 37#define INCLUDED_IMF_INPUT_FILE_H
 38
 39//-----------------------------------------------------------------------------
 40//
 41//	class InputFile -- a scanline-based interface that can be used
 42//	to read both scanline-based and tiled OpenEXR image files.
 43//
 44//-----------------------------------------------------------------------------
 45
 46#include <ImfHeader.h>
 47#include <ImfFrameBuffer.h>
 48#include <ImfTiledOutputFile.h>
 49#include <string>
 50#include <fstream>
 51#include <ImfThreading.h>
 52
 53namespace Imf {
 54
 55class TiledInputFile;
 56class ScanLineInputFile;
 57
 58
 59class InputFile
 60{
 61  public:
 62
 63    //-----------------------------------------------------------
 64    // A constructor that opens the file with the specified name.
 65    // Destroying the InputFile object will close the file.
 66    //
 67    // numThreads determines the number of threads that will be
 68    // used to read the file (see ImfThreading.h).
 69    //-----------------------------------------------------------
 70
 71    InputFile (const char fileName[], int numThreads = globalThreadCount());
 72
 73
 74    //-------------------------------------------------------------
 75    // A constructor that attaches the new InputFile object to a
 76    // file that has already been opened.  Destroying the InputFile
 77    // object will not close the file.
 78    //
 79    // numThreads determines the number of threads that will be
 80    // used to read the file (see ImfThreading.h).
 81    //-------------------------------------------------------------
 82
 83    InputFile (IStream &is, int numThreads = globalThreadCount());
 84
 85
 86    //-----------
 87    // Destructor
 88    //-----------
 89
 90    virtual ~InputFile ();
 91
 92
 93    //------------------------
 94    // Access to the file name
 95    //------------------------
 96
 97    const char *	fileName () const;
 98
 99
100    //--------------------------
101    // Access to the file header
102    //--------------------------
103
104    const Header &	header () const;
105
106
107    //----------------------------------
108    // Access to the file format version
109    //----------------------------------
110
111    int			version () const;
112
113
114    //-----------------------------------------------------------
115    // Set the current frame buffer -- copies the FrameBuffer
116    // object into the InputFile object.
117    //
118    // The current frame buffer is the destination for the pixel
119    // data read from the file.  The current frame buffer must be
120    // set at least once before readPixels() is called.
121    // The current frame buffer can be changed after each call
122    // to readPixels().
123    //-----------------------------------------------------------
124
125    void		setFrameBuffer (const FrameBuffer &frameBuffer);
126
127
128    //-----------------------------------
129    // Access to the current frame buffer
130    //-----------------------------------
131
132    const FrameBuffer &	frameBuffer () const;
133
134
135    //---------------------------------------------------------------
136    // Check if the file is complete:
137    //
138    // isComplete() returns true if all pixels in the data window are
139    // present in the input file, or false if any pixels are missing.
140    // (Another program may still be busy writing the file, or file
141    // writing may have been aborted prematurely.)
142    //---------------------------------------------------------------
143
144    bool		isComplete () const;
145
146
147    //---------------------------------------------------------------
148    // Read pixel data:
149    //
150    // readPixels(s1,s2) reads all scan lines with y coordinates
151    // in the interval [min (s1, s2), max (s1, s2)] from the file,
152    // and stores them in the current frame buffer.
153    //
154    // Both s1 and s2 must be within the interval
155    // [header().dataWindow().min.y, header().dataWindow().max.y]
156    //
157    // The scan lines can be read from the file in random order, and
158    // individual scan lines may be skipped or read multiple times.
159    // For maximum efficiency, the scan lines should be read in the
160    // order in which they were written to the file.
161    //
162    // readPixels(s) calls readPixels(s,s).
163    //
164    //---------------------------------------------------------------
165
166    void		readPixels (int scanLine1, int scanLine2);
167    void		readPixels (int scanLine);
168
169
170    //----------------------------------------------
171    // Read a block of raw pixel data from the file,
172    // without uncompressing it (this function is
173    // used to implement OutputFile::copyPixels()).
174    //----------------------------------------------
175
176    void		rawPixelData (int firstScanLine,
177				      const char *&pixelData,
178				      int &pixelDataSize);
179                                     
180    //--------------------------------------------------
181    // Read a tile of raw pixel data from the file,
182    // without uncompressing it (this function is
183    // used to implement TiledOutputFile::copyPixels()).
184    //--------------------------------------------------
185
186    void		rawTileData (int &dx, int &dy,
187				     int &lx, int &ly,
188				     const char *&pixelData,
189				     int &pixelDataSize);
190
191    struct Data;
192    
193  private:
194
195    InputFile (const InputFile &);			// not implemented
196    InputFile & operator = (const InputFile &);		// not implemented
197
198    void		initialize ();
199    TiledInputFile *	tFile ();
200    
201    friend void TiledOutputFile::copyPixels (InputFile &);
202    
203    Data *		_data;
204};
205
206
207} // namespace Imf
208
209#endif