Blame IlmImf/ImfDeepScanLineOutputPart.h

Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
//
Packit 0d464f
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
Packit 0d464f
// Digital Ltd. LLC
Packit 0d464f
//
Packit 0d464f
// All rights reserved.
Packit 0d464f
//
Packit 0d464f
// Redistribution and use in source and binary forms, with or without
Packit 0d464f
// modification, are permitted provided that the following conditions are
Packit 0d464f
// met:
Packit 0d464f
// *       Redistributions of source code must retain the above copyright
Packit 0d464f
// notice, this list of conditions and the following disclaimer.
Packit 0d464f
// *       Redistributions in binary form must reproduce the above
Packit 0d464f
// copyright notice, this list of conditions and the following disclaimer
Packit 0d464f
// in the documentation and/or other materials provided with the
Packit 0d464f
// distribution.
Packit 0d464f
// *       Neither the name of Industrial Light & Magic nor the names of
Packit 0d464f
// its contributors may be used to endorse or promote products derived
Packit 0d464f
// from this software without specific prior written permission.
Packit 0d464f
//
Packit 0d464f
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 0d464f
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 0d464f
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 0d464f
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 0d464f
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 0d464f
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 0d464f
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 0d464f
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 0d464f
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 0d464f
//
Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
Packit 0d464f
#ifndef IMFDEEPSCANLINEOUTPUTPART_H_
Packit 0d464f
#define IMFDEEPSCANLINEOUTPUTPART_H_
Packit 0d464f
Packit 0d464f
#include "ImfDeepScanLineOutputFile.h"
Packit 0d464f
#include "ImfMultiPartOutputFile.h"
Packit 0d464f
#include "ImfNamespace.h"
Packit 0d464f
#include "ImfExport.h"
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit 0d464f
Packit 0d464f
class IMF_EXPORT DeepScanLineOutputPart
Packit 0d464f
{
Packit 0d464f
  public:
Packit 0d464f
Packit 0d464f
    DeepScanLineOutputPart(MultiPartOutputFile& multiPartFile, int partNumber);
Packit 0d464f
Packit 0d464f
    //------------------------
Packit 0d464f
    // Access to the file name
Packit 0d464f
    //------------------------
Packit 0d464f
Packit 0d464f
    const char *        fileName () const;
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //--------------------------
Packit 0d464f
    // Access to the file header
Packit 0d464f
    //--------------------------
Packit 0d464f
Packit 0d464f
    const Header &      header () const;
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //-------------------------------------------------------
Packit 0d464f
    // Set the current frame buffer -- copies the FrameBuffer
Packit 0d464f
    // object into the OutputFile object.
Packit 0d464f
    //
Packit 0d464f
    // The current frame buffer is the source of the pixel
Packit 0d464f
    // data written to the file.  The current frame buffer
Packit 0d464f
    // must be set at least once before writePixels() is
Packit 0d464f
    // called.  The current frame buffer can be changed
Packit 0d464f
    // after each call to writePixels.
Packit 0d464f
    //-------------------------------------------------------
Packit 0d464f
Packit 0d464f
    void                setFrameBuffer (const DeepFrameBuffer &frameBuffer);
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //-----------------------------------
Packit 0d464f
    // Access to the current frame buffer
Packit 0d464f
    //-----------------------------------
Packit 0d464f
Packit 0d464f
    const DeepFrameBuffer & frameBuffer () const;
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //-------------------------------------------------------------------
Packit 0d464f
    // Write pixel data:
Packit 0d464f
    //
Packit 0d464f
    // writePixels(n) retrieves the next n scan lines worth of data from
Packit 0d464f
    // the current frame buffer, starting with the scan line indicated by
Packit 0d464f
    // currentScanLine(), and stores the data in the output file, and
Packit 0d464f
    // progressing in the direction indicated by header.lineOrder().
Packit 0d464f
    //
Packit 0d464f
    // To produce a complete and correct file, exactly m scan lines must
Packit 0d464f
    // be written, where m is equal to
Packit 0d464f
    // header().dataWindow().max.y - header().dataWindow().min.y + 1.
Packit 0d464f
    //-------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
    void                writePixels (int numScanLines = 1);
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //------------------------------------------------------------------
Packit 0d464f
    // Access to the current scan line:
Packit 0d464f
    //
Packit 0d464f
    // currentScanLine() returns the y coordinate of the first scan line
Packit 0d464f
    // that will be read from the current frame buffer during the next
Packit 0d464f
    // call to writePixels().
Packit 0d464f
    //
Packit 0d464f
    // If header.lineOrder() == INCREASING_Y:
Packit 0d464f
    //
Packit 0d464f
    //  The current scan line before the first call to writePixels()
Packit 0d464f
    //  is header().dataWindow().min.y.  After writing each scan line,
Packit 0d464f
    //  the current scan line is incremented by 1.
Packit 0d464f
    //
Packit 0d464f
    // If header.lineOrder() == DECREASING_Y:
Packit 0d464f
    //
Packit 0d464f
    //  The current scan line before the first call to writePixels()
Packit 0d464f
    //  is header().dataWindow().max.y.  After writing each scan line,
Packit 0d464f
    //  the current scan line is decremented by 1.
Packit 0d464f
    //
Packit 0d464f
    //------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
    int                 currentScanLine () const;
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //--------------------------------------------------------------
Packit 0d464f
    // Shortcut to copy all pixels from an InputFile into this file,
Packit 0d464f
    // without uncompressing and then recompressing the pixel data.
Packit 0d464f
    // This file's header must be compatible with the InputFile's
Packit 0d464f
    // header:  The two header's "dataWindow", "compression",
Packit 0d464f
    // "lineOrder" and "channels" attributes must be the same.
Packit 0d464f
    //--------------------------------------------------------------
Packit 0d464f
Packit 0d464f
    void                copyPixels (DeepScanLineInputFile &in);
Packit 0d464f
    void                copyPixels (DeepScanLineInputPart &in);
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //--------------------------------------------------------------
Packit 0d464f
    // Updating the preview image:
Packit 0d464f
    //
Packit 0d464f
    // updatePreviewImage() supplies a new set of pixels for the
Packit 0d464f
    // preview image attribute in the file's header.  If the header
Packit 0d464f
    // does not contain a preview image, updatePreviewImage() throws
Packit 0d464f
    // an IEX_NAMESPACE::LogicExc.
Packit 0d464f
    //
Packit 0d464f
    // Note: updatePreviewImage() is necessary because images are
Packit 0d464f
    // often stored in a file incrementally, a few scan lines at a
Packit 0d464f
    // time, while the image is being generated.  Since the preview
Packit 0d464f
    // image is an attribute in the file's header, it gets stored in
Packit 0d464f
    // the file as soon as the file is opened, but we may not know
Packit 0d464f
    // what the preview image should look like until we have written
Packit 0d464f
    // the last scan line of the main image.
Packit 0d464f
    //
Packit 0d464f
    //--------------------------------------------------------------
Packit 0d464f
Packit 0d464f
    void                updatePreviewImage (const PreviewRgba newPixels[]);
Packit 0d464f
Packit 0d464f
  private:
Packit 0d464f
      DeepScanLineOutputFile* file;
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit 0d464f
Packit 0d464f
Packit 0d464f
Packit 0d464f
Packit 0d464f
Packit 0d464f
#endif /* IMFDEEPSCANLINEOUTPUTPART_H_ */