HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfCRgbaFile.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef INCLUDED_IMF_C_RGBA_FILE_H
7 #define INCLUDED_IMF_C_RGBA_FILE_H
8 
9 #include "ImfExport.h"
10 
11 #include <stdlib.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /*
18 ** Interpreting unsigned shorts as 16-bit floating point numbers
19 */
20 
21 typedef unsigned short ImfHalf;
22 
24 void ImfFloatToHalf (float f,
25  ImfHalf *h);
26 
28 void ImfFloatToHalfArray (int n,
29  const float f[/*n*/],
30  ImfHalf h[/*n*/]);
31 
33 float ImfHalfToFloat (ImfHalf h);
34 
36 void ImfHalfToFloatArray (int n,
37  const ImfHalf h[/*n*/],
38  float f[/*n*/]);
39 
40 /*
41 ** RGBA pixel; memory layout must be the same as struct Imf::Rgba.
42 */
43 
44 struct ImfRgba
45 {
46  ImfHalf r;
47  ImfHalf g;
48  ImfHalf b;
49  ImfHalf a;
50 };
51 
52 typedef struct ImfRgba ImfRgba;
53 
54 /*
55 ** Magic number; this must be the same as Imf::MAGIC
56 */
57 
58 #define IMF_MAGIC 20000630
59 
60 /*
61 ** Version number; this must be the same as Imf::EXR_VERSION
62 */
63 
64 #define IMF_VERSION_NUMBER 2
65 
66 /*
67 ** Line order; values must the the same as in Imf::LineOrder.
68 */
69 
70 #define IMF_INCREASING_Y 0
71 #define IMF_DECREASING_Y 1
72 #define IMF_RANDOM_Y 2
73 
74 
75 /*
76 ** Compression types; values must be the same as in Imf::Compression.
77 */
78 
79 #define IMF_NO_COMPRESSION 0
80 #define IMF_RLE_COMPRESSION 1
81 #define IMF_ZIPS_COMPRESSION 2
82 #define IMF_ZIP_COMPRESSION 3
83 #define IMF_PIZ_COMPRESSION 4
84 #define IMF_PXR24_COMPRESSION 5
85 #define IMF_B44_COMPRESSION 6
86 #define IMF_B44A_COMPRESSION 7
87 #define IMF_DWAA_COMPRESSION 8
88 #define IMF_DWAB_COMPRESSION 9
89 
90 
91 /*
92 ** Channels; values must be the same as in Imf::RgbaChannels.
93 */
94 
95 #define IMF_WRITE_R 0x01
96 #define IMF_WRITE_G 0x02
97 #define IMF_WRITE_B 0x04
98 #define IMF_WRITE_A 0x08
99 #define IMF_WRITE_Y 0x10
100 #define IMF_WRITE_C 0x20
101 #define IMF_WRITE_RGB 0x07
102 #define IMF_WRITE_RGBA 0x0f
103 #define IMF_WRITE_YC 0x30
104 #define IMF_WRITE_YA 0x18
105 #define IMF_WRITE_YCA 0x38
106 
107 
108 /*
109 ** Level modes; values must be the same as in Imf::LevelMode
110 */
111 
112 #define IMF_ONE_LEVEL 0
113 #define IMF_MIPMAP_LEVELS 1
114 #define IMF_RIPMAP_LEVELS 2
115 
116 
117 /*
118 ** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
119 */
120 
121 #define IMF_ROUND_DOWN 0
122 #define IMF_ROUND_UP 1
123 
124 
125 /*
126 ** RGBA file header
127 */
128 
129 struct ImfHeader;
130 typedef struct ImfHeader ImfHeader;
131 
132 IMF_EXPORT
133 ImfHeader * ImfNewHeader (void);
134 
135 IMF_EXPORT
136 void ImfDeleteHeader (ImfHeader *hdr);
137 
138 IMF_EXPORT
139 ImfHeader * ImfCopyHeader (const ImfHeader *hdr);
140 
141 IMF_EXPORT
143  int xMin, int yMin,
144  int xMax, int yMax);
145 
146 IMF_EXPORT
147 void ImfHeaderDisplayWindow (const ImfHeader *hdr,
148  int *xMin, int *yMin,
149  int *xMax, int *yMax);
150 
151 IMF_EXPORT
153  int xMin, int yMin,
154  int xMax, int yMax);
155 
156 IMF_EXPORT
157 void ImfHeaderDataWindow (const ImfHeader *hdr,
158  int *xMin, int *yMin,
159  int *xMax, int *yMax);
160 
161 IMF_EXPORT
163  float pixelAspectRatio);
164 
165 IMF_EXPORT
166 float ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
167 
168 IMF_EXPORT
170  float x, float y);
171 
172 IMF_EXPORT
173 void ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
174  float *x, float *y);
175 
176 IMF_EXPORT
178  float width);
179 
180 IMF_EXPORT
181 float ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
182 
183 IMF_EXPORT
185  int lineOrder);
186 
187 IMF_EXPORT
188 int ImfHeaderLineOrder (const ImfHeader *hdr);
189 
190 IMF_EXPORT
192  int compression);
193 
194 IMF_EXPORT
195 int ImfHeaderCompression (const ImfHeader *hdr);
196 
197 IMF_EXPORT
199  const char name[],
200  int value);
201 
202 IMF_EXPORT
203 int ImfHeaderIntAttribute (const ImfHeader *hdr,
204  const char name[],
205  int *value);
206 
207 IMF_EXPORT
209  const char name[],
210  float value);
211 
212 IMF_EXPORT
214  const char name[],
215  double value);
216 
217 IMF_EXPORT
218 int ImfHeaderFloatAttribute (const ImfHeader *hdr,
219  const char name[],
220  float *value);
221 
222 IMF_EXPORT
223 int ImfHeaderDoubleAttribute (const ImfHeader *hdr,
224  const char name[],
225  double *value);
226 
227 IMF_EXPORT
229  const char name[],
230  const char value[]);
231 
232 IMF_EXPORT
233 int ImfHeaderStringAttribute (const ImfHeader *hdr,
234  const char name[],
235  const char **value);
236 
237 IMF_EXPORT
239  const char name[],
240  int xMin, int yMin,
241  int xMax, int yMax);
242 
243 IMF_EXPORT
244 int ImfHeaderBox2iAttribute (const ImfHeader *hdr,
245  const char name[],
246  int *xMin, int *yMin,
247  int *xMax, int *yMax);
248 
249 IMF_EXPORT
251  const char name[],
252  float xMin, float yMin,
253  float xMax, float yMax);
254 
255 IMF_EXPORT
256 int ImfHeaderBox2fAttribute (const ImfHeader *hdr,
257  const char name[],
258  float *xMin, float *yMin,
259  float *xMax, float *yMax);
260 
261 IMF_EXPORT
263  const char name[],
264  int x, int y);
265 
266 IMF_EXPORT
267 int ImfHeaderV2iAttribute (const ImfHeader *hdr,
268  const char name[],
269  int *x, int *y);
270 
271 IMF_EXPORT
273  const char name[],
274  float x, float y);
275 
276 IMF_EXPORT
277 int ImfHeaderV2fAttribute (const ImfHeader *hdr,
278  const char name[],
279  float *x, float *y);
280 
281 IMF_EXPORT
283  const char name[],
284  int x, int y, int z);
285 
286 IMF_EXPORT
287 int ImfHeaderV3iAttribute (const ImfHeader *hdr,
288  const char name[],
289  int *x, int *y, int *z);
290 
291 IMF_EXPORT
293  const char name[],
294  float x, float y, float z);
295 
296 IMF_EXPORT
297 int ImfHeaderV3fAttribute (const ImfHeader *hdr,
298  const char name[],
299  float *x, float *y, float *z);
300 
301 IMF_EXPORT
303  const char name[],
304  const float m[3][3]);
305 
306 IMF_EXPORT
307 int ImfHeaderM33fAttribute (const ImfHeader *hdr,
308  const char name[],
309  float m[3][3]);
310 
311 IMF_EXPORT
313  const char name[],
314  const float m[4][4]);
315 
316 IMF_EXPORT
317 int ImfHeaderM44fAttribute (const ImfHeader *hdr,
318  const char name[],
319  float m[4][4]);
320 
321 /*
322 ** RGBA output file
323 */
324 
325 struct ImfOutputFile;
327 
328 IMF_EXPORT
329 ImfOutputFile * ImfOpenOutputFile (const char name[],
330  const ImfHeader *hdr,
331  int channels);
332 
333 IMF_EXPORT
335 
336 IMF_EXPORT
338  const ImfRgba *base,
339  size_t xStride,
340  size_t yStride);
341 
342 IMF_EXPORT
344  int numScanLines);
345 
346 IMF_EXPORT
347 int ImfOutputCurrentScanLine (const ImfOutputFile *out);
348 
349 IMF_EXPORT
350 const ImfHeader * ImfOutputHeader (const ImfOutputFile *out);
351 
352 IMF_EXPORT
353 int ImfOutputChannels (const ImfOutputFile *out);
354 
355 
356 /*
357 ** Tiled RGBA output file
358 */
359 
360 struct ImfTiledOutputFile;
362 
363 IMF_EXPORT
365  const ImfHeader *hdr,
366  int channels,
367  int xSize, int ySize,
368  int mode, int rmode);
369 
370 IMF_EXPORT
372 
373 IMF_EXPORT
375  const ImfRgba *base,
376  size_t xStride,
377  size_t yStride);
378 
379 IMF_EXPORT
381  int dx, int dy,
382  int lx, int ly);
383 
384 IMF_EXPORT
386  int dxMin, int dxMax,
387  int dyMin, int dyMax,
388  int lx, int ly);
389 
390 IMF_EXPORT
392 
393 IMF_EXPORT
395 
396 IMF_EXPORT
398 
399 IMF_EXPORT
401 
402 IMF_EXPORT
404 
405 IMF_EXPORT
407  (const ImfTiledOutputFile *out);
408 
409 
410 /*
411 ** RGBA input file
412 */
413 
414 struct ImfInputFile;
415 typedef struct ImfInputFile ImfInputFile;
416 
418 ImfInputFile * ImfOpenInputFile (const char name[]);
419 
420 IMF_EXPORT
422 
423 IMF_EXPORT
425  ImfRgba *base,
426  size_t xStride,
427  size_t yStride);
428 
429 IMF_EXPORT
431  int scanLine1,
432  int scanLine2);
433 
434 IMF_EXPORT
435 const ImfHeader * ImfInputHeader (const ImfInputFile *in);
436 
437 IMF_EXPORT
438 int ImfInputChannels (const ImfInputFile *in);
439 
440 IMF_EXPORT
441 const char * ImfInputFileName (const ImfInputFile *in);
442 
443 
444 /*
445 ** Tiled RGBA input file
446 */
447 
448 struct ImfTiledInputFile;
450 
451 IMF_EXPORT
453 
454 IMF_EXPORT
456 
457 IMF_EXPORT
459  ImfRgba *base,
460  size_t xStride,
461  size_t yStride);
462 
463 IMF_EXPORT
465  int dx, int dy,
466  int lx, int ly);
467 
468 IMF_EXPORT
470  int dxMin, int dxMax,
471  int dyMin, int dyMax,
472  int lx, int ly);
473 
474 IMF_EXPORT
476 
477 IMF_EXPORT
479 
480 IMF_EXPORT
481 const char * ImfTiledInputFileName (const ImfTiledInputFile *in);
482 
483 IMF_EXPORT
485 
486 IMF_EXPORT
488 
489 IMF_EXPORT
491 
492 IMF_EXPORT
494  (const ImfTiledInputFile *in);
495 
496 /*
497 ** Lookup tables
498 */
499 
500 struct ImfLut;
501 typedef struct ImfLut ImfLut;
502 
503 IMF_EXPORT
505 
506 IMF_EXPORT
507 ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels);
508 
509 IMF_EXPORT
510 void ImfDeleteLut (ImfLut *lut);
511 
512 IMF_EXPORT
513 void ImfApplyLut (ImfLut *lut,
514  ImfRgba *data,
515  int nData,
516  int stride);
517 /*
518 ** Most recent error message
519 */
520 
521 IMF_EXPORT
522 const char * ImfErrorMessage (void);
523 
524 
525 #ifdef __cplusplus
526 } /* extern "C" */
527 #endif
528 
529 #endif
IMF_EXPORT int ImfHeaderBox2iAttribute(const ImfHeader *hdr, const char name[], int *xMin, int *yMin, int *xMax, int *yMax)
IMF_EXPORT int ImfTiledInputReadTiles(ImfTiledInputFile *in, int dxMin, int dxMax, int dyMin, int dyMax, int lx, int ly)
IMF_EXPORT int ImfTiledInputLevelMode(const ImfTiledInputFile *in)
struct ImfLut ImfLut
Definition: ImfCRgbaFile.h:501
IMF_EXPORT void ImfHeaderSetPixelAspectRatio(ImfHeader *hdr, float pixelAspectRatio)
IMF_EXPORT int ImfTiledOutputLevelMode(const ImfTiledOutputFile *out)
IMF_EXPORT ImfLut * ImfNewRound12logLut(int channels)
IMF_EXPORT const char * ImfErrorMessage(void)
IMF_EXPORT ImfOutputFile * ImfOpenOutputFile(const char name[], const ImfHeader *hdr, int channels)
unsigned short ImfHalf
Definition: ImfCRgbaFile.h:21
IMF_EXPORT void ImfFloatToHalfArray(int n, const float f[], ImfHalf h[])
IMF_EXPORT int ImfTiledInputSetFrameBuffer(ImfTiledInputFile *in, ImfRgba *base, size_t xStride, size_t yStride)
IMF_EXPORT const ImfHeader * ImfTiledInputHeader(const ImfTiledInputFile *in)
IMF_EXPORT int ImfHeaderCompression(const ImfHeader *hdr)
IMF_EXPORT void ImfApplyLut(ImfLut *lut, ImfRgba *data, int nData, int stride)
IMF_EXPORT int ImfHeaderV3fAttribute(const ImfHeader *hdr, const char name[], float *x, float *y, float *z)
IMF_EXPORT void ImfHeaderDisplayWindow(const ImfHeader *hdr, int *xMin, int *yMin, int *xMax, int *yMax)
IMF_EXPORT ImfHeader * ImfNewHeader(void)
IMF_EXPORT const char * ImfInputFileName(const ImfInputFile *in)
struct ImfTiledOutputFile ImfTiledOutputFile
Definition: ImfCRgbaFile.h:361
IMF_EXPORT int ImfHeaderSetBox2iAttribute(ImfHeader *hdr, const char name[], int xMin, int yMin, int xMax, int yMax)
IMF_EXPORT ImfHeader * ImfCopyHeader(const ImfHeader *hdr)
IMF_EXPORT int ImfHeaderSetBox2fAttribute(ImfHeader *hdr, const char name[], float xMin, float yMin, float xMax, float yMax)
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
GLint y
Definition: glcorearb.h:103
IMF_EXPORT int ImfTiledOutputSetFrameBuffer(ImfTiledOutputFile *out, const ImfRgba *base, size_t xStride, size_t yStride)
struct ImfInputFile ImfInputFile
Definition: ImfCRgbaFile.h:415
IMF_EXPORT int ImfHeaderV2fAttribute(const ImfHeader *hdr, const char name[], float *x, float *y)
IMF_EXPORT void ImfHeaderSetCompression(ImfHeader *hdr, int compression)
IMF_EXPORT void ImfFloatToHalf(float f, ImfHalf *h)
IMF_EXPORT float ImfHeaderScreenWindowWidth(const ImfHeader *hdr)
IMF_EXPORT int ImfInputReadPixels(ImfInputFile *in, int scanLine1, int scanLine2)
IMF_EXPORT const ImfHeader * ImfTiledOutputHeader(const ImfTiledOutputFile *out)
IMF_EXPORT int ImfHeaderSetV2fAttribute(ImfHeader *hdr, const char name[], float x, float y)
IMF_EXPORT int ImfHeaderSetIntAttribute(ImfHeader *hdr, const char name[], int value)
IMF_EXPORT int ImfHeaderSetM44fAttribute(ImfHeader *hdr, const char name[], const float m[4][4])
GLdouble n
Definition: glcorearb.h:2008
IMF_EXPORT int ImfHeaderFloatAttribute(const ImfHeader *hdr, const char name[], float *value)
GLfloat f
Definition: glcorearb.h:1926
IMF_EXPORT int ImfHeaderM44fAttribute(const ImfHeader *hdr, const char name[], float m[4][4])
struct ImfHeader ImfHeader
Definition: ImfCRgbaFile.h:130
IMF_EXPORT int ImfOutputCurrentScanLine(const ImfOutputFile *out)
struct ImfTiledInputFile ImfTiledInputFile
Definition: ImfCRgbaFile.h:449
IMF_EXPORT int ImfInputChannels(const ImfInputFile *in)
IMF_EXPORT int ImfHeaderStringAttribute(const ImfHeader *hdr, const char name[], const char **value)
IMF_EXPORT ImfTiledInputFile * ImfOpenTiledInputFile(const char name[])
IMF_EXPORT int ImfTiledInputChannels(const ImfTiledInputFile *in)
IMF_EXPORT void ImfHeaderSetDataWindow(ImfHeader *hdr, int xMin, int yMin, int xMax, int yMax)
IMF_EXPORT int ImfHeaderSetStringAttribute(ImfHeader *hdr, const char name[], const char value[])
IMF_EXPORT int ImfHeaderBox2fAttribute(const ImfHeader *hdr, const char name[], float *xMin, float *yMin, float *xMax, float *yMax)
IMF_EXPORT int ImfTiledOutputWriteTiles(ImfTiledOutputFile *out, int dxMin, int dxMax, int dyMin, int dyMax, int lx, int ly)
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
IMF_EXPORT int ImfHeaderDoubleAttribute(const ImfHeader *hdr, const char name[], double *value)
IMF_EXPORT void ImfDeleteHeader(ImfHeader *hdr)
IMF_EXPORT int ImfHeaderSetV3fAttribute(ImfHeader *hdr, const char name[], float x, float y, float z)
IMF_EXPORT const char * ImfTiledInputFileName(const ImfTiledInputFile *in)
#define IMF_EXPORT
Definition: ImfExport.h:54
IMF_EXPORT void ImfHeaderSetScreenWindowCenter(ImfHeader *hdr, float x, float y)
IMF_EXPORT int ImfHeaderSetV2iAttribute(ImfHeader *hdr, const char name[], int x, int y)
GLuint const GLchar * name
Definition: glcorearb.h:786
IMF_EXPORT int ImfHeaderIntAttribute(const ImfHeader *hdr, const char name[], int *value)
IMF_EXPORT float ImfHalfToFloat(ImfHalf h)
IMF_EXPORT int ImfHeaderSetV3iAttribute(ImfHeader *hdr, const char name[], int x, int y, int z)
HUSD_API const char * pixelAspectRatio()
IMF_EXPORT int ImfOutputWritePixels(ImfOutputFile *out, int numScanLines)
GLint GLenum GLint x
Definition: glcorearb.h:409
IMF_EXPORT void ImfHeaderDataWindow(const ImfHeader *hdr, int *xMin, int *yMin, int *xMax, int *yMax)
IMF_EXPORT int ImfOutputChannels(const ImfOutputFile *out)
IMF_EXPORT int ImfOutputSetFrameBuffer(ImfOutputFile *out, const ImfRgba *base, size_t xStride, size_t yStride)
ImfHalf a
Definition: ImfCRgbaFile.h:49
IMF_EXPORT int ImfHeaderV2iAttribute(const ImfHeader *hdr, const char name[], int *x, int *y)
GLenum mode
Definition: glcorearb.h:99
IMF_EXPORT int ImfTiledOutputTileXSize(const ImfTiledOutputFile *out)
IMF_EXPORT int ImfHeaderV3iAttribute(const ImfHeader *hdr, const char name[], int *x, int *y, int *z)
IMF_EXPORT ImfInputFile * ImfOpenInputFile(const char name[])
IMF_EXPORT void ImfHeaderSetDisplayWindow(ImfHeader *hdr, int xMin, int yMin, int xMax, int yMax)
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
IMF_EXPORT void ImfHeaderSetScreenWindowWidth(ImfHeader *hdr, float width)
IMF_EXPORT int ImfTiledOutputLevelRoundingMode(const ImfTiledOutputFile *out)
IMF_EXPORT void ImfDeleteLut(ImfLut *lut)
IMF_EXPORT int ImfHeaderSetFloatAttribute(ImfHeader *hdr, const char name[], float value)
IMF_EXPORT int ImfCloseInputFile(ImfInputFile *in)
IMF_EXPORT int ImfHeaderLineOrder(const ImfHeader *hdr)
IMF_EXPORT int ImfTiledInputLevelRoundingMode(const ImfTiledInputFile *in)
IMF_EXPORT int ImfCloseTiledOutputFile(ImfTiledOutputFile *out)
IMF_EXPORT const ImfHeader * ImfOutputHeader(const ImfOutputFile *out)
IMF_EXPORT int ImfTiledInputTileXSize(const ImfTiledInputFile *in)
IMF_EXPORT int ImfHeaderM33fAttribute(const ImfHeader *hdr, const char name[], float m[3][3])
IMF_EXPORT void ImfHeaderScreenWindowCenter(const ImfHeader *hdr, float *x, float *y)
struct ImfOutputFile ImfOutputFile
Definition: ImfCRgbaFile.h:326
IMF_EXPORT int ImfTiledOutputWriteTile(ImfTiledOutputFile *out, int dx, int dy, int lx, int ly)
IMF_EXPORT const ImfHeader * ImfInputHeader(const ImfInputFile *in)
IMF_EXPORT int ImfInputSetFrameBuffer(ImfInputFile *in, ImfRgba *base, size_t xStride, size_t yStride)
IMF_EXPORT int ImfCloseOutputFile(ImfOutputFile *out)
GLint GLsizei width
Definition: glcorearb.h:103
IMF_EXPORT int ImfTiledInputTileYSize(const ImfTiledInputFile *in)
IMF_EXPORT ImfLut * ImfNewRoundNBitLut(unsigned int n, int channels)
Definition: core.h:1131
IMF_EXPORT float ImfHeaderPixelAspectRatio(const ImfHeader *hdr)
ImfHalf b
Definition: ImfCRgbaFile.h:48
IMF_EXPORT ImfTiledOutputFile * ImfOpenTiledOutputFile(const char name[], const ImfHeader *hdr, int channels, int xSize, int ySize, int mode, int rmode)
IMF_EXPORT void ImfHeaderSetLineOrder(ImfHeader *hdr, int lineOrder)
IMF_EXPORT int ImfCloseTiledInputFile(ImfTiledInputFile *in)
IMF_EXPORT int ImfTiledOutputChannels(const ImfTiledOutputFile *out)
ImfHalf g
Definition: ImfCRgbaFile.h:47
IMF_EXPORT int ImfHeaderSetDoubleAttribute(ImfHeader *hdr, const char name[], double value)
IMF_EXPORT int ImfHeaderSetM33fAttribute(ImfHeader *hdr, const char name[], const float m[3][3])
Definition: format.h:895
ImfHalf r
Definition: ImfCRgbaFile.h:46
IMF_EXPORT int ImfTiledOutputTileYSize(const ImfTiledOutputFile *out)
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
IMF_EXPORT void ImfHalfToFloatArray(int n, const ImfHalf h[], float f[])
IMF_EXPORT int ImfTiledInputReadTile(ImfTiledInputFile *in, int dx, int dy, int lx, int ly)