source: NonGTP/OpenEXR/include/IlmImf/ImfCRgbaFile.h @ 855

Revision 855, 11.0 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*
2
3Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
4Digital Ltd. LLC
5
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are
10met:
11*       Redistributions of source code must retain the above copyright
12notice, this list of conditions and the following disclaimer.
13*       Redistributions in binary form must reproduce the above
14copyright notice, this list of conditions and the following disclaimer
15in the documentation and/or other materials provided with the
16distribution.
17*       Neither the name of Industrial Light & Magic nor the names of
18its contributors may be used to endorse or promote products derived
19from this software without specific prior written permission.
20
21THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31OF 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
42extern "C" {
43#endif
44
45/*
46** Interpreting unsigned shorts as 16-bit floating point numbers
47*/
48
49typedef unsigned short ImfHalf;
50
51void    ImfFloatToHalf (float f,
52                        ImfHalf *h);
53
54void    ImfFloatToHalfArray (int n,
55                            const float f[/*n*/],
56                            ImfHalf h[/*n*/]);
57
58float   ImfHalfToFloat (ImfHalf h);
59
60void    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
68struct ImfRgba
69{
70    ImfHalf     r;
71    ImfHalf     g;
72    ImfHalf     b;
73    ImfHalf     a;
74};
75
76typedef 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
149struct ImfHeader;
150typedef struct ImfHeader ImfHeader;
151
152ImfHeader *     ImfNewHeader (void);
153
154void            ImfDeleteHeader (ImfHeader *hdr);
155
156ImfHeader *     ImfCopyHeader (const ImfHeader *hdr);
157
158void            ImfHeaderSetDisplayWindow (ImfHeader *hdr,
159                                           int xMin, int yMin,
160                                           int xMax, int yMax);
161
162void            ImfHeaderDisplayWindow (const ImfHeader *hdr,
163                                        int *xMin, int *yMin,
164                                        int *xMax, int *yMax);
165
166void            ImfHeaderSetDataWindow (ImfHeader *hdr,
167                                        int xMin, int yMin,
168                                        int xMax, int yMax);
169
170void            ImfHeaderDataWindow (const ImfHeader *hdr,
171                                     int *xMin, int *yMin,
172                                     int *xMax, int *yMax);
173
174void            ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,
175                                              float pixelAspectRatio);
176
177float           ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
178
179void            ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,
180                                                float x, float y);
181
182void            ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
183                                             float *x, float *y);
184
185void            ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,
186                                               float width);
187
188float           ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
189
190void            ImfHeaderSetLineOrder (ImfHeader *hdr,
191                                       int lineOrder);
192
193int             ImfHeaderLineOrder (const ImfHeader *hdr);
194                           
195void            ImfHeaderSetCompression (ImfHeader *hdr,
196                                         int compression);
197
198int             ImfHeaderCompression (const ImfHeader *hdr);
199
200int             ImfHeaderSetIntAttribute (ImfHeader *hdr,
201                                          const char name[],
202                                          int value);
203
204int             ImfHeaderIntAttribute (const ImfHeader *hdr,
205                                       const char name[],
206                                       int *value);
207
208int             ImfHeaderSetFloatAttribute (ImfHeader *hdr,
209                                            const char name[],
210                                            float value);
211
212int             ImfHeaderSetDoubleAttribute (ImfHeader *hdr,
213                                             const char name[],
214                                             double value);
215
216int             ImfHeaderFloatAttribute (const ImfHeader *hdr,
217                                         const char name[],
218                                         float *value);
219
220int             ImfHeaderDoubleAttribute (const ImfHeader *hdr,
221                                          const char name[],
222                                          double *value);
223
224int             ImfHeaderSetStringAttribute (ImfHeader *hdr,
225                                             const char name[],
226                                             const char value[]);
227
228int             ImfHeaderStringAttribute (const ImfHeader *hdr,
229                                         const char name[],
230                                          const char **value);
231
232int             ImfHeaderSetBox2iAttribute (ImfHeader *hdr,
233                                            const char name[],
234                                            int xMin, int yMin,
235                                            int xMax, int yMax);
236
237int             ImfHeaderBox2iAttribute (const ImfHeader *hdr,
238                                         const char name[],
239                                         int *xMin, int *yMin,
240                                         int *xMax, int *yMax);
241
242int             ImfHeaderSetBox2fAttribute (ImfHeader *hdr,
243                                            const char name[],
244                                            float xMin, float yMin,
245                                            float xMax, float yMax);
246
247int             ImfHeaderBox2fAttribute (const ImfHeader *hdr,
248                                         const char name[],
249                                         float *xMin, float *yMin,
250                                         float *xMax, float *yMax);
251
252int             ImfHeaderSetV2iAttribute (ImfHeader *hdr,
253                                         const char name[],
254                                         int x, int y);
255
256int             ImfHeaderV2iAttribute (const ImfHeader *hdr,
257                                       const char name[],
258                                       int *x, int *y);
259
260int             ImfHeaderSetV2fAttribute (ImfHeader *hdr,
261                                          const char name[],
262                                          float x, float y);
263
264int             ImfHeaderV2fAttribute (const ImfHeader *hdr,
265                                       const char name[],
266                                       float *x, float *y);
267
268int             ImfHeaderSetV3iAttribute (ImfHeader *hdr,
269                                          const char name[],
270                                          int x, int y, int z);
271
272int             ImfHeaderV3iAttribute (const ImfHeader *hdr,
273                                       const char name[],
274                                       int *x, int *y, int *z);
275
276int             ImfHeaderSetV3fAttribute (ImfHeader *hdr,
277                                          const char name[],
278                                          float x, float y, float z);
279
280int             ImfHeaderV3fAttribute (const ImfHeader *hdr,
281                                       const char name[],
282                                       float *x, float *y, float *z);
283
284int             ImfHeaderSetM33fAttribute (ImfHeader *hdr,
285                                           const char name[],
286                                           const float m[3][3]);
287
288int             ImfHeaderM33fAttribute (const ImfHeader *hdr,
289                                        const char name[],
290                                        float m[3][3]);
291
292int             ImfHeaderSetM44fAttribute (ImfHeader *hdr,
293                                           const char name[],
294                                           const float m[4][4]);
295
296int             ImfHeaderM44fAttribute (const ImfHeader *hdr,
297                                        const char name[],
298                                        float m[4][4]);
299
300/*
301** RGBA output file
302*/
303
304struct ImfOutputFile;
305typedef struct ImfOutputFile ImfOutputFile;
306
307ImfOutputFile * ImfOpenOutputFile (const char name[],
308                                                   const ImfHeader *hdr,
309                                                   int channels);
310
311int                     ImfCloseOutputFile (ImfOutputFile *out);
312
313int                     ImfOutputSetFrameBuffer (ImfOutputFile *out,
314                                                         const ImfRgba *base,
315                                                         size_t xStride,
316                                                         size_t yStride);
317
318int                     ImfOutputWritePixels (ImfOutputFile *out,
319                                                      int numScanLines);
320
321int                     ImfOutputCurrentScanLine (const ImfOutputFile *out);
322
323const ImfHeader *       ImfOutputHeader (const ImfOutputFile *out);
324
325int                     ImfOutputChannels (const ImfOutputFile *out);
326
327
328/*
329** Tiled RGBA output file
330*/
331
332struct ImfTiledOutputFile;
333typedef struct ImfTiledOutputFile ImfTiledOutputFile;
334
335ImfTiledOutputFile *    ImfOpenTiledOutputFile (const char name[],
336                                                const ImfHeader *hdr,
337                                                int channels,
338                                                int xSize, int ySize,
339                                                int mode, int rmode);
340
341int             ImfCloseTiledOutputFile (ImfTiledOutputFile *out);
342
343int             ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,
344                                                      const ImfRgba *base,
345                                                      size_t xStride,
346                                                      size_t yStride);
347
348int             ImfTiledOutputWriteTile (ImfTiledOutputFile *out,
349                                                 int dx, int dy,
350                                                 int lx, int ly);
351
352const ImfHeader *       ImfTiledOutputHeader (const ImfTiledOutputFile *out);
353
354int             ImfTiledOutputChannels (const ImfTiledOutputFile *out);
355
356int             ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);
357
358int             ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);
359
360int             ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);
361int             ImfTiledOutputLevelRoundingMode
362                                                (const ImfTiledOutputFile *out);
363
364
365/*
366** RGBA input file
367*/
368
369struct ImfInputFile;
370typedef struct ImfInputFile ImfInputFile;
371
372ImfInputFile *          ImfOpenInputFile (const char name[]);
373
374int                     ImfCloseInputFile (ImfInputFile *in);
375
376int                     ImfInputSetFrameBuffer (ImfInputFile *in,
377                                                ImfRgba *base,
378                                                size_t xStride,
379                                                size_t yStride);
380
381int                     ImfInputReadPixels (ImfInputFile *in,
382                                            int scanLine1,
383                                            int scanLine2);
384
385const ImfHeader *       ImfInputHeader (const ImfInputFile *in);
386
387int                     ImfInputChannels (const ImfInputFile *in);
388
389const char *            ImfInputFileName (const ImfInputFile *in);
390
391
392/*
393** Tiled RGBA input file
394*/
395
396struct ImfTiledInputFile;
397typedef struct ImfTiledInputFile ImfTiledInputFile;
398
399ImfTiledInputFile *     ImfOpenTiledInputFile (const char name[]);
400
401int             ImfCloseTiledInputFile (ImfTiledInputFile *in);
402
403int             ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,
404                                                     ImfRgba *base,
405                                                     size_t xStride,
406                                                     size_t yStride);
407
408int             ImfTiledInputReadTile (ImfTiledInputFile *in,
409                                               int dx, int dy,
410                                               int lx, int ly);
411
412const ImfHeader *       ImfTiledInputHeader (const ImfTiledInputFile *in);
413
414int             ImfTiledInputChannels (const ImfTiledInputFile *in);
415
416const char *            ImfTiledInputFileName (const ImfTiledInputFile *in);
417
418int             ImfTiledInputTileXSize (const ImfTiledInputFile *in);
419
420int             ImfTiledInputTileYSize (const ImfTiledInputFile *in);
421
422int             ImfTiledInputLevelMode (const ImfTiledInputFile *in);
423
424int             ImfTiledInputLevelRoundingMode
425                                               (const ImfTiledInputFile *in);
426
427/*
428** Lookup tables
429*/
430
431struct ImfLut;
432typedef struct ImfLut ImfLut;
433
434ImfLut *                ImfNewRound12logLut (int channels);
435
436ImfLut *                ImfNewRoundNBitLut (unsigned int n, int channels);
437
438void                    ImfDeleteLut (ImfLut *lut);
439
440void                    ImfApplyLut (ImfLut *lut,
441                                     ImfRgba *data,
442                                     int nData,
443                                     int stride);
444/*
445** Most recent error message
446*/
447
448const char *            ImfErrorMessage (void);
449
450
451#ifdef __cplusplus
452} /* extern "C" */
453#endif
454
455#endif
Note: See TracBrowser for help on using the repository browser.