[855] | 1 | /* |
---|
| 2 | |
---|
| 3 | Copyright (c) 2002, 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 | #ifndef INCLUDED_IMF_C_RGBA_FILE_H |
---|
| 36 | #define INCLUDED_IMF_C_RGBA_FILE_H |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | #include <stdlib.h> |
---|
| 40 | |
---|
| 41 | #ifdef __cplusplus |
---|
| 42 | extern "C" { |
---|
| 43 | #endif |
---|
| 44 | |
---|
| 45 | /* |
---|
| 46 | ** Interpreting unsigned shorts as 16-bit floating point numbers |
---|
| 47 | */ |
---|
| 48 | |
---|
| 49 | typedef unsigned short ImfHalf; |
---|
| 50 | |
---|
| 51 | void ImfFloatToHalf (float f, |
---|
| 52 | ImfHalf *h); |
---|
| 53 | |
---|
| 54 | void ImfFloatToHalfArray (int n, |
---|
| 55 | const float f[/*n*/], |
---|
| 56 | ImfHalf h[/*n*/]); |
---|
| 57 | |
---|
| 58 | float ImfHalfToFloat (ImfHalf h); |
---|
| 59 | |
---|
| 60 | void ImfHalfToFloatArray (int n, |
---|
| 61 | const ImfHalf h[/*n*/], |
---|
| 62 | float f[/*n*/]); |
---|
| 63 | |
---|
| 64 | /* |
---|
| 65 | ** RGBA pixel; memory layout must be the same as struct Imf::Rgba. |
---|
| 66 | */ |
---|
| 67 | |
---|
| 68 | struct ImfRgba |
---|
| 69 | { |
---|
| 70 | ImfHalf r; |
---|
| 71 | ImfHalf g; |
---|
| 72 | ImfHalf b; |
---|
| 73 | ImfHalf a; |
---|
| 74 | }; |
---|
| 75 | |
---|
| 76 | typedef struct ImfRgba ImfRgba; |
---|
| 77 | |
---|
| 78 | /* |
---|
| 79 | ** Magic number; this must be the same as Imf::MAGIC |
---|
| 80 | */ |
---|
| 81 | |
---|
| 82 | #define IMF_MAGIC 20000630 |
---|
| 83 | |
---|
| 84 | /* |
---|
| 85 | ** Version number; this must be the same as Imf::EXR_VERSION |
---|
| 86 | */ |
---|
| 87 | |
---|
| 88 | #define IMF_VERSION_NUMBER 2 |
---|
| 89 | |
---|
| 90 | /* |
---|
| 91 | ** Line order; values must the the same as in Imf::LineOrder. |
---|
| 92 | */ |
---|
| 93 | |
---|
| 94 | #define IMF_INCREASING_Y 0 |
---|
| 95 | #define IMF_DECREASING_Y 1 |
---|
| 96 | #define IMF_RAMDOM_Y 2 |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | /* |
---|
| 100 | ** Compression types; values must be the same as in Imf::Compression. |
---|
| 101 | */ |
---|
| 102 | |
---|
| 103 | #define IMF_NO_COMPRESSION 0 |
---|
| 104 | #define IMF_RLE_COMPRESSION 1 |
---|
| 105 | #define IMF_ZIPS_COMPRESSION 2 |
---|
| 106 | #define IMF_ZIP_COMPRESSION 3 |
---|
| 107 | #define IMF_PIZ_COMPRESSION 4 |
---|
| 108 | #define IMF_PXR24_COMPRESSION 5 |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | /* |
---|
| 112 | ** Channels; values must be the same as in Imf::RgbaChannels. |
---|
| 113 | */ |
---|
| 114 | |
---|
| 115 | #define IMF_WRITE_R 0x01 |
---|
| 116 | #define IMF_WRITE_G 0x02 |
---|
| 117 | #define IMF_WRITE_B 0x04 |
---|
| 118 | #define IMF_WRITE_A 0x08 |
---|
| 119 | #define IMF_WRITE_Y 0x10 |
---|
| 120 | #define IMF_WRITE_C 0x20 |
---|
| 121 | #define IMF_WRITE_RGB 0x07 |
---|
| 122 | #define IMF_WRITE_RGBA 0x0f |
---|
| 123 | #define IMF_WRITE_YC 0x30 |
---|
| 124 | #define IMF_WRITE_YA 0x18 |
---|
| 125 | #define IMF_WRITE_YCA 0x38 |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | /* |
---|
| 129 | ** Level modes; values must be the same as in Imf::LevelMode |
---|
| 130 | */ |
---|
| 131 | |
---|
| 132 | #define IMF_ONE_LEVEL 0 |
---|
| 133 | #define IMF_MIPMAP_LEVELS 1 |
---|
| 134 | #define IMF_RIPMAP_LEVELS 2 |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | /* |
---|
| 138 | ** Level rounding modes; values must be the same as in Imf::LevelRoundingMode |
---|
| 139 | */ |
---|
| 140 | |
---|
| 141 | #define IMF_ROUND_DOWN 0 |
---|
| 142 | #define IMF_ROUND_UP 1 |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | /* |
---|
| 146 | ** RGBA file header |
---|
| 147 | */ |
---|
| 148 | |
---|
| 149 | struct ImfHeader; |
---|
| 150 | typedef struct ImfHeader ImfHeader; |
---|
| 151 | |
---|
| 152 | ImfHeader * ImfNewHeader (void); |
---|
| 153 | |
---|
| 154 | void ImfDeleteHeader (ImfHeader *hdr); |
---|
| 155 | |
---|
| 156 | ImfHeader * ImfCopyHeader (const ImfHeader *hdr); |
---|
| 157 | |
---|
| 158 | void ImfHeaderSetDisplayWindow (ImfHeader *hdr, |
---|
| 159 | int xMin, int yMin, |
---|
| 160 | int xMax, int yMax); |
---|
| 161 | |
---|
| 162 | void ImfHeaderDisplayWindow (const ImfHeader *hdr, |
---|
| 163 | int *xMin, int *yMin, |
---|
| 164 | int *xMax, int *yMax); |
---|
| 165 | |
---|
| 166 | void ImfHeaderSetDataWindow (ImfHeader *hdr, |
---|
| 167 | int xMin, int yMin, |
---|
| 168 | int xMax, int yMax); |
---|
| 169 | |
---|
| 170 | void ImfHeaderDataWindow (const ImfHeader *hdr, |
---|
| 171 | int *xMin, int *yMin, |
---|
| 172 | int *xMax, int *yMax); |
---|
| 173 | |
---|
| 174 | void ImfHeaderSetPixelAspectRatio (ImfHeader *hdr, |
---|
| 175 | float pixelAspectRatio); |
---|
| 176 | |
---|
| 177 | float ImfHeaderPixelAspectRatio (const ImfHeader *hdr); |
---|
| 178 | |
---|
| 179 | void ImfHeaderSetScreenWindowCenter (ImfHeader *hdr, |
---|
| 180 | float x, float y); |
---|
| 181 | |
---|
| 182 | void ImfHeaderScreenWindowCenter (const ImfHeader *hdr, |
---|
| 183 | float *x, float *y); |
---|
| 184 | |
---|
| 185 | void ImfHeaderSetScreenWindowWidth (ImfHeader *hdr, |
---|
| 186 | float width); |
---|
| 187 | |
---|
| 188 | float ImfHeaderScreenWindowWidth (const ImfHeader *hdr); |
---|
| 189 | |
---|
| 190 | void ImfHeaderSetLineOrder (ImfHeader *hdr, |
---|
| 191 | int lineOrder); |
---|
| 192 | |
---|
| 193 | int ImfHeaderLineOrder (const ImfHeader *hdr); |
---|
| 194 | |
---|
| 195 | void ImfHeaderSetCompression (ImfHeader *hdr, |
---|
| 196 | int compression); |
---|
| 197 | |
---|
| 198 | int ImfHeaderCompression (const ImfHeader *hdr); |
---|
| 199 | |
---|
| 200 | int ImfHeaderSetIntAttribute (ImfHeader *hdr, |
---|
| 201 | const char name[], |
---|
| 202 | int value); |
---|
| 203 | |
---|
| 204 | int ImfHeaderIntAttribute (const ImfHeader *hdr, |
---|
| 205 | const char name[], |
---|
| 206 | int *value); |
---|
| 207 | |
---|
| 208 | int ImfHeaderSetFloatAttribute (ImfHeader *hdr, |
---|
| 209 | const char name[], |
---|
| 210 | float value); |
---|
| 211 | |
---|
| 212 | int ImfHeaderSetDoubleAttribute (ImfHeader *hdr, |
---|
| 213 | const char name[], |
---|
| 214 | double value); |
---|
| 215 | |
---|
| 216 | int ImfHeaderFloatAttribute (const ImfHeader *hdr, |
---|
| 217 | const char name[], |
---|
| 218 | float *value); |
---|
| 219 | |
---|
| 220 | int ImfHeaderDoubleAttribute (const ImfHeader *hdr, |
---|
| 221 | const char name[], |
---|
| 222 | double *value); |
---|
| 223 | |
---|
| 224 | int ImfHeaderSetStringAttribute (ImfHeader *hdr, |
---|
| 225 | const char name[], |
---|
| 226 | const char value[]); |
---|
| 227 | |
---|
| 228 | int ImfHeaderStringAttribute (const ImfHeader *hdr, |
---|
| 229 | const char name[], |
---|
| 230 | const char **value); |
---|
| 231 | |
---|
| 232 | int ImfHeaderSetBox2iAttribute (ImfHeader *hdr, |
---|
| 233 | const char name[], |
---|
| 234 | int xMin, int yMin, |
---|
| 235 | int xMax, int yMax); |
---|
| 236 | |
---|
| 237 | int ImfHeaderBox2iAttribute (const ImfHeader *hdr, |
---|
| 238 | const char name[], |
---|
| 239 | int *xMin, int *yMin, |
---|
| 240 | int *xMax, int *yMax); |
---|
| 241 | |
---|
| 242 | int ImfHeaderSetBox2fAttribute (ImfHeader *hdr, |
---|
| 243 | const char name[], |
---|
| 244 | float xMin, float yMin, |
---|
| 245 | float xMax, float yMax); |
---|
| 246 | |
---|
| 247 | int ImfHeaderBox2fAttribute (const ImfHeader *hdr, |
---|
| 248 | const char name[], |
---|
| 249 | float *xMin, float *yMin, |
---|
| 250 | float *xMax, float *yMax); |
---|
| 251 | |
---|
| 252 | int ImfHeaderSetV2iAttribute (ImfHeader *hdr, |
---|
| 253 | const char name[], |
---|
| 254 | int x, int y); |
---|
| 255 | |
---|
| 256 | int ImfHeaderV2iAttribute (const ImfHeader *hdr, |
---|
| 257 | const char name[], |
---|
| 258 | int *x, int *y); |
---|
| 259 | |
---|
| 260 | int ImfHeaderSetV2fAttribute (ImfHeader *hdr, |
---|
| 261 | const char name[], |
---|
| 262 | float x, float y); |
---|
| 263 | |
---|
| 264 | int ImfHeaderV2fAttribute (const ImfHeader *hdr, |
---|
| 265 | const char name[], |
---|
| 266 | float *x, float *y); |
---|
| 267 | |
---|
| 268 | int ImfHeaderSetV3iAttribute (ImfHeader *hdr, |
---|
| 269 | const char name[], |
---|
| 270 | int x, int y, int z); |
---|
| 271 | |
---|
| 272 | int ImfHeaderV3iAttribute (const ImfHeader *hdr, |
---|
| 273 | const char name[], |
---|
| 274 | int *x, int *y, int *z); |
---|
| 275 | |
---|
| 276 | int ImfHeaderSetV3fAttribute (ImfHeader *hdr, |
---|
| 277 | const char name[], |
---|
| 278 | float x, float y, float z); |
---|
| 279 | |
---|
| 280 | int ImfHeaderV3fAttribute (const ImfHeader *hdr, |
---|
| 281 | const char name[], |
---|
| 282 | float *x, float *y, float *z); |
---|
| 283 | |
---|
| 284 | int ImfHeaderSetM33fAttribute (ImfHeader *hdr, |
---|
| 285 | const char name[], |
---|
| 286 | const float m[3][3]); |
---|
| 287 | |
---|
| 288 | int ImfHeaderM33fAttribute (const ImfHeader *hdr, |
---|
| 289 | const char name[], |
---|
| 290 | float m[3][3]); |
---|
| 291 | |
---|
| 292 | int ImfHeaderSetM44fAttribute (ImfHeader *hdr, |
---|
| 293 | const char name[], |
---|
| 294 | const float m[4][4]); |
---|
| 295 | |
---|
| 296 | int ImfHeaderM44fAttribute (const ImfHeader *hdr, |
---|
| 297 | const char name[], |
---|
| 298 | float m[4][4]); |
---|
| 299 | |
---|
| 300 | /* |
---|
| 301 | ** RGBA output file |
---|
| 302 | */ |
---|
| 303 | |
---|
| 304 | struct ImfOutputFile; |
---|
| 305 | typedef struct ImfOutputFile ImfOutputFile; |
---|
| 306 | |
---|
| 307 | ImfOutputFile * ImfOpenOutputFile (const char name[], |
---|
| 308 | const ImfHeader *hdr, |
---|
| 309 | int channels); |
---|
| 310 | |
---|
| 311 | int ImfCloseOutputFile (ImfOutputFile *out); |
---|
| 312 | |
---|
| 313 | int ImfOutputSetFrameBuffer (ImfOutputFile *out, |
---|
| 314 | const ImfRgba *base, |
---|
| 315 | size_t xStride, |
---|
| 316 | size_t yStride); |
---|
| 317 | |
---|
| 318 | int ImfOutputWritePixels (ImfOutputFile *out, |
---|
| 319 | int numScanLines); |
---|
| 320 | |
---|
| 321 | int ImfOutputCurrentScanLine (const ImfOutputFile *out); |
---|
| 322 | |
---|
| 323 | const ImfHeader * ImfOutputHeader (const ImfOutputFile *out); |
---|
| 324 | |
---|
| 325 | int ImfOutputChannels (const ImfOutputFile *out); |
---|
| 326 | |
---|
| 327 | |
---|
| 328 | /* |
---|
| 329 | ** Tiled RGBA output file |
---|
| 330 | */ |
---|
| 331 | |
---|
| 332 | struct ImfTiledOutputFile; |
---|
| 333 | typedef struct ImfTiledOutputFile ImfTiledOutputFile; |
---|
| 334 | |
---|
| 335 | ImfTiledOutputFile * ImfOpenTiledOutputFile (const char name[], |
---|
| 336 | const ImfHeader *hdr, |
---|
| 337 | int channels, |
---|
| 338 | int xSize, int ySize, |
---|
| 339 | int mode, int rmode); |
---|
| 340 | |
---|
| 341 | int ImfCloseTiledOutputFile (ImfTiledOutputFile *out); |
---|
| 342 | |
---|
| 343 | int ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out, |
---|
| 344 | const ImfRgba *base, |
---|
| 345 | size_t xStride, |
---|
| 346 | size_t yStride); |
---|
| 347 | |
---|
| 348 | int ImfTiledOutputWriteTile (ImfTiledOutputFile *out, |
---|
| 349 | int dx, int dy, |
---|
| 350 | int lx, int ly); |
---|
| 351 | |
---|
| 352 | const ImfHeader * ImfTiledOutputHeader (const ImfTiledOutputFile *out); |
---|
| 353 | |
---|
| 354 | int ImfTiledOutputChannels (const ImfTiledOutputFile *out); |
---|
| 355 | |
---|
| 356 | int ImfTiledOutputTileXSize (const ImfTiledOutputFile *out); |
---|
| 357 | |
---|
| 358 | int ImfTiledOutputTileYSize (const ImfTiledOutputFile *out); |
---|
| 359 | |
---|
| 360 | int ImfTiledOutputLevelMode (const ImfTiledOutputFile *out); |
---|
| 361 | int ImfTiledOutputLevelRoundingMode |
---|
| 362 | (const ImfTiledOutputFile *out); |
---|
| 363 | |
---|
| 364 | |
---|
| 365 | /* |
---|
| 366 | ** RGBA input file |
---|
| 367 | */ |
---|
| 368 | |
---|
| 369 | struct ImfInputFile; |
---|
| 370 | typedef struct ImfInputFile ImfInputFile; |
---|
| 371 | |
---|
| 372 | ImfInputFile * ImfOpenInputFile (const char name[]); |
---|
| 373 | |
---|
| 374 | int ImfCloseInputFile (ImfInputFile *in); |
---|
| 375 | |
---|
| 376 | int ImfInputSetFrameBuffer (ImfInputFile *in, |
---|
| 377 | ImfRgba *base, |
---|
| 378 | size_t xStride, |
---|
| 379 | size_t yStride); |
---|
| 380 | |
---|
| 381 | int ImfInputReadPixels (ImfInputFile *in, |
---|
| 382 | int scanLine1, |
---|
| 383 | int scanLine2); |
---|
| 384 | |
---|
| 385 | const ImfHeader * ImfInputHeader (const ImfInputFile *in); |
---|
| 386 | |
---|
| 387 | int ImfInputChannels (const ImfInputFile *in); |
---|
| 388 | |
---|
| 389 | const char * ImfInputFileName (const ImfInputFile *in); |
---|
| 390 | |
---|
| 391 | |
---|
| 392 | /* |
---|
| 393 | ** Tiled RGBA input file |
---|
| 394 | */ |
---|
| 395 | |
---|
| 396 | struct ImfTiledInputFile; |
---|
| 397 | typedef struct ImfTiledInputFile ImfTiledInputFile; |
---|
| 398 | |
---|
| 399 | ImfTiledInputFile * ImfOpenTiledInputFile (const char name[]); |
---|
| 400 | |
---|
| 401 | int ImfCloseTiledInputFile (ImfTiledInputFile *in); |
---|
| 402 | |
---|
| 403 | int ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in, |
---|
| 404 | ImfRgba *base, |
---|
| 405 | size_t xStride, |
---|
| 406 | size_t yStride); |
---|
| 407 | |
---|
| 408 | int ImfTiledInputReadTile (ImfTiledInputFile *in, |
---|
| 409 | int dx, int dy, |
---|
| 410 | int lx, int ly); |
---|
| 411 | |
---|
| 412 | const ImfHeader * ImfTiledInputHeader (const ImfTiledInputFile *in); |
---|
| 413 | |
---|
| 414 | int ImfTiledInputChannels (const ImfTiledInputFile *in); |
---|
| 415 | |
---|
| 416 | const char * ImfTiledInputFileName (const ImfTiledInputFile *in); |
---|
| 417 | |
---|
| 418 | int ImfTiledInputTileXSize (const ImfTiledInputFile *in); |
---|
| 419 | |
---|
| 420 | int ImfTiledInputTileYSize (const ImfTiledInputFile *in); |
---|
| 421 | |
---|
| 422 | int ImfTiledInputLevelMode (const ImfTiledInputFile *in); |
---|
| 423 | |
---|
| 424 | int ImfTiledInputLevelRoundingMode |
---|
| 425 | (const ImfTiledInputFile *in); |
---|
| 426 | |
---|
| 427 | /* |
---|
| 428 | ** Lookup tables |
---|
| 429 | */ |
---|
| 430 | |
---|
| 431 | struct ImfLut; |
---|
| 432 | typedef struct ImfLut ImfLut; |
---|
| 433 | |
---|
| 434 | ImfLut * ImfNewRound12logLut (int channels); |
---|
| 435 | |
---|
| 436 | ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels); |
---|
| 437 | |
---|
| 438 | void ImfDeleteLut (ImfLut *lut); |
---|
| 439 | |
---|
| 440 | void ImfApplyLut (ImfLut *lut, |
---|
| 441 | ImfRgba *data, |
---|
| 442 | int nData, |
---|
| 443 | int stride); |
---|
| 444 | /* |
---|
| 445 | ** Most recent error message |
---|
| 446 | */ |
---|
| 447 | |
---|
| 448 | const char * ImfErrorMessage (void); |
---|
| 449 | |
---|
| 450 | |
---|
| 451 | #ifdef __cplusplus |
---|
| 452 | } /* extern "C" */ |
---|
| 453 | #endif |
---|
| 454 | |
---|
| 455 | #endif |
---|