Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/OpenEXR/IlmImf/ImfDeepTiledOutputFile.h  view on Meta::CPAN

// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////


#ifndef INCLUDED_IMF_DEEP_TILED_OUTPUT_FILE_H
#define INCLUDED_IMF_DEEP_TILED_OUTPUT_FILE_H

//-----------------------------------------------------------------------------
//
//      class DeepTiledOutputFile
//
//-----------------------------------------------------------------------------

#include "ImfHeader.h"
#include "ImfFrameBuffer.h"
#include "ImathBox.h"
#include "ImfThreading.h"
#include "ImfGenericOutputFile.h"
#include "ImfNamespace.h"
#include "ImfForward.h"
#include "ImfExport.h"

OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER


class IMF_EXPORT DeepTiledOutputFile : public GenericOutputFile
{
  public:

    //-------------------------------------------------------------------
    // A constructor that opens the file with the specified name, and
    // writes the file header.  The file header is also copied into the
    // TiledOutputFile object, and can later be accessed via the header()
    // method.
    //
    // Destroying TiledOutputFile constructed with this constructor
    // automatically closes the corresponding files.
    //
    // The header must contain a TileDescriptionAttribute called "tiles".
    //
    // The x and y subsampling factors for all image channels must be 1;
    // subsampling is not supported.
    //
    // Tiles can be written to the file in arbitrary order.  The line
    // order attribute can be used to cause the tiles to be sorted in
    // the file.  When the file is read later, reading the tiles in the
    // same order as they are in the file tends to be significantly
    // faster than reading the tiles in random order (see writeTile,
    // below).
    //-------------------------------------------------------------------

    DeepTiledOutputFile (const char fileName[],
                         const Header &header,
                         int numThreads = globalThreadCount ());


    // ----------------------------------------------------------------
    // A constructor that attaches the new TiledOutputFile object to
    // a file that has already been opened.  Destroying TiledOutputFile
    // objects constructed with this constructor does not automatically
    // close the corresponding files.
    // ----------------------------------------------------------------

    DeepTiledOutputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os,
                         const Header &header,
                         int numThreads = globalThreadCount ());


    //-----------------------------------------------------
    // Destructor
    //
    // Destroying a TiledOutputFile object before all tiles
    // have been written results in an incomplete file.
    //-----------------------------------------------------

    virtual ~DeepTiledOutputFile ();


    //------------------------
    // Access to the file name
    //------------------------

    const char *        fileName () const;


    //--------------------------
    // Access to the file header
    //--------------------------

    const Header &      header () const;


    //-------------------------------------------------------
    // Set the current frame buffer -- copies the FrameBuffer
    // object into the TiledOutputFile object.
    //
    // The current frame buffer is the source of the pixel
    // data written to the file.  The current frame buffer
    // must be set at least once before writeTile() is
    // called.  The current frame buffer can be changed
    // after each call to writeTile().
    //-------------------------------------------------------

    void                setFrameBuffer (const DeepFrameBuffer &frameBuffer);


    //-----------------------------------
    // Access to the current frame buffer
    //-----------------------------------

    const DeepFrameBuffer & frameBuffer () const;


    //-------------------
    // Utility functions:
    //-------------------

    //---------------------------------------------------------

src/Source/OpenEXR/IlmImf/ImfDeepTiledOutputFile.h  view on Meta::CPAN



    //------------------------------------------------------------------
    // Shortcut to copy all pixels from a TiledInputFile into this file,
    // without uncompressing and then recompressing the pixel data.
    // This file's header must be compatible with the TiledInputFile's
    // header:  The two header's "dataWindow", "compression",
    // "lineOrder", "channels", and "tiles" attributes must be the same.
    //------------------------------------------------------------------

    void                copyPixels (DeepTiledInputFile &in);
    void                copyPixels (DeepTiledInputPart &in);



    //--------------------------------------------------------------
    // Updating the preview image:
    //
    // updatePreviewImage() supplies a new set of pixels for the
    // preview image attribute in the file's header.  If the header
    // does not contain a preview image, updatePreviewImage() throws
    // an IEX_NAMESPACE::LogicExc.
    //
    // Note: updatePreviewImage() is necessary because images are
    // often stored in a file incrementally, a few tiles at a time,
    // while the image is being generated.  Since the preview image
    // is an attribute in the file's header, it gets stored in the
    // file as soon as the file is opened, but we may not know what
    // the preview image should look like until we have written the
    // last tile of the main image.
    //
    //--------------------------------------------------------------

    void                updatePreviewImage (const PreviewRgba newPixels[]);


    //-------------------------------------------------------------
    // Break a tile -- for testing and debugging only:
    //
    // breakTile(dx,dy,lx,ly,p,n,c) introduces an error into the
    // output file by writing n copies of character c, starting
    // p bytes from the beginning of the tile with tile coordinates
    // (dx, dy) and level number (lx, ly).
    //
    // Warning: Calling this function usually results in a broken
    // image file.  The file or parts of it may not be readable,
    // or the file may contain bad data.
    //
    //-------------------------------------------------------------

    void                breakTile  (int dx, int dy,
                                    int lx, int ly,
                                    int offset,
                                    int length,
                                    char c);
    struct Data;

  private:

    // ----------------------------------------------------------------
    // A constructor attaches the OutputStreamMutex to the
    // given one from MultiPartOutputFile. Set the previewPosition
    // and lineOffsetsPosition which have been acquired from
    // the constructor of MultiPartOutputFile as well.
    // ----------------------------------------------------------------
    DeepTiledOutputFile (const OutputPartData* part);

    DeepTiledOutputFile (const DeepTiledOutputFile &);              // not implemented
    DeepTiledOutputFile & operator = (const DeepTiledOutputFile &); // not implemented

    void                initialize (const Header &header);

    bool                isValidTile (int dx, int dy,
                                     int lx, int ly) const;

    size_t              bytesPerLineForTile (int dx, int dy,
                                             int lx, int ly) const;

    Data *              _data;


    friend class MultiPartOutputFile;

};


OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT

#endif



( run in 1.676 second using v1.01-cache-2.11-cpan-4991d5b9bd9 )