/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. #ifndef INCLUDED_IMF_INPUT_FILE_H
  35. #define INCLUDED_IMF_INPUT_FILE_H
  36. //-----------------------------------------------------------------------------
  37. //
  38. // class InputFile -- a scanline-based interface that can be used
  39. // to read both scanline-based and tiled OpenEXR image files.
  40. //
  41. //-----------------------------------------------------------------------------
  42. #include <ImfHeader.h>
  43. #include <ImfFrameBuffer.h>
  44. #include <ImfTiledOutputFile.h>
  45. #include <string>
  46. #include <fstream>
  47. #include <ImfThreading.h>
  48. namespace Imf {
  49. class TiledInputFile;
  50. class ScanLineInputFile;
  51. class InputFile
  52. {
  53. public:
  54. //-----------------------------------------------------------
  55. // A constructor that opens the file with the specified name.
  56. // Destroying the InputFile object will close the file.
  57. //
  58. // numThreads determines the number of threads that will be
  59. // used to read the file (see ImfThreading.h).
  60. //-----------------------------------------------------------
  61. InputFile (const char fileName[], int numThreads = globalThreadCount());
  62. //-------------------------------------------------------------
  63. // A constructor that attaches the new InputFile object to a
  64. // file that has already been opened. Destroying the InputFile
  65. // object will not 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. InputFile (IStream &is, int numThreads = globalThreadCount());
  71. //-----------
  72. // Destructor
  73. //-----------
  74. virtual ~InputFile ();
  75. //------------------------
  76. // Access to the file name
  77. //------------------------
  78. const char * fileName () const;
  79. //--------------------------
  80. // Access to the file header
  81. //--------------------------
  82. const Header & header () const;
  83. //----------------------------------
  84. // Access to the file format version
  85. //----------------------------------
  86. int version () const;
  87. //-----------------------------------------------------------
  88. // Set the current frame buffer -- copies the FrameBuffer
  89. // object into the InputFile object.
  90. //
  91. // The current frame buffer is the destination for the pixel
  92. // data read from the file. The current frame buffer must be
  93. // set at least once before readPixels() is called.
  94. // The current frame buffer can be changed after each call
  95. // to readPixels().
  96. //-----------------------------------------------------------
  97. void setFrameBuffer (const FrameBuffer &frameBuffer);
  98. //-----------------------------------
  99. // Access to the current frame buffer
  100. //-----------------------------------
  101. const FrameBuffer & frameBuffer () const;
  102. //---------------------------------------------------------------
  103. // Check if the file is complete:
  104. //
  105. // isComplete() returns true if all pixels in the data window are
  106. // present in the input file, or false if any pixels are missing.
  107. // (Another program may still be busy writing the file, or file
  108. // writing may have been aborted prematurely.)
  109. //---------------------------------------------------------------
  110. bool isComplete () const;
  111. //---------------------------------------------------------------
  112. // Read pixel data:
  113. //
  114. // readPixels(s1,s2) reads all scan lines with y coordinates
  115. // in the interval [min (s1, s2), max (s1, s2)] from the file,
  116. // and stores them in the current frame buffer.
  117. //
  118. // Both s1 and s2 must be within the interval
  119. // [header().dataWindow().min.y, header().dataWindow().max.y]
  120. //
  121. // The scan lines can be read from the file in random order, and
  122. // individual scan lines may be skipped or read multiple times.
  123. // For maximum efficiency, the scan lines should be read in the
  124. // order in which they were written to the file.
  125. //
  126. // readPixels(s) calls readPixels(s,s).
  127. //
  128. //---------------------------------------------------------------
  129. void readPixels (int scanLine1, int scanLine2);
  130. void readPixels (int scanLine);
  131. //----------------------------------------------
  132. // Read a block of raw pixel data from the file,
  133. // without uncompressing it (this function is
  134. // used to implement OutputFile::copyPixels()).
  135. //----------------------------------------------
  136. void rawPixelData (int firstScanLine,
  137. const char *&pixelData,
  138. int &pixelDataSize);
  139. //--------------------------------------------------
  140. // Read a tile of raw pixel data from the file,
  141. // without uncompressing it (this function is
  142. // used to implement TiledOutputFile::copyPixels()).
  143. //--------------------------------------------------
  144. void rawTileData (int &dx, int &dy,
  145. int &lx, int &ly,
  146. const char *&pixelData,
  147. int &pixelDataSize);
  148. struct Data;
  149. private:
  150. InputFile (const InputFile &); // not implemented
  151. InputFile & operator = (const InputFile &); // not implemented
  152. void initialize ();
  153. TiledInputFile * tFile ();
  154. friend void TiledOutputFile::copyPixels (InputFile &);
  155. Data * _data;
  156. };
  157. } // namespace Imf
  158. #endif