ImfDeepScanLineOutputPart.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Copyright (c) Contributors to the OpenEXR Project.
  4. //
  5. #ifndef IMFDEEPSCANLINEOUTPUTPART_H_
  6. #define IMFDEEPSCANLINEOUTPUTPART_H_
  7. #include "ImfDeepScanLineOutputFile.h"
  8. #include "ImfMultiPartOutputFile.h"
  9. #include "ImfNamespace.h"
  10. #include "ImfExport.h"
  11. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  12. class DeepScanLineOutputPart
  13. {
  14. public:
  15. IMF_EXPORT
  16. DeepScanLineOutputPart(MultiPartOutputFile& multiPartFile, int partNumber);
  17. //------------------------
  18. // Access to the file name
  19. //------------------------
  20. IMF_EXPORT
  21. const char * fileName () const;
  22. //--------------------------
  23. // Access to the file header
  24. //--------------------------
  25. IMF_EXPORT
  26. const Header & header () const;
  27. //-------------------------------------------------------
  28. // Set the current frame buffer -- copies the FrameBuffer
  29. // object into the OutputFile object.
  30. //
  31. // The current frame buffer is the source of the pixel
  32. // data written to the file. The current frame buffer
  33. // must be set at least once before writePixels() is
  34. // called. The current frame buffer can be changed
  35. // after each call to writePixels.
  36. //-------------------------------------------------------
  37. IMF_EXPORT
  38. void setFrameBuffer (const DeepFrameBuffer &frameBuffer);
  39. //-----------------------------------
  40. // Access to the current frame buffer
  41. //-----------------------------------
  42. IMF_EXPORT
  43. const DeepFrameBuffer & frameBuffer () const;
  44. //-------------------------------------------------------------------
  45. // Write pixel data:
  46. //
  47. // writePixels(n) retrieves the next n scan lines worth of data from
  48. // the current frame buffer, starting with the scan line indicated by
  49. // currentScanLine(), and stores the data in the output file, and
  50. // progressing in the direction indicated by header.lineOrder().
  51. //
  52. // To produce a complete and correct file, exactly m scan lines must
  53. // be written, where m is equal to
  54. // header().dataWindow().max.y - header().dataWindow().min.y + 1.
  55. //-------------------------------------------------------------------
  56. IMF_EXPORT
  57. void writePixels (int numScanLines = 1);
  58. //------------------------------------------------------------------
  59. // Access to the current scan line:
  60. //
  61. // currentScanLine() returns the y coordinate of the first scan line
  62. // that will be read from the current frame buffer during the next
  63. // call to writePixels().
  64. //
  65. // If header.lineOrder() == INCREASING_Y:
  66. //
  67. // The current scan line before the first call to writePixels()
  68. // is header().dataWindow().min.y. After writing each scan line,
  69. // the current scan line is incremented by 1.
  70. //
  71. // If header.lineOrder() == DECREASING_Y:
  72. //
  73. // The current scan line before the first call to writePixels()
  74. // is header().dataWindow().max.y. After writing each scan line,
  75. // the current scan line is decremented by 1.
  76. //
  77. //------------------------------------------------------------------
  78. IMF_EXPORT
  79. int currentScanLine () const;
  80. //--------------------------------------------------------------
  81. // Shortcut to copy all pixels from an InputFile into this file,
  82. // without uncompressing and then recompressing the pixel data.
  83. // This file's header must be compatible with the InputFile's
  84. // header: The two header's "dataWindow", "compression",
  85. // "lineOrder" and "channels" attributes must be the same.
  86. //--------------------------------------------------------------
  87. IMF_EXPORT
  88. void copyPixels (DeepScanLineInputFile &in);
  89. IMF_EXPORT
  90. void copyPixels (DeepScanLineInputPart &in);
  91. //--------------------------------------------------------------
  92. // Updating the preview image:
  93. //
  94. // updatePreviewImage() supplies a new set of pixels for the
  95. // preview image attribute in the file's header. If the header
  96. // does not contain a preview image, updatePreviewImage() throws
  97. // an IEX_NAMESPACE::LogicExc.
  98. //
  99. // Note: updatePreviewImage() is necessary because images are
  100. // often stored in a file incrementally, a few scan lines at a
  101. // time, while the image is being generated. Since the preview
  102. // image is an attribute in the file's header, it gets stored in
  103. // the file as soon as the file is opened, but we may not know
  104. // what the preview image should look like until we have written
  105. // the last scan line of the main image.
  106. //
  107. //--------------------------------------------------------------
  108. IMF_EXPORT
  109. void updatePreviewImage (const PreviewRgba newPixels[]);
  110. private:
  111. DeepScanLineOutputFile* file;
  112. };
  113. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  114. #endif /* IMFDEEPSCANLINEOUTPUTPART_H_ */