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 
84 /*
85 ** Channels; values must be the same as in Imf::RgbaChannels.
86 */
87 
88 #define IMF_WRITE_R 0x01
89 #define IMF_WRITE_G 0x02
90 #define IMF_WRITE_B 0x04
91 #define IMF_WRITE_A 0x08
92 #define IMF_WRITE_Y 0x10
93 #define IMF_WRITE_C 0x20
94 #define IMF_WRITE_RGB 0x07
95 #define IMF_WRITE_RGBA 0x0f
96 #define IMF_WRITE_YC 0x30
97 #define IMF_WRITE_YA 0x18
98 #define IMF_WRITE_YCA 0x38
99 
100 /*
101 ** Level modes; values must be the same as in Imf::LevelMode
102 */
103 
104 #define IMF_ONE_LEVEL 0
105 #define IMF_MIPMAP_LEVELS 1
106 #define IMF_RIPMAP_LEVELS 2
107 
108 /*
109 ** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
110 */
111 
112 #define IMF_ROUND_DOWN 0
113 #define IMF_ROUND_UP 1
114 
115 /*
116 ** RGBA file header
117 */
118 
119 struct ImfHeader;
120 typedef struct ImfHeader ImfHeader;
121 
123 ImfHeader* ImfNewHeader (void);
124 
126 void ImfDeleteHeader (ImfHeader* hdr);
127 
129 ImfHeader* ImfCopyHeader (const ImfHeader* hdr);
130 
133  ImfHeader* hdr, int xMin, int yMin, int xMax, int yMax);
134 
137  const ImfHeader* hdr, int* xMin, int* yMin, int* xMax, int* yMax);
138 
140 void
141 ImfHeaderSetDataWindow (ImfHeader* hdr, int xMin, int yMin, int xMax, int yMax);
142 
144 void ImfHeaderDataWindow (
145  const ImfHeader* hdr, int* xMin, int* yMin, int* xMax, int* yMax);
146 
149 
151 float ImfHeaderPixelAspectRatio (const ImfHeader* hdr);
152 
154 void ImfHeaderSetScreenWindowCenter (ImfHeader* hdr, float x, float y);
155 
157 void ImfHeaderScreenWindowCenter (const ImfHeader* hdr, float* x, float* y);
158 
161 
163 float ImfHeaderScreenWindowWidth (const ImfHeader* hdr);
164 
166 void ImfHeaderSetLineOrder (ImfHeader* hdr, int lineOrder);
167 
169 int ImfHeaderLineOrder (const ImfHeader* hdr);
170 
172 void ImfHeaderSetCompression (ImfHeader* hdr, int compression);
173 
175 int ImfHeaderCompression (const ImfHeader* hdr);
176 
178 int ImfHeaderSetIntAttribute (ImfHeader* hdr, const char name[], int value);
179 
181 int ImfHeaderIntAttribute (const ImfHeader* hdr, const char name[], int* value);
182 
184 int ImfHeaderSetFloatAttribute (ImfHeader* hdr, const char name[], float value);
185 
187 int
188 ImfHeaderSetDoubleAttribute (ImfHeader* hdr, const char name[], double value);
189 
191 int
192 ImfHeaderFloatAttribute (const ImfHeader* hdr, const char name[], float* value);
193 
196  const ImfHeader* hdr, const char name[], double* value);
197 
200  ImfHeader* hdr, const char name[], const char value[]);
201 
204  const ImfHeader* hdr, const char name[], const char** value);
205 
208  ImfHeader* hdr, const char name[], int xMin, int yMin, int xMax, int yMax);
209 
212  const ImfHeader* hdr,
213  const char name[],
214  int* xMin,
215  int* yMin,
216  int* xMax,
217  int* yMax);
218 
221  ImfHeader* hdr,
222  const char name[],
223  float xMin,
224  float yMin,
225  float xMax,
226  float yMax);
227 
230  const ImfHeader* hdr,
231  const char name[],
232  float* xMin,
233  float* yMin,
234  float* xMax,
235  float* yMax);
236 
238 int ImfHeaderSetV2iAttribute (ImfHeader* hdr, const char name[], int x, int y);
239 
241 int
242 ImfHeaderV2iAttribute (const ImfHeader* hdr, const char name[], int* x, int* y);
243 
245 int
246 ImfHeaderSetV2fAttribute (ImfHeader* hdr, const char name[], float x, float y);
247 
250  const ImfHeader* hdr, const char name[], float* x, float* y);
251 
254  ImfHeader* hdr, const char name[], int x, int y, int z);
255 
258  const ImfHeader* hdr, const char name[], int* x, int* y, int* z);
259 
262  ImfHeader* hdr, const char name[], float x, float y, float z);
263 
266  const ImfHeader* hdr, const char name[], float* x, float* y, float* z);
267 
270  ImfHeader* hdr, const char name[], const float m[3][3]);
271 
273 int
274 ImfHeaderM33fAttribute (const ImfHeader* hdr, const char name[], float m[3][3]);
275 
278  ImfHeader* hdr, const char name[], const float m[4][4]);
279 
281 int
282 ImfHeaderM44fAttribute (const ImfHeader* hdr, const char name[], float m[4][4]);
283 
284 /*
285 ** RGBA output file
286 */
287 
288 struct ImfOutputFile;
290 
293 ImfOpenOutputFile (const char name[], const ImfHeader* hdr, int channels);
294 
297 
300  ImfOutputFile* out, const ImfRgba* base, size_t xStride, size_t yStride);
301 
303 int ImfOutputWritePixels (ImfOutputFile* out, int numScanLines);
304 
306 int ImfOutputCurrentScanLine (const ImfOutputFile* out);
307 
309 const ImfHeader* ImfOutputHeader (const ImfOutputFile* out);
310 
312 int ImfOutputChannels (const ImfOutputFile* out);
313 
314 /*
315 ** Tiled RGBA output file
316 */
317 
318 struct ImfTiledOutputFile;
320 
323  const char name[],
324  const ImfHeader* hdr,
325  int channels,
326  int xSize,
327  int ySize,
328  int mode,
329  int rmode);
330 
333 
336  ImfTiledOutputFile* out,
337  const ImfRgba* base,
338  size_t xStride,
339  size_t yStride);
340 
343  ImfTiledOutputFile* out, int dx, int dy, int lx, int ly);
344 
347  ImfTiledOutputFile* out,
348  int dxMin,
349  int dxMax,
350  int dyMin,
351  int dyMax,
352  int lx,
353  int ly);
354 
357 
360 
363 
366 
369 
372 
373 /*
374 ** RGBA input file
375 */
376 
377 struct ImfInputFile;
378 typedef struct ImfInputFile ImfInputFile;
379 
381 ImfInputFile* ImfOpenInputFile (const char name[]);
382 
385 
388  ImfInputFile* in, ImfRgba* base, size_t xStride, size_t yStride);
389 
391 int ImfInputReadPixels (ImfInputFile* in, int scanLine1, int scanLine2);
392 
394 const ImfHeader* ImfInputHeader (const ImfInputFile* in);
395 
397 int ImfInputChannels (const ImfInputFile* in);
398 
400 const char* ImfInputFileName (const ImfInputFile* in);
401 
402 /*
403 ** Tiled RGBA input file
404 */
405 
406 struct ImfTiledInputFile;
408 
411 
414 
417  ImfTiledInputFile* in, ImfRgba* base, size_t xStride, size_t yStride);
418 
420 int
421 ImfTiledInputReadTile (ImfTiledInputFile* in, int dx, int dy, int lx, int ly);
422 
425  ImfTiledInputFile* in,
426  int dxMin,
427  int dxMax,
428  int dyMin,
429  int dyMax,
430  int lx,
431  int ly);
432 
435 
438 
440 const char* ImfTiledInputFileName (const ImfTiledInputFile* in);
441 
444 
447 
450 
453 
454 /*
455 ** Lookup tables
456 */
457 
458 struct ImfLut;
459 typedef struct ImfLut ImfLut;
460 
463 
465 ImfLut* ImfNewRoundNBitLut (unsigned int n, int channels);
466 
468 void ImfDeleteLut (ImfLut* lut);
469 
471 void ImfApplyLut (ImfLut* lut, ImfRgba* data, int nData, int stride);
472 /*
473 ** Most recent error message
474 */
475 
477 const char* ImfErrorMessage (void);
478 
479 #ifdef __cplusplus
480 } /* extern "C" */
481 #endif
482 
483 #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:459
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:319
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:378
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:120
IMF_EXPORT int ImfOutputCurrentScanLine(const ImfOutputFile *out)
struct ImfTiledInputFile ImfTiledInputFile
Definition: ImfCRgbaFile.h:407
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:289
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: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:895
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)