HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfDeepScanLineOutputFile.h
Go to the documentation of this file.
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 
35 
36 
37 #ifndef INCLUDED_IMF_DEEP_SCAN_LINE_OUTPUT_FILE_H
38 #define INCLUDED_IMF_DEEP_SCAN_LINE_OUTPUT_FILE_H
39 
40 //-----------------------------------------------------------------------------
41 //
42 // class DeepScanLineOutputFile
43 //
44 //-----------------------------------------------------------------------------
45 
46 #include "ImfHeader.h"
47 #include "ImfFrameBuffer.h"
48 #include "ImfThreading.h"
49 #include "ImfGenericOutputFile.h"
50 #include "ImfNamespace.h"
51 #include "ImfForward.h"
52 #include "ImfExport.h"
53 
55 
56 
57 struct PreviewRgba;
58 
60 {
61  public:
62 
63  //-----------------------------------------------------------
64  // Constructor -- opens the file and writes the file header.
65  // The file header is also copied into the DeepScanLineOutputFile
66  // object, and can later be accessed via the header() method.
67  // Destroying this DeepScanLineOutputFile object automatically closes
68  // the file.
69  //
70  // numThreads determines the number of threads that will be
71  // used to write the file (see ImfThreading.h).
72  //-----------------------------------------------------------
73 
75  DeepScanLineOutputFile (const char fileName[], const Header &header,
76  int numThreads = globalThreadCount());
77 
78 
79  //------------------------------------------------------------
80  // Constructor -- attaches the new DeepScanLineOutputFile object
81  // to a file that has already been opened, and writes the file header.
82  // The file header is also copied into the DeepScanLineOutputFile
83  // object, and can later be accessed via the header() method.
84  // Destroying this DeepScanLineOutputFile object does not automatically
85  // close the file.
86  //
87  // numThreads determines the number of threads that will be
88  // used to write the file (see ImfThreading.h).
89  //------------------------------------------------------------
90 
92  DeepScanLineOutputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, const Header &header,
93  int numThreads = globalThreadCount());
94 
95 
96  //-------------------------------------------------
97  // Destructor
98  //
99  // Destroying the DeepScanLineOutputFile object
100  // before writing all scan lines within the data
101  // window results in an incomplete file.
102  //-------------------------------------------------
103 
104  IMF_EXPORT
105  virtual ~DeepScanLineOutputFile ();
106 
107 
108  //------------------------
109  // Access to the file name
110  //------------------------
111 
112  IMF_EXPORT
113  const char * fileName () const;
114 
115 
116  //--------------------------
117  // Access to the file header
118  //--------------------------
119 
120  IMF_EXPORT
121  const Header & header () const;
122 
123 
124  //-------------------------------------------------------
125  // Set the current frame buffer -- copies the FrameBuffer
126  // object into the OutputFile object.
127  //
128  // The current frame buffer is the source of the pixel
129  // data written to the file. The current frame buffer
130  // must be set at least once before writePixels() is
131  // called. The current frame buffer can be changed
132  // after each call to writePixels.
133  //-------------------------------------------------------
134 
135  IMF_EXPORT
137 
138 
139  //-----------------------------------
140  // Access to the current frame buffer
141  //-----------------------------------
142 
143  IMF_EXPORT
144  const DeepFrameBuffer & frameBuffer () const;
145 
146 
147  //-------------------------------------------------------------------
148  // Write pixel data:
149  //
150  // writePixels(n) retrieves the next n scan lines worth of data from
151  // the current frame buffer, starting with the scan line indicated by
152  // currentScanLine(), and stores the data in the output file, and
153  // progressing in the direction indicated by header.lineOrder().
154  //
155  // To produce a complete and correct file, exactly m scan lines must
156  // be written, where m is equal to
157  // header().dataWindow().max.y - header().dataWindow().min.y + 1.
158  //-------------------------------------------------------------------
159 
160  IMF_EXPORT
161  void writePixels (int numScanLines = 1);
162 
163 
164  //------------------------------------------------------------------
165  // Access to the current scan line:
166  //
167  // currentScanLine() returns the y coordinate of the first scan line
168  // that will be read from the current frame buffer during the next
169  // call to writePixels().
170  //
171  // If header.lineOrder() == INCREASING_Y:
172  //
173  // The current scan line before the first call to writePixels()
174  // is header().dataWindow().min.y. After writing each scan line,
175  // the current scan line is incremented by 1.
176  //
177  // If header.lineOrder() == DECREASING_Y:
178  //
179  // The current scan line before the first call to writePixels()
180  // is header().dataWindow().max.y. After writing each scan line,
181  // the current scan line is decremented by 1.
182  //
183  //------------------------------------------------------------------
184 
185  IMF_EXPORT
186  int currentScanLine () const;
187 
188 
189  //--------------------------------------------------------------
190  // Shortcut to copy all pixels from an InputFile into this file,
191  // without uncompressing and then recompressing the pixel data.
192  // This file's header must be compatible with the InputFile's
193  // header: The two header's "dataWindow", "compression",
194  // "lineOrder" and "channels" attributes must be the same.
195  //--------------------------------------------------------------
196 
197  IMF_EXPORT
199 
200  // --------------------------------------------------------------
201  // Shortcut to copy pixels from a given part of a multipart file
202  // --------------------------------------------------------------
203  IMF_EXPORT
205 
206 
207  //--------------------------------------------------------------
208  // Updating the preview image:
209  //
210  // updatePreviewImage() supplies a new set of pixels for the
211  // preview image attribute in the file's header. If the header
212  // does not contain a preview image, updatePreviewImage() throws
213  // an IEX_NAMESPACE::LogicExc.
214  //
215  // Note: updatePreviewImage() is necessary because images are
216  // often stored in a file incrementally, a few scan lines at a
217  // time, while the image is being generated. Since the preview
218  // image is an attribute in the file's header, it gets stored in
219  // the file as soon as the file is opened, but we may not know
220  // what the preview image should look like until we have written
221  // the last scan line of the main image.
222  //
223  //--------------------------------------------------------------
224 
225  IMF_EXPORT
226  void updatePreviewImage (const PreviewRgba newPixels[]);
227 
228 
229  struct Data;
230 
231  private:
232 
233  //------------------------------------------------------------
234  // Constructor -- attaches the OutputStreamMutex to the
235  // given one from MultiPartOutputFile. Set the previewPosition
236  // and lineOffsetsPosition which have been acquired from
237  // the constructor of MultiPartOutputFile as well.
238  //------------------------------------------------------------
239  DeepScanLineOutputFile (const OutputPartData* part);
240 
241  DeepScanLineOutputFile (const DeepScanLineOutputFile &); // not implemented
242  DeepScanLineOutputFile & operator = (const DeepScanLineOutputFile &); // not implemented
243 
244  void initialize (const Header &header);
245  void initializeLineBuffer();
246 
247  Data * _data;
248 
249 
250 
251  friend class MultiPartOutputFile;
252 };
253 
255 
256 #endif
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:109
IMF_EXPORT void setFrameBuffer(const DeepFrameBuffer &frameBuffer)
GLuint in
Definition: glew.h:11552
IMF_EXPORT const Header & header() const
IMF_EXPORT DeepScanLineOutputFile(const char fileName[], const Header &header, int numThreads=globalThreadCount())
IMF_EXPORT const char * fileName() const
#define IMF_EXPORT
Definition: ImfExport.h:44
OPENVDB_API void initialize()
Global registration of basic types.
Definition: logging.h:294
IMF_EXPORT void copyPixels(DeepScanLineInputFile &in)
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER IMF_EXPORT int globalThreadCount()
IMF_EXPORT void writePixels(int numScanLines=1)
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:108
virtual IMF_EXPORT ~DeepScanLineOutputFile()
IMF_EXPORT void updatePreviewImage(const PreviewRgba newPixels[])
IMF_EXPORT const DeepFrameBuffer & frameBuffer() const
IMF_EXPORT int currentScanLine() const