/source/3rd_party/opencv/sources/3rdparty/openexr/IlmImf/ImfCRgbaFile.h
C Header | 467 lines | 254 code | 132 blank | 81 comment | 0 complexity | 3677c69affcad045a91fd51e285b43b2 MD5 | raw file
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#define IMF_B44_COMPRESSION 6
110#define IMF_B44A_COMPRESSION 7
111
112
113/*
114** Channels; values must be the same as in Imf::RgbaChannels.
115*/
116
117#define IMF_WRITE_R 0x01
118#define IMF_WRITE_G 0x02
119#define IMF_WRITE_B 0x04
120#define IMF_WRITE_A 0x08
121#define IMF_WRITE_Y 0x10
122#define IMF_WRITE_C 0x20
123#define IMF_WRITE_RGB 0x07
124#define IMF_WRITE_RGBA 0x0f
125#define IMF_WRITE_YC 0x30
126#define IMF_WRITE_YA 0x18
127#define IMF_WRITE_YCA 0x38
128
129
130/*
131** Level modes; values must be the same as in Imf::LevelMode
132*/
133
134#define IMF_ONE_LEVEL 0
135#define IMF_MIPMAP_LEVELS 1
136#define IMF_RIPMAP_LEVELS 2
137
138
139/*
140** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
141*/
142
143#define IMF_ROUND_DOWN 0
144#define IMF_ROUND_UP 1
145
146
147/*
148** RGBA file header
149*/
150
151struct ImfHeader;
152typedef struct ImfHeader ImfHeader;
153
154ImfHeader * ImfNewHeader (void);
155
156void ImfDeleteHeader (ImfHeader *hdr);
157
158ImfHeader * ImfCopyHeader (const ImfHeader *hdr);
159
160void ImfHeaderSetDisplayWindow (ImfHeader *hdr,
161 int xMin, int yMin,
162 int xMax, int yMax);
163
164void ImfHeaderDisplayWindow (const ImfHeader *hdr,
165 int *xMin, int *yMin,
166 int *xMax, int *yMax);
167
168void ImfHeaderSetDataWindow (ImfHeader *hdr,
169 int xMin, int yMin,
170 int xMax, int yMax);
171
172void ImfHeaderDataWindow (const ImfHeader *hdr,
173 int *xMin, int *yMin,
174 int *xMax, int *yMax);
175
176void ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,
177 float pixelAspectRatio);
178
179float ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
180
181void ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,
182 float x, float y);
183
184void ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
185 float *x, float *y);
186
187void ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,
188 float width);
189
190float ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
191
192void ImfHeaderSetLineOrder (ImfHeader *hdr,
193 int lineOrder);
194
195int ImfHeaderLineOrder (const ImfHeader *hdr);
196
197void ImfHeaderSetCompression (ImfHeader *hdr,
198 int compression);
199
200int ImfHeaderCompression (const ImfHeader *hdr);
201
202int ImfHeaderSetIntAttribute (ImfHeader *hdr,
203 const char name[],
204 int value);
205
206int ImfHeaderIntAttribute (const ImfHeader *hdr,
207 const char name[],
208 int *value);
209
210int ImfHeaderSetFloatAttribute (ImfHeader *hdr,
211 const char name[],
212 float value);
213
214int ImfHeaderSetDoubleAttribute (ImfHeader *hdr,
215 const char name[],
216 double value);
217
218int ImfHeaderFloatAttribute (const ImfHeader *hdr,
219 const char name[],
220 float *value);
221
222int ImfHeaderDoubleAttribute (const ImfHeader *hdr,
223 const char name[],
224 double *value);
225
226int ImfHeaderSetStringAttribute (ImfHeader *hdr,
227 const char name[],
228 const char value[]);
229
230int ImfHeaderStringAttribute (const ImfHeader *hdr,
231 const char name[],
232 const char **value);
233
234int ImfHeaderSetBox2iAttribute (ImfHeader *hdr,
235 const char name[],
236 int xMin, int yMin,
237 int xMax, int yMax);
238
239int ImfHeaderBox2iAttribute (const ImfHeader *hdr,
240 const char name[],
241 int *xMin, int *yMin,
242 int *xMax, int *yMax);
243
244int ImfHeaderSetBox2fAttribute (ImfHeader *hdr,
245 const char name[],
246 float xMin, float yMin,
247 float xMax, float yMax);
248
249int ImfHeaderBox2fAttribute (const ImfHeader *hdr,
250 const char name[],
251 float *xMin, float *yMin,
252 float *xMax, float *yMax);
253
254int ImfHeaderSetV2iAttribute (ImfHeader *hdr,
255 const char name[],
256 int x, int y);
257
258int ImfHeaderV2iAttribute (const ImfHeader *hdr,
259 const char name[],
260 int *x, int *y);
261
262int ImfHeaderSetV2fAttribute (ImfHeader *hdr,
263 const char name[],
264 float x, float y);
265
266int ImfHeaderV2fAttribute (const ImfHeader *hdr,
267 const char name[],
268 float *x, float *y);
269
270int ImfHeaderSetV3iAttribute (ImfHeader *hdr,
271 const char name[],
272 int x, int y, int z);
273
274int ImfHeaderV3iAttribute (const ImfHeader *hdr,
275 const char name[],
276 int *x, int *y, int *z);
277
278int ImfHeaderSetV3fAttribute (ImfHeader *hdr,
279 const char name[],
280 float x, float y, float z);
281
282int ImfHeaderV3fAttribute (const ImfHeader *hdr,
283 const char name[],
284 float *x, float *y, float *z);
285
286int ImfHeaderSetM33fAttribute (ImfHeader *hdr,
287 const char name[],
288 const float m[3][3]);
289
290int ImfHeaderM33fAttribute (const ImfHeader *hdr,
291 const char name[],
292 float m[3][3]);
293
294int ImfHeaderSetM44fAttribute (ImfHeader *hdr,
295 const char name[],
296 const float m[4][4]);
297
298int ImfHeaderM44fAttribute (const ImfHeader *hdr,
299 const char name[],
300 float m[4][4]);
301
302/*
303** RGBA output file
304*/
305
306struct ImfOutputFile;
307typedef struct ImfOutputFile ImfOutputFile;
308
309ImfOutputFile * ImfOpenOutputFile (const char name[],
310 const ImfHeader *hdr,
311 int channels);
312
313int ImfCloseOutputFile (ImfOutputFile *out);
314
315int ImfOutputSetFrameBuffer (ImfOutputFile *out,
316 const ImfRgba *base,
317 size_t xStride,
318 size_t yStride);
319
320int ImfOutputWritePixels (ImfOutputFile *out,
321 int numScanLines);
322
323int ImfOutputCurrentScanLine (const ImfOutputFile *out);
324
325const ImfHeader * ImfOutputHeader (const ImfOutputFile *out);
326
327int ImfOutputChannels (const ImfOutputFile *out);
328
329
330/*
331** Tiled RGBA output file
332*/
333
334struct ImfTiledOutputFile;
335typedef struct ImfTiledOutputFile ImfTiledOutputFile;
336
337ImfTiledOutputFile * ImfOpenTiledOutputFile (const char name[],
338 const ImfHeader *hdr,
339 int channels,
340 int xSize, int ySize,
341 int mode, int rmode);
342
343int ImfCloseTiledOutputFile (ImfTiledOutputFile *out);
344
345int ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,
346 const ImfRgba *base,
347 size_t xStride,
348 size_t yStride);
349
350int ImfTiledOutputWriteTile (ImfTiledOutputFile *out,
351 int dx, int dy,
352 int lx, int ly);
353
354int ImfTiledOutputWriteTiles (ImfTiledOutputFile *out,
355 int dxMin, int dxMax,
356 int dyMin, int dyMax,
357 int lx, int ly);
358
359const ImfHeader * ImfTiledOutputHeader (const ImfTiledOutputFile *out);
360
361int ImfTiledOutputChannels (const ImfTiledOutputFile *out);
362
363int ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);
364
365int ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);
366
367int ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);
368int ImfTiledOutputLevelRoundingMode
369 (const ImfTiledOutputFile *out);
370
371
372/*
373** RGBA input file
374*/
375
376struct ImfInputFile;
377typedef struct ImfInputFile ImfInputFile;
378
379ImfInputFile * ImfOpenInputFile (const char name[]);
380
381int ImfCloseInputFile (ImfInputFile *in);
382
383int ImfInputSetFrameBuffer (ImfInputFile *in,
384 ImfRgba *base,
385 size_t xStride,
386 size_t yStride);
387
388int ImfInputReadPixels (ImfInputFile *in,
389 int scanLine1,
390 int scanLine2);
391
392const ImfHeader * ImfInputHeader (const ImfInputFile *in);
393
394int ImfInputChannels (const ImfInputFile *in);
395
396const char * ImfInputFileName (const ImfInputFile *in);
397
398
399/*
400** Tiled RGBA input file
401*/
402
403struct ImfTiledInputFile;
404typedef struct ImfTiledInputFile ImfTiledInputFile;
405
406ImfTiledInputFile * ImfOpenTiledInputFile (const char name[]);
407
408int ImfCloseTiledInputFile (ImfTiledInputFile *in);
409
410int ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,
411 ImfRgba *base,
412 size_t xStride,
413 size_t yStride);
414
415int ImfTiledInputReadTile (ImfTiledInputFile *in,
416 int dx, int dy,
417 int lx, int ly);
418
419int ImfTiledInputReadTiles (ImfTiledInputFile *in,
420 int dxMin, int dxMax,
421 int dyMin, int dyMax,
422 int lx, int ly);
423
424const ImfHeader * ImfTiledInputHeader (const ImfTiledInputFile *in);
425
426int ImfTiledInputChannels (const ImfTiledInputFile *in);
427
428const char * ImfTiledInputFileName (const ImfTiledInputFile *in);
429
430int ImfTiledInputTileXSize (const ImfTiledInputFile *in);
431
432int ImfTiledInputTileYSize (const ImfTiledInputFile *in);
433
434int ImfTiledInputLevelMode (const ImfTiledInputFile *in);
435
436int ImfTiledInputLevelRoundingMode
437 (const ImfTiledInputFile *in);
438
439/*
440** Lookup tables
441*/
442
443struct ImfLut;
444typedef struct ImfLut ImfLut;
445
446ImfLut * ImfNewRound12logLut (int channels);
447
448ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels);
449
450void ImfDeleteLut (ImfLut *lut);
451
452void ImfApplyLut (ImfLut *lut,
453 ImfRgba *data,
454 int nData,
455 int stride);
456/*
457** Most recent error message
458*/
459
460const char * ImfErrorMessage (void);
461
462
463#ifdef __cplusplus
464} /* extern "C" */
465#endif
466
467#endif