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, ImfHalf* h);
25 
27 void ImfFloatToHalfArray (int n, const float f[/*n*/], ImfHalf h[/*n*/]);
28 
30 float ImfHalfToFloat (ImfHalf h);
31 
33 void ImfHalfToFloatArray (int n, const ImfHalf h[/*n*/], float f[/*n*/]);
34 
35 /*
36 ** RGBA pixel; memory layout must be the same as struct Imf::Rgba.
37 */
38 
39 struct ImfRgba
40 {
41  ImfHalf r;
42  ImfHalf g;
43  ImfHalf b;
44  ImfHalf a;
45 };
46 
47 typedef struct ImfRgba ImfRgba;
48 
49 /*
50 ** Magic number; this must be the same as Imf::MAGIC
51 */
52 
53 #define IMF_MAGIC 20000630
54 
55 /*
56 ** Version number; this must be the same as Imf::EXR_VERSION
57 */
58 
59 #define IMF_VERSION_NUMBER 2
60 
61 /*
62 ** Line order; values must be the same as in Imf::LineOrder.
63 */
64 
65 #define IMF_INCREASING_Y 0
66 #define IMF_DECREASING_Y 1
67 #define IMF_RANDOM_Y 2
68 
69 /*
70 ** Compression types; values must be the same as in Imf::Compression.
71 */
72 
73 #define IMF_NO_COMPRESSION 0
74 #define IMF_RLE_COMPRESSION 1
75 #define IMF_ZIPS_COMPRESSION 2
76 #define IMF_ZIP_COMPRESSION 3
77 #define IMF_PIZ_COMPRESSION 4
78 #define IMF_PXR24_COMPRESSION 5
79 #define IMF_B44_COMPRESSION 6
80 #define IMF_B44A_COMPRESSION 7
81 #define IMF_DWAA_COMPRESSION 8
82 #define IMF_DWAB_COMPRESSION 9
83 #define IMF_NUM_COMPRESSION_METHODS 10
84 
85 /*
86 ** Channels; values must be the same as in Imf::RgbaChannels.
87 */
88 
89 #define IMF_WRITE_R 0x01
90 #define IMF_WRITE_G 0x02
91 #define IMF_WRITE_B 0x04
92 #define IMF_WRITE_A 0x08
93 #define IMF_WRITE_Y 0x10
94 #define IMF_WRITE_C 0x20
95 #define IMF_WRITE_RGB 0x07
96 #define IMF_WRITE_RGBA 0x0f
97 #define IMF_WRITE_YC 0x30
98 #define IMF_WRITE_YA 0x18
99 #define IMF_WRITE_YCA 0x38
100 
101 /*
102 ** Level modes; values must be the same as in Imf::LevelMode
103 */
104 
105 #define IMF_ONE_LEVEL 0
106 #define IMF_MIPMAP_LEVELS 1
107 #define IMF_RIPMAP_LEVELS 2
108 
109 /*
110 ** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
111 */
112 
113 #define IMF_ROUND_DOWN 0
114 #define IMF_ROUND_UP 1
115 
116 /*
117 ** RGBA file header
118 */
119 
120 struct ImfHeader;
121 typedef struct ImfHeader ImfHeader;
122 
124 ImfHeader* ImfNewHeader (void);
125 
127 void ImfDeleteHeader (ImfHeader* hdr);
128 
130 ImfHeader* ImfCopyHeader (const ImfHeader* hdr);
131 
134  ImfHeader* hdr, int xMin, int yMin, int xMax, int yMax);
135 
138  const ImfHeader* hdr, int* xMin, int* yMin, int* xMax, int* yMax);
139 
141 void
142 ImfHeaderSetDataWindow (ImfHeader* hdr, int xMin, int yMin, int xMax, int yMax);
143 
145 void ImfHeaderDataWindow (
146  const ImfHeader* hdr, int* xMin, int* yMin, int* xMax, int* yMax);
147 
150 
152 float ImfHeaderPixelAspectRatio (const ImfHeader* hdr);
153 
155 void ImfHeaderSetScreenWindowCenter (ImfHeader* hdr, float x, float y);
156 
158 void ImfHeaderScreenWindowCenter (const ImfHeader* hdr, float* x, float* y);
159 
162 
164 float ImfHeaderScreenWindowWidth (const ImfHeader* hdr);
165 
167 void ImfHeaderSetLineOrder (ImfHeader* hdr, int lineOrder);
168 
170 int ImfHeaderLineOrder (const ImfHeader* hdr);
171 
173 void ImfHeaderSetCompression (ImfHeader* hdr, int compression);
174 
176 int ImfHeaderCompression (const ImfHeader* hdr);
177 
179 int ImfHeaderSetIntAttribute (ImfHeader* hdr, const char name[], int value);
180 
182 int ImfHeaderIntAttribute (const ImfHeader* hdr, const char name[], int* value);
183 
185 int ImfHeaderSetFloatAttribute (ImfHeader* hdr, const char name[], float value);
186 
188 int
189 ImfHeaderSetDoubleAttribute (ImfHeader* hdr, const char name[], double value);
190 
192 int
193 ImfHeaderFloatAttribute (const ImfHeader* hdr, const char name[], float* value);
194 
197  const ImfHeader* hdr, const char name[], double* value);
198 
201  ImfHeader* hdr, const char name[], const char value[]);
202 
205  const ImfHeader* hdr, const char name[], const char** value);
206 
209  ImfHeader* hdr, const char name[], int xMin, int yMin, int xMax, int yMax);
210 
213  const ImfHeader* hdr,
214  const char name[],
215  int* xMin,
216  int* yMin,
217  int* xMax,
218  int* yMax);
219 
222  ImfHeader* hdr,
223  const char name[],
224  float xMin,
225  float yMin,
226  float xMax,
227  float yMax);
228 
231  const ImfHeader* hdr,
232  const char name[],
233  float* xMin,
234  float* yMin,
235  float* xMax,
236  float* yMax);
237 
239 int ImfHeaderSetV2iAttribute (ImfHeader* hdr, const char name[], int x, int y);
240 
242 int
243 ImfHeaderV2iAttribute (const ImfHeader* hdr, const char name[], int* x, int* y);
244 
246 int
247 ImfHeaderSetV2fAttribute (ImfHeader* hdr, const char name[], float x, float y);
248 
251  const ImfHeader* hdr, const char name[], float* x, float* y);
252 
255  ImfHeader* hdr, const char name[], int x, int y, int z);
256 
259  const ImfHeader* hdr, const char name[], int* x, int* y, int* z);
260 
263  ImfHeader* hdr, const char name[], float x, float y, float z);
264 
267  const ImfHeader* hdr, const char name[], float* x, float* y, float* z);
268 
271  ImfHeader* hdr, const char name[], const float m[3][3]);
272 
274 int
275 ImfHeaderM33fAttribute (const ImfHeader* hdr, const char name[], float m[3][3]);
276 
279  ImfHeader* hdr, const char name[], const float m[4][4]);
280 
282 int
283 ImfHeaderM44fAttribute (const ImfHeader* hdr, const char name[], float m[4][4]);
284 
285 /*
286 ** RGBA output file
287 */
288 
289 struct ImfOutputFile;
291 
294 ImfOpenOutputFile (const char name[], const ImfHeader* hdr, int channels);
295 
298 
301  ImfOutputFile* out, const ImfRgba* base, size_t xStride, size_t yStride);
302 
304 int ImfOutputWritePixels (ImfOutputFile* out, int numScanLines);
305 
307 int ImfOutputCurrentScanLine (const ImfOutputFile* out);
308 
310 const ImfHeader* ImfOutputHeader (const ImfOutputFile* out);
311 
313 int ImfOutputChannels (const ImfOutputFile* out);
314 
315 /*
316 ** Tiled RGBA output file
317 */
318 
319 struct ImfTiledOutputFile;
321 
324  const char name[],
325  const ImfHeader* hdr,
326  int channels,
327  int xSize,
328  int ySize,
329  int mode,
330  int rmode);
331 
334 
337  ImfTiledOutputFile* out,
338  const ImfRgba* base,
339  size_t xStride,
340  size_t yStride);
341 
344  ImfTiledOutputFile* out, int dx, int dy, int lx, int ly);
345 
348  ImfTiledOutputFile* out,
349  int dxMin,
350  int dxMax,
351  int dyMin,
352  int dyMax,
353  int lx,
354  int ly);
355 
358 
361 
364 
367 
370 
373 
374 /*
375 ** RGBA input file
376 */
377 
378 struct ImfInputFile;
379 typedef struct ImfInputFile ImfInputFile;
380 
382 ImfInputFile* ImfOpenInputFile (const char name[]);
383 
386 
389  ImfInputFile* in, ImfRgba* base, size_t xStride, size_t yStride);
390 
392 int ImfInputReadPixels (ImfInputFile* in, int scanLine1, int scanLine2);
393 
395 const ImfHeader* ImfInputHeader (const ImfInputFile* in);
396 
398 int ImfInputChannels (const ImfInputFile* in);
399 
401 const char* ImfInputFileName (const ImfInputFile* in);
402 
403 /*
404 ** Tiled RGBA input file
405 */
406 
407 struct ImfTiledInputFile;
409 
412 
415 
418  ImfTiledInputFile* in, ImfRgba* base, size_t xStride, size_t yStride);
419 
421 int
422 ImfTiledInputReadTile (ImfTiledInputFile* in, int dx, int dy, int lx, int ly);
423 
427  int dxMin,
428  int dxMax,
429  int dyMin,
430  int dyMax,
431  int lx,
432  int ly);
433 
436 
439 
441 const char* ImfTiledInputFileName (const ImfTiledInputFile* in);
442 
445 
448 
451 
454 
455 /*
456 ** Lookup tables
457 */
458 
459 struct ImfLut;
460 typedef struct ImfLut ImfLut;
461 
464 
466 ImfLut* ImfNewRoundNBitLut (unsigned int n, int channels);
467 
469 void ImfDeleteLut (ImfLut* lut);
470 
472 void ImfApplyLut (ImfLut* lut, ImfRgba* data, int nData, int stride);
473 /*
474 ** Most recent error message
475 */
476 
478 const char* ImfErrorMessage (void);
479 
480 #ifdef __cplusplus
481 } /* extern "C" */
482 #endif
483 
484 #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:460
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:320
GLsizei const GLfloat * value
Definition: glcorearb.h:824
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:379
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)
constexpr auto in(type t, int set) -> bool
Definition: core.h:611
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:121
IMF_EXPORT int ImfOutputCurrentScanLine(const ImfOutputFile *out)
struct ImfTiledInputFile ImfTiledInputFile
Definition: ImfCRgbaFile.h:408
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:44
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:290
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)
IMF_EXPORT float ImfHeaderPixelAspectRatio(const ImfHeader *hdr)
ImfHalf b
Definition: ImfCRgbaFile.h:43
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:42
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:1821
ImfHalf r
Definition: ImfCRgbaFile.h:41
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)