PBRT
/home/felix/UBC/projects/AdaptiveLightfieldSampling/pbrt_v2/src/3rdparty/openexr-1.7.0/ImfCRgbaFile.h
00001 /*
00002 
00003 Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
00004 Digital Ltd. LLC
00005 
00006 All rights reserved.
00007 
00008 Redistribution and use in source and binary forms, with or without
00009 modification, are permitted provided that the following conditions are
00010 met:
00011 *       Redistributions of source code must retain the above copyright
00012 notice, this list of conditions and the following disclaimer.
00013 *       Redistributions in binary form must reproduce the above
00014 copyright notice, this list of conditions and the following disclaimer
00015 in the documentation and/or other materials provided with the
00016 distribution.
00017 *       Neither the name of Industrial Light & Magic nor the names of
00018 its contributors may be used to endorse or promote products derived
00019 from this software without specific prior written permission. 
00020 
00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00024 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00025 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00026 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00027 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00028 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00029 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 
00033 */
00034 
00035 #ifndef INCLUDED_IMF_C_RGBA_FILE_H
00036 #define INCLUDED_IMF_C_RGBA_FILE_H
00037 
00038 
00039 #include <stdlib.h>
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 /*
00046 ** Interpreting unsigned shorts as 16-bit floating point numbers
00047 */
00048 
00049 typedef unsigned short ImfHalf;
00050 
00051 void    ImfFloatToHalf (float f,
00052                         ImfHalf *h);
00053 
00054 void    ImfFloatToHalfArray (int n,
00055                             const float f[/*n*/],
00056                             ImfHalf h[/*n*/]);
00057 
00058 float   ImfHalfToFloat (ImfHalf h);
00059 
00060 void    ImfHalfToFloatArray (int n,
00061                             const ImfHalf h[/*n*/],
00062                             float f[/*n*/]);
00063 
00064 /*
00065 ** RGBA pixel; memory layout must be the same as struct Imf::Rgba.
00066 */
00067 
00068 struct ImfRgba
00069 {
00070     ImfHalf     r;
00071     ImfHalf     g;
00072     ImfHalf     b;
00073     ImfHalf     a;
00074 };
00075 
00076 typedef struct ImfRgba ImfRgba;
00077 
00078 /*
00079 ** Magic number; this must be the same as Imf::MAGIC
00080 */
00081 
00082 #define IMF_MAGIC               20000630
00083 
00084 /*
00085 ** Version number; this must be the same as Imf::EXR_VERSION
00086 */
00087 
00088 #define IMF_VERSION_NUMBER      2
00089 
00090 /*
00091 ** Line order; values must the the same as in Imf::LineOrder.
00092 */
00093 
00094 #define IMF_INCREASING_Y        0
00095 #define IMF_DECREASING_Y        1
00096 #define IMF_RAMDOM_Y            2
00097 
00098 
00099 /*
00100 ** Compression types; values must be the same as in Imf::Compression.
00101 */
00102 
00103 #define IMF_NO_COMPRESSION      0
00104 #define IMF_RLE_COMPRESSION     1
00105 #define IMF_ZIPS_COMPRESSION    2
00106 #define IMF_ZIP_COMPRESSION     3
00107 #define IMF_PIZ_COMPRESSION     4
00108 #define IMF_PXR24_COMPRESSION   5
00109 #define IMF_B44_COMPRESSION     6
00110 #define IMF_B44A_COMPRESSION    7
00111 
00112 
00113 /*
00114 ** Channels; values must be the same as in Imf::RgbaChannels.
00115 */
00116 
00117 #define IMF_WRITE_R             0x01
00118 #define IMF_WRITE_G             0x02
00119 #define IMF_WRITE_B             0x04
00120 #define IMF_WRITE_A             0x08
00121 #define IMF_WRITE_Y             0x10
00122 #define IMF_WRITE_C             0x20
00123 #define IMF_WRITE_RGB           0x07
00124 #define IMF_WRITE_RGBA          0x0f
00125 #define IMF_WRITE_YC            0x30
00126 #define IMF_WRITE_YA            0x18
00127 #define IMF_WRITE_YCA           0x38
00128 
00129 
00130 /*
00131 ** Level modes; values must be the same as in Imf::LevelMode
00132 */
00133 
00134 #define IMF_ONE_LEVEL           0
00135 #define IMF_MIPMAP_LEVELS       1
00136 #define IMF_RIPMAP_LEVELS       2
00137 
00138 
00139 /*
00140 ** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
00141 */
00142 
00143 #define IMF_ROUND_DOWN          0
00144 #define IMF_ROUND_UP            1
00145 
00146 
00147 /*
00148 ** RGBA file header
00149 */
00150 
00151 struct ImfHeader;
00152 typedef struct ImfHeader ImfHeader;
00153 
00154 ImfHeader *     ImfNewHeader (void);
00155 
00156 void            ImfDeleteHeader (ImfHeader *hdr);
00157 
00158 ImfHeader *     ImfCopyHeader (const ImfHeader *hdr);
00159 
00160 void            ImfHeaderSetDisplayWindow (ImfHeader *hdr,
00161                                            int xMin, int yMin,
00162                                            int xMax, int yMax);
00163 
00164 void            ImfHeaderDisplayWindow (const ImfHeader *hdr,
00165                                         int *xMin, int *yMin,
00166                                         int *xMax, int *yMax);
00167 
00168 void            ImfHeaderSetDataWindow (ImfHeader *hdr,
00169                                         int xMin, int yMin,
00170                                         int xMax, int yMax);
00171 
00172 void            ImfHeaderDataWindow (const ImfHeader *hdr,
00173                                      int *xMin, int *yMin,
00174                                      int *xMax, int *yMax);
00175 
00176 void            ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,
00177                                               float pixelAspectRatio);
00178 
00179 float           ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
00180 
00181 void            ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,
00182                                                 float x, float y);
00183 
00184 void            ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
00185                                              float *x, float *y);
00186 
00187 void            ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,
00188                                                float width);
00189 
00190 float           ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
00191 
00192 void            ImfHeaderSetLineOrder (ImfHeader *hdr,
00193                                        int lineOrder);
00194 
00195 int             ImfHeaderLineOrder (const ImfHeader *hdr);
00196                             
00197 void            ImfHeaderSetCompression (ImfHeader *hdr,
00198                                          int compression);
00199 
00200 int             ImfHeaderCompression (const ImfHeader *hdr);
00201 
00202 int             ImfHeaderSetIntAttribute (ImfHeader *hdr,
00203                                           const char name[],
00204                                           int value);
00205 
00206 int             ImfHeaderIntAttribute (const ImfHeader *hdr,
00207                                        const char name[],
00208                                        int *value);
00209 
00210 int             ImfHeaderSetFloatAttribute (ImfHeader *hdr,
00211                                             const char name[],
00212                                             float value);
00213 
00214 int             ImfHeaderSetDoubleAttribute (ImfHeader *hdr,
00215                                              const char name[],
00216                                              double value);
00217 
00218 int             ImfHeaderFloatAttribute (const ImfHeader *hdr,
00219                                          const char name[],
00220                                          float *value);
00221 
00222 int             ImfHeaderDoubleAttribute (const ImfHeader *hdr,
00223                                           const char name[],
00224                                           double *value);
00225 
00226 int             ImfHeaderSetStringAttribute (ImfHeader *hdr,
00227                                              const char name[],
00228                                              const char value[]);
00229 
00230 int             ImfHeaderStringAttribute (const ImfHeader *hdr,
00231                                          const char name[],
00232                                           const char **value);
00233 
00234 int             ImfHeaderSetBox2iAttribute (ImfHeader *hdr,
00235                                             const char name[],
00236                                             int xMin, int yMin,
00237                                             int xMax, int yMax);
00238 
00239 int             ImfHeaderBox2iAttribute (const ImfHeader *hdr,
00240                                          const char name[],
00241                                          int *xMin, int *yMin,
00242                                          int *xMax, int *yMax);
00243 
00244 int             ImfHeaderSetBox2fAttribute (ImfHeader *hdr,
00245                                             const char name[],
00246                                             float xMin, float yMin,
00247                                             float xMax, float yMax);
00248 
00249 int             ImfHeaderBox2fAttribute (const ImfHeader *hdr,
00250                                          const char name[],
00251                                          float *xMin, float *yMin,
00252                                          float *xMax, float *yMax);
00253 
00254 int             ImfHeaderSetV2iAttribute (ImfHeader *hdr,
00255                                          const char name[],
00256                                          int x, int y);
00257 
00258 int             ImfHeaderV2iAttribute (const ImfHeader *hdr,
00259                                        const char name[],
00260                                        int *x, int *y);
00261 
00262 int             ImfHeaderSetV2fAttribute (ImfHeader *hdr,
00263                                           const char name[],
00264                                           float x, float y);
00265 
00266 int             ImfHeaderV2fAttribute (const ImfHeader *hdr,
00267                                        const char name[],
00268                                        float *x, float *y);
00269 
00270 int             ImfHeaderSetV3iAttribute (ImfHeader *hdr,
00271                                           const char name[],
00272                                           int x, int y, int z);
00273 
00274 int             ImfHeaderV3iAttribute (const ImfHeader *hdr,
00275                                        const char name[],
00276                                        int *x, int *y, int *z);
00277 
00278 int             ImfHeaderSetV3fAttribute (ImfHeader *hdr,
00279                                           const char name[],
00280                                           float x, float y, float z);
00281 
00282 int             ImfHeaderV3fAttribute (const ImfHeader *hdr,
00283                                        const char name[],
00284                                        float *x, float *y, float *z);
00285 
00286 int             ImfHeaderSetM33fAttribute (ImfHeader *hdr,
00287                                            const char name[],
00288                                            const float m[3][3]);
00289 
00290 int             ImfHeaderM33fAttribute (const ImfHeader *hdr,
00291                                         const char name[],
00292                                         float m[3][3]);
00293 
00294 int             ImfHeaderSetM44fAttribute (ImfHeader *hdr,
00295                                            const char name[],
00296                                            const float m[4][4]);
00297 
00298 int             ImfHeaderM44fAttribute (const ImfHeader *hdr,
00299                                         const char name[],
00300                                         float m[4][4]);
00301 
00302 /*
00303 ** RGBA output file
00304 */
00305 
00306 struct ImfOutputFile;
00307 typedef struct ImfOutputFile ImfOutputFile;
00308 
00309 ImfOutputFile * ImfOpenOutputFile (const char name[],
00310                                    const ImfHeader *hdr,
00311                                    int channels);
00312 
00313 int                     ImfCloseOutputFile (ImfOutputFile *out);
00314 
00315 int                     ImfOutputSetFrameBuffer (ImfOutputFile *out,
00316                                                  const ImfRgba *base,
00317                                                  size_t xStride,
00318                                                  size_t yStride);
00319 
00320 int                     ImfOutputWritePixels (ImfOutputFile *out,
00321                                               int numScanLines);
00322 
00323 int                     ImfOutputCurrentScanLine (const ImfOutputFile *out);
00324 
00325 const ImfHeader *       ImfOutputHeader (const ImfOutputFile *out);
00326 
00327 int                     ImfOutputChannels (const ImfOutputFile *out);
00328 
00329 
00330 /*
00331 ** Tiled RGBA output file
00332 */
00333 
00334 struct ImfTiledOutputFile;
00335 typedef struct ImfTiledOutputFile ImfTiledOutputFile;
00336 
00337 ImfTiledOutputFile *    ImfOpenTiledOutputFile (const char name[],
00338                                                 const ImfHeader *hdr,
00339                                                 int channels,
00340                                                 int xSize, int ySize,
00341                                                 int mode, int rmode);
00342 
00343 int             ImfCloseTiledOutputFile (ImfTiledOutputFile *out);
00344 
00345 int             ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,
00346                                               const ImfRgba *base,
00347                                               size_t xStride,
00348                                               size_t yStride);
00349 
00350 int             ImfTiledOutputWriteTile (ImfTiledOutputFile *out,
00351                                          int dx, int dy,
00352                                          int lx, int ly);
00353 
00354 int             ImfTiledOutputWriteTiles (ImfTiledOutputFile *out,
00355                                           int dxMin, int dxMax,
00356                                           int dyMin, int dyMax,
00357                                           int lx, int ly);
00358 
00359 const ImfHeader *       ImfTiledOutputHeader (const ImfTiledOutputFile *out);
00360 
00361 int             ImfTiledOutputChannels (const ImfTiledOutputFile *out);
00362 
00363 int             ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);
00364 
00365 int             ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);
00366 
00367 int             ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);
00368 int             ImfTiledOutputLevelRoundingMode
00369                                                 (const ImfTiledOutputFile *out);
00370 
00371 
00372 /*
00373 ** RGBA input file
00374 */
00375 
00376 struct ImfInputFile;
00377 typedef struct ImfInputFile ImfInputFile;
00378 
00379 ImfInputFile *          ImfOpenInputFile (const char name[]);
00380 
00381 int                     ImfCloseInputFile (ImfInputFile *in);
00382 
00383 int                     ImfInputSetFrameBuffer (ImfInputFile *in,
00384                                                 ImfRgba *base,
00385                                                 size_t xStride,
00386                                                 size_t yStride);
00387 
00388 int                     ImfInputReadPixels (ImfInputFile *in,
00389                                             int scanLine1,
00390                                             int scanLine2);
00391 
00392 const ImfHeader *       ImfInputHeader (const ImfInputFile *in);
00393 
00394 int                     ImfInputChannels (const ImfInputFile *in);
00395 
00396 const char *            ImfInputFileName (const ImfInputFile *in);
00397 
00398 
00399 /*
00400 ** Tiled RGBA input file
00401 */
00402 
00403 struct ImfTiledInputFile;
00404 typedef struct ImfTiledInputFile ImfTiledInputFile;
00405 
00406 ImfTiledInputFile *     ImfOpenTiledInputFile (const char name[]);
00407 
00408 int             ImfCloseTiledInputFile (ImfTiledInputFile *in);
00409 
00410 int             ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,
00411                                              ImfRgba *base,
00412                                              size_t xStride,
00413                                              size_t yStride);
00414 
00415 int             ImfTiledInputReadTile (ImfTiledInputFile *in,
00416                                        int dx, int dy,
00417                                        int lx, int ly);
00418 
00419 int             ImfTiledInputReadTiles (ImfTiledInputFile *in,
00420                                         int dxMin, int dxMax,
00421                                         int dyMin, int dyMax,
00422                                         int lx, int ly);
00423 
00424 const ImfHeader *       ImfTiledInputHeader (const ImfTiledInputFile *in);
00425 
00426 int             ImfTiledInputChannels (const ImfTiledInputFile *in);
00427 
00428 const char *            ImfTiledInputFileName (const ImfTiledInputFile *in);
00429 
00430 int             ImfTiledInputTileXSize (const ImfTiledInputFile *in);
00431 
00432 int             ImfTiledInputTileYSize (const ImfTiledInputFile *in);
00433 
00434 int             ImfTiledInputLevelMode (const ImfTiledInputFile *in);
00435 
00436 int             ImfTiledInputLevelRoundingMode
00437                                                (const ImfTiledInputFile *in);
00438 
00439 /*
00440 ** Lookup tables
00441 */
00442 
00443 struct ImfLut;
00444 typedef struct ImfLut ImfLut;
00445 
00446 ImfLut *                ImfNewRound12logLut (int channels);
00447 
00448 ImfLut *                ImfNewRoundNBitLut (unsigned int n, int channels);
00449 
00450 void                    ImfDeleteLut (ImfLut *lut);
00451 
00452 void                    ImfApplyLut (ImfLut *lut,
00453                                      ImfRgba *data,
00454                                      int nData,
00455                                      int stride);
00456 /*
00457 ** Most recent error message
00458 */
00459 
00460 const char *            ImfErrorMessage (void);
00461 
00462 
00463 #ifdef __cplusplus
00464 } /* extern "C" */
00465 #endif
00466 
00467 #endif