Path: blob/master/3rdparty/openexr/IlmImf/ImfCRgbaFile.h
16337 views
/*12Copyright (c) 2002, Industrial Light & Magic, a division of Lucas3Digital Ltd. LLC45All rights reserved.67Redistribution and use in source and binary forms, with or without8modification, are permitted provided that the following conditions are9met:10* Redistributions of source code must retain the above copyright11notice, this list of conditions and the following disclaimer.12* Redistributions in binary form must reproduce the above13copyright notice, this list of conditions and the following disclaimer14in the documentation and/or other materials provided with the15distribution.16* Neither the name of Industrial Light & Magic nor the names of17its contributors may be used to endorse or promote products derived18from this software without specific prior written permission.1920THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS21"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT22LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR23A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT24OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,25SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,27DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY28THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE30OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.3132*/3334#ifndef INCLUDED_IMF_C_RGBA_FILE_H35#define INCLUDED_IMF_C_RGBA_FILE_H363738#include <stdlib.h>3940#ifdef __cplusplus41extern "C" {42#endif4344/*45** Interpreting unsigned shorts as 16-bit floating point numbers46*/4748typedef unsigned short ImfHalf;4950void ImfFloatToHalf (float f,51ImfHalf *h);5253void ImfFloatToHalfArray (int n,54const float f[/*n*/],55ImfHalf h[/*n*/]);5657float ImfHalfToFloat (ImfHalf h);5859void ImfHalfToFloatArray (int n,60const ImfHalf h[/*n*/],61float f[/*n*/]);6263/*64** RGBA pixel; memory layout must be the same as struct Imf::Rgba.65*/6667struct ImfRgba68{69ImfHalf r;70ImfHalf g;71ImfHalf b;72ImfHalf a;73};7475typedef struct ImfRgba ImfRgba;7677/*78** Magic number; this must be the same as Imf::MAGIC79*/8081#define IMF_MAGIC 200006308283/*84** Version number; this must be the same as Imf::EXR_VERSION85*/8687#define IMF_VERSION_NUMBER 28889/*90** Line order; values must the the same as in Imf::LineOrder.91*/9293#define IMF_INCREASING_Y 094#define IMF_DECREASING_Y 195#define IMF_RAMDOM_Y 2969798/*99** Compression types; values must be the same as in Imf::Compression.100*/101102#define IMF_NO_COMPRESSION 0103#define IMF_RLE_COMPRESSION 1104#define IMF_ZIPS_COMPRESSION 2105#define IMF_ZIP_COMPRESSION 3106#define IMF_PIZ_COMPRESSION 4107#define IMF_PXR24_COMPRESSION 5108#define IMF_B44_COMPRESSION 6109#define IMF_B44A_COMPRESSION 7110111112/*113** Channels; values must be the same as in Imf::RgbaChannels.114*/115116#define IMF_WRITE_R 0x01117#define IMF_WRITE_G 0x02118#define IMF_WRITE_B 0x04119#define IMF_WRITE_A 0x08120#define IMF_WRITE_Y 0x10121#define IMF_WRITE_C 0x20122#define IMF_WRITE_RGB 0x07123#define IMF_WRITE_RGBA 0x0f124#define IMF_WRITE_YC 0x30125#define IMF_WRITE_YA 0x18126#define IMF_WRITE_YCA 0x38127128129/*130** Level modes; values must be the same as in Imf::LevelMode131*/132133#define IMF_ONE_LEVEL 0134#define IMF_MIPMAP_LEVELS 1135#define IMF_RIPMAP_LEVELS 2136137138/*139** Level rounding modes; values must be the same as in Imf::LevelRoundingMode140*/141142#define IMF_ROUND_DOWN 0143#define IMF_ROUND_UP 1144145146/*147** RGBA file header148*/149150struct ImfHeader;151typedef struct ImfHeader ImfHeader;152153ImfHeader * ImfNewHeader (void);154155void ImfDeleteHeader (ImfHeader *hdr);156157ImfHeader * ImfCopyHeader (const ImfHeader *hdr);158159void ImfHeaderSetDisplayWindow (ImfHeader *hdr,160int xMin, int yMin,161int xMax, int yMax);162163void ImfHeaderDisplayWindow (const ImfHeader *hdr,164int *xMin, int *yMin,165int *xMax, int *yMax);166167void ImfHeaderSetDataWindow (ImfHeader *hdr,168int xMin, int yMin,169int xMax, int yMax);170171void ImfHeaderDataWindow (const ImfHeader *hdr,172int *xMin, int *yMin,173int *xMax, int *yMax);174175void ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,176float pixelAspectRatio);177178float ImfHeaderPixelAspectRatio (const ImfHeader *hdr);179180void ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,181float x, float y);182183void ImfHeaderScreenWindowCenter (const ImfHeader *hdr,184float *x, float *y);185186void ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,187float width);188189float ImfHeaderScreenWindowWidth (const ImfHeader *hdr);190191void ImfHeaderSetLineOrder (ImfHeader *hdr,192int lineOrder);193194int ImfHeaderLineOrder (const ImfHeader *hdr);195196void ImfHeaderSetCompression (ImfHeader *hdr,197int compression);198199int ImfHeaderCompression (const ImfHeader *hdr);200201int ImfHeaderSetIntAttribute (ImfHeader *hdr,202const char name[],203int value);204205int ImfHeaderIntAttribute (const ImfHeader *hdr,206const char name[],207int *value);208209int ImfHeaderSetFloatAttribute (ImfHeader *hdr,210const char name[],211float value);212213int ImfHeaderSetDoubleAttribute (ImfHeader *hdr,214const char name[],215double value);216217int ImfHeaderFloatAttribute (const ImfHeader *hdr,218const char name[],219float *value);220221int ImfHeaderDoubleAttribute (const ImfHeader *hdr,222const char name[],223double *value);224225int ImfHeaderSetStringAttribute (ImfHeader *hdr,226const char name[],227const char value[]);228229int ImfHeaderStringAttribute (const ImfHeader *hdr,230const char name[],231const char **value);232233int ImfHeaderSetBox2iAttribute (ImfHeader *hdr,234const char name[],235int xMin, int yMin,236int xMax, int yMax);237238int ImfHeaderBox2iAttribute (const ImfHeader *hdr,239const char name[],240int *xMin, int *yMin,241int *xMax, int *yMax);242243int ImfHeaderSetBox2fAttribute (ImfHeader *hdr,244const char name[],245float xMin, float yMin,246float xMax, float yMax);247248int ImfHeaderBox2fAttribute (const ImfHeader *hdr,249const char name[],250float *xMin, float *yMin,251float *xMax, float *yMax);252253int ImfHeaderSetV2iAttribute (ImfHeader *hdr,254const char name[],255int x, int y);256257int ImfHeaderV2iAttribute (const ImfHeader *hdr,258const char name[],259int *x, int *y);260261int ImfHeaderSetV2fAttribute (ImfHeader *hdr,262const char name[],263float x, float y);264265int ImfHeaderV2fAttribute (const ImfHeader *hdr,266const char name[],267float *x, float *y);268269int ImfHeaderSetV3iAttribute (ImfHeader *hdr,270const char name[],271int x, int y, int z);272273int ImfHeaderV3iAttribute (const ImfHeader *hdr,274const char name[],275int *x, int *y, int *z);276277int ImfHeaderSetV3fAttribute (ImfHeader *hdr,278const char name[],279float x, float y, float z);280281int ImfHeaderV3fAttribute (const ImfHeader *hdr,282const char name[],283float *x, float *y, float *z);284285int ImfHeaderSetM33fAttribute (ImfHeader *hdr,286const char name[],287const float m[3][3]);288289int ImfHeaderM33fAttribute (const ImfHeader *hdr,290const char name[],291float m[3][3]);292293int ImfHeaderSetM44fAttribute (ImfHeader *hdr,294const char name[],295const float m[4][4]);296297int ImfHeaderM44fAttribute (const ImfHeader *hdr,298const char name[],299float m[4][4]);300301/*302** RGBA output file303*/304305struct ImfOutputFile;306typedef struct ImfOutputFile ImfOutputFile;307308ImfOutputFile * ImfOpenOutputFile (const char name[],309const ImfHeader *hdr,310int channels);311312int ImfCloseOutputFile (ImfOutputFile *out);313314int ImfOutputSetFrameBuffer (ImfOutputFile *out,315const ImfRgba *base,316size_t xStride,317size_t yStride);318319int ImfOutputWritePixels (ImfOutputFile *out,320int numScanLines);321322int ImfOutputCurrentScanLine (const ImfOutputFile *out);323324const ImfHeader * ImfOutputHeader (const ImfOutputFile *out);325326int ImfOutputChannels (const ImfOutputFile *out);327328329/*330** Tiled RGBA output file331*/332333struct ImfTiledOutputFile;334typedef struct ImfTiledOutputFile ImfTiledOutputFile;335336ImfTiledOutputFile * ImfOpenTiledOutputFile (const char name[],337const ImfHeader *hdr,338int channels,339int xSize, int ySize,340int mode, int rmode);341342int ImfCloseTiledOutputFile (ImfTiledOutputFile *out);343344int ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,345const ImfRgba *base,346size_t xStride,347size_t yStride);348349int ImfTiledOutputWriteTile (ImfTiledOutputFile *out,350int dx, int dy,351int lx, int ly);352353int ImfTiledOutputWriteTiles (ImfTiledOutputFile *out,354int dxMin, int dxMax,355int dyMin, int dyMax,356int lx, int ly);357358const ImfHeader * ImfTiledOutputHeader (const ImfTiledOutputFile *out);359360int ImfTiledOutputChannels (const ImfTiledOutputFile *out);361362int ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);363364int ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);365366int ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);367int ImfTiledOutputLevelRoundingMode368(const ImfTiledOutputFile *out);369370371/*372** RGBA input file373*/374375struct ImfInputFile;376typedef struct ImfInputFile ImfInputFile;377378ImfInputFile * ImfOpenInputFile (const char name[]);379380int ImfCloseInputFile (ImfInputFile *in);381382int ImfInputSetFrameBuffer (ImfInputFile *in,383ImfRgba *base,384size_t xStride,385size_t yStride);386387int ImfInputReadPixels (ImfInputFile *in,388int scanLine1,389int scanLine2);390391const ImfHeader * ImfInputHeader (const ImfInputFile *in);392393int ImfInputChannels (const ImfInputFile *in);394395const char * ImfInputFileName (const ImfInputFile *in);396397398/*399** Tiled RGBA input file400*/401402struct ImfTiledInputFile;403typedef struct ImfTiledInputFile ImfTiledInputFile;404405ImfTiledInputFile * ImfOpenTiledInputFile (const char name[]);406407int ImfCloseTiledInputFile (ImfTiledInputFile *in);408409int ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,410ImfRgba *base,411size_t xStride,412size_t yStride);413414int ImfTiledInputReadTile (ImfTiledInputFile *in,415int dx, int dy,416int lx, int ly);417418int ImfTiledInputReadTiles (ImfTiledInputFile *in,419int dxMin, int dxMax,420int dyMin, int dyMax,421int lx, int ly);422423const ImfHeader * ImfTiledInputHeader (const ImfTiledInputFile *in);424425int ImfTiledInputChannels (const ImfTiledInputFile *in);426427const char * ImfTiledInputFileName (const ImfTiledInputFile *in);428429int ImfTiledInputTileXSize (const ImfTiledInputFile *in);430431int ImfTiledInputTileYSize (const ImfTiledInputFile *in);432433int ImfTiledInputLevelMode (const ImfTiledInputFile *in);434435int ImfTiledInputLevelRoundingMode436(const ImfTiledInputFile *in);437438/*439** Lookup tables440*/441442struct ImfLut;443typedef struct ImfLut ImfLut;444445ImfLut * ImfNewRound12logLut (int channels);446447ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels);448449void ImfDeleteLut (ImfLut *lut);450451void ImfApplyLut (ImfLut *lut,452ImfRgba *data,453int nData,454int stride);455/*456** Most recent error message457*/458459const char * ImfErrorMessage (void);460461462#ifdef __cplusplus463} /* extern "C" */464#endif465466#endif467468469