ImfDeepScanLineOutputPart.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2011, 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 IMFDEEPSCANLINEOUTPUTPART_H_
  35. #define IMFDEEPSCANLINEOUTPUTPART_H_
  36. #include "ImfDeepScanLineOutputFile.h"
  37. #include "ImfMultiPartOutputFile.h"
  38. #include "ImfNamespace.h"
  39. #include "ImfExport.h"
  40. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  41. class DeepScanLineOutputPart
  42. {
  43. public:
  44. IMF_EXPORT
  45. DeepScanLineOutputPart(MultiPartOutputFile& multiPartFile, int partNumber);
  46. //------------------------
  47. // Access to the file name
  48. //------------------------
  49. IMF_EXPORT
  50. const char * fileName () const;
  51. //--------------------------
  52. // Access to the file header
  53. //--------------------------
  54. IMF_EXPORT
  55. const Header & header () const;
  56. //-------------------------------------------------------
  57. // Set the current frame buffer -- copies the FrameBuffer
  58. // object into the OutputFile object.
  59. //
  60. // The current frame buffer is the source of the pixel
  61. // data written to the file. The current frame buffer
  62. // must be set at least once before writePixels() is
  63. // called. The current frame buffer can be changed
  64. // after each call to writePixels.
  65. //-------------------------------------------------------
  66. IMF_EXPORT
  67. void setFrameBuffer (const DeepFrameBuffer &frameBuffer);
  68. //-----------------------------------
  69. // Access to the current frame buffer
  70. //-----------------------------------
  71. IMF_EXPORT
  72. const DeepFrameBuffer & frameBuffer () const;
  73. //-------------------------------------------------------------------
  74. // Write pixel data:
  75. //
  76. // writePixels(n) retrieves the next n scan lines worth of data from
  77. // the current frame buffer, starting with the scan line indicated by
  78. // currentScanLine(), and stores the data in the output file, and
  79. // progressing in the direction indicated by header.lineOrder().
  80. //
  81. // To produce a complete and correct file, exactly m scan lines must
  82. // be written, where m is equal to
  83. // header().dataWindow().max.y - header().dataWindow().min.y + 1.
  84. //-------------------------------------------------------------------
  85. IMF_EXPORT
  86. void writePixels (int numScanLines = 1);
  87. //------------------------------------------------------------------
  88. // Access to the current scan line:
  89. //
  90. // currentScanLine() returns the y coordinate of the first scan line
  91. // that will be read from the current frame buffer during the next
  92. // call to writePixels().
  93. //
  94. // If header.lineOrder() == INCREASING_Y:
  95. //
  96. // The current scan line before the first call to writePixels()
  97. // is header().dataWindow().min.y. After writing each scan line,
  98. // the current scan line is incremented by 1.
  99. //
  100. // If header.lineOrder() == DECREASING_Y:
  101. //
  102. // The current scan line before the first call to writePixels()
  103. // is header().dataWindow().max.y. After writing each scan line,
  104. // the current scan line is decremented by 1.
  105. //
  106. //------------------------------------------------------------------
  107. IMF_EXPORT
  108. int currentScanLine () const;
  109. //--------------------------------------------------------------
  110. // Shortcut to copy all pixels from an InputFile into this file,
  111. // without uncompressing and then recompressing the pixel data.
  112. // This file's header must be compatible with the InputFile's
  113. // header: The two header's "dataWindow", "compression",
  114. // "lineOrder" and "channels" attributes must be the same.
  115. //--------------------------------------------------------------
  116. IMF_EXPORT
  117. void copyPixels (DeepScanLineInputFile &in);
  118. IMF_EXPORT
  119. void copyPixels (DeepScanLineInputPart &in);
  120. //--------------------------------------------------------------
  121. // Updating the preview image:
  122. //
  123. // updatePreviewImage() supplies a new set of pixels for the
  124. // preview image attribute in the file's header. If the header
  125. // does not contain a preview image, updatePreviewImage() throws
  126. // an IEX_NAMESPACE::LogicExc.
  127. //
  128. // Note: updatePreviewImage() is necessary because images are
  129. // often stored in a file incrementally, a few scan lines at a
  130. // time, while the image is being generated. Since the preview
  131. // image is an attribute in the file's header, it gets stored in
  132. // the file as soon as the file is opened, but we may not know
  133. // what the preview image should look like until we have written
  134. // the last scan line of the main image.
  135. //
  136. //--------------------------------------------------------------
  137. IMF_EXPORT
  138. void updatePreviewImage (const PreviewRgba newPixels[]);
  139. private:
  140. DeepScanLineOutputFile* file;
  141. };
  142. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  143. #endif /* IMFDEEPSCANLINEOUTPUTPART_H_ */