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_HTJ2K256_COMPRESSION 10
84 #define IMF_HTJ2K32_COMPRESSION 11
85 #define IMF_NUM_COMPRESSION_METHODS 12
86 
87 /*
88 ** Channels; values must be the same as in Imf::RgbaChannels.
89 */
90 
91 #define IMF_WRITE_R 0x01
92 #define IMF_WRITE_G 0x02
93 #define IMF_WRITE_B 0x04
94 #define IMF_WRITE_A 0x08
95 #define IMF_WRITE_Y 0x10
96 #define IMF_WRITE_C 0x20
97 #define IMF_WRITE_RGB 0x07
98 #define IMF_WRITE_RGBA 0x0f
99 #define IMF_WRITE_YC 0x30
100 #define IMF_WRITE_YA 0x18
101 #define IMF_WRITE_YCA 0x38
102 
103 /*
104 ** Level modes; values must be the same as in Imf::LevelMode
105 */
106 
107 #define IMF_ONE_LEVEL 0
108 #define IMF_MIPMAP_LEVELS 1
109 #define IMF_RIPMAP_LEVELS 2
110 
111 /*
112 ** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
113 */
114 
115 #define IMF_ROUND_DOWN 0
116 #define IMF_ROUND_UP 1
117 
118 /*
119 ** RGBA file header
120 */
121 
122 struct ImfHeader;
123 typedef struct ImfHeader ImfHeader;
124 
126 ImfHeader* ImfNewHeader (void);
127 
129 void ImfDeleteHeader (ImfHeader* hdr);
130 
132 ImfHeader* ImfCopyHeader (const ImfHeader* hdr);
133 
136  ImfHeader* hdr, int xMin, int yMin, int xMax, int yMax);
137 
140  const ImfHeader* hdr, int* xMin, int* yMin, int* xMax, int* yMax);
141 
143 void
144 ImfHeaderSetDataWindow (ImfHeader* hdr, int xMin, int yMin, int xMax, int yMax);
145 
147 void ImfHeaderDataWindow (
148  const ImfHeader* hdr, int* xMin, int* yMin, int* xMax, int* yMax);
149 
152 
154 float ImfHeaderPixelAspectRatio (const ImfHeader* hdr);
155 
157 void ImfHeaderSetScreenWindowCenter (ImfHeader* hdr, float x, float y);
158 
160 void ImfHeaderScreenWindowCenter (const ImfHeader* hdr, float* x, float* y);
161 
164 
166 float ImfHeaderScreenWindowWidth (const ImfHeader* hdr);
167 
169 void ImfHeaderSetLineOrder (ImfHeader* hdr, int lineOrder);
170 
172 int ImfHeaderLineOrder (const ImfHeader* hdr);
173 
175 void ImfHeaderSetCompression (ImfHeader* hdr, int compression);
176 
178 int ImfHeaderCompression (const ImfHeader* hdr);
179 
181 int ImfHeaderSetIntAttribute (ImfHeader* hdr, const char name[], int value);
182 
184 int ImfHeaderIntAttribute (const ImfHeader* hdr, const char name[], int* value);
185 
187 int ImfHeaderSetFloatAttribute (ImfHeader* hdr, const char name[], float value);
188 
190 int
191 ImfHeaderSetDoubleAttribute (ImfHeader* hdr, const char name[], double value);
192 
194 int
195 ImfHeaderFloatAttribute (const ImfHeader* hdr, const char name[], float* value);
196 
199  const ImfHeader* hdr, const char name[], double* value);
200 
203  ImfHeader* hdr, const char name[], const char value[]);
204 
207  const ImfHeader* hdr, const char name[], const char** value);
208 
211  ImfHeader* hdr, const char name[], int xMin, int yMin, int xMax, int yMax);
212 
215  const ImfHeader* hdr,
216  const char name[],
217  int* xMin,
218  int* yMin,
219  int* xMax,
220  int* yMax);
221 
224  ImfHeader* hdr,
225  const char name[],
226  float xMin,
227  float yMin,
228  float xMax,
229  float yMax);
230 
233  const ImfHeader* hdr,
234  const char name[],
235  float* xMin,
236  float* yMin,
237  float* xMax,
238  float* yMax);
239 
241 int ImfHeaderSetV2iAttribute (ImfHeader* hdr, const char name[], int x, int y);
242 
244 int
245 ImfHeaderV2iAttribute (const ImfHeader* hdr, const char name[], int* x, int* y);
246 
248 int
249 ImfHeaderSetV2fAttribute (ImfHeader* hdr, const char name[], float x, float y);
250 
253  const ImfHeader* hdr, const char name[], float* x, float* y);
254 
257  ImfHeader* hdr, const char name[], int x, int y, int z);
258 
261  const ImfHeader* hdr, const char name[], int* x, int* y, int* z);
262 
265  ImfHeader* hdr, const char name[], float x, float y, float z);
266 
269  const ImfHeader* hdr, const char name[], float* x, float* y, float* z);
270 
273  ImfHeader* hdr, const char name[], const float m[3][3]);
274 
276 int
277 ImfHeaderM33fAttribute (const ImfHeader* hdr, const char name[], float m[3][3]);
278 
281  ImfHeader* hdr, const char name[], const float m[4][4]);
282 
284 int
285 ImfHeaderM44fAttribute (const ImfHeader* hdr, const char name[], float m[4][4]);
286 
287 /*
288 ** RGBA output file
289 */
290 
291 struct ImfOutputFile;
293 
296 ImfOpenOutputFile (const char name[], const ImfHeader* hdr, int channels);
297 
300 
303  ImfOutputFile* out, const ImfRgba* base, size_t xStride, size_t yStride);
304 
306 int ImfOutputWritePixels (ImfOutputFile* out, int numScanLines);
307 
309 int ImfOutputCurrentScanLine (const ImfOutputFile* out);
310 
312 const ImfHeader* ImfOutputHeader (const ImfOutputFile* out);
313 
315 int ImfOutputChannels (const ImfOutputFile* out);
316 
317 /*
318 ** Tiled RGBA output file
319 */
320 
321 struct ImfTiledOutputFile;
323 
326  const char name[],
327  const ImfHeader* hdr,
328  int channels,
329  int xSize,
330  int ySize,
331  int mode,
332  int rmode);
333 
336 
339  ImfTiledOutputFile* out,
340  const ImfRgba* base,
341  size_t xStride,
342  size_t yStride);
343 
346  ImfTiledOutputFile* out, int dx, int dy, int lx, int ly);
347 
350  ImfTiledOutputFile* out,
351  int dxMin,
352  int dxMax,
353  int dyMin,
354  int dyMax,
355  int lx,
356  int ly);
357 
360 
363 
366 
369 
372 
375 
376 /*
377 ** RGBA input file
378 */
379 
380 struct ImfInputFile;
381 typedef struct ImfInputFile ImfInputFile;
382 
384 ImfInputFile* ImfOpenInputFile (const char name[]);
385 
388 
391  ImfInputFile* in, ImfRgba* base, size_t xStride, size_t yStride);
392 
394 int ImfInputReadPixels (ImfInputFile* in, int scanLine1, int scanLine2);
395 
397 const ImfHeader* ImfInputHeader (const ImfInputFile* in);
398 
400 int ImfInputChannels (const ImfInputFile* in);
401 
403 const char* ImfInputFileName (const ImfInputFile* in);
404 
405 /*
406 ** Tiled RGBA input file
407 */
408 
409 struct ImfTiledInputFile;
411 
414 
417 
420  ImfTiledInputFile* in, ImfRgba* base, size_t xStride, size_t yStride);
421 
423 int
424 ImfTiledInputReadTile (ImfTiledInputFile* in, int dx, int dy, int lx, int ly);
425 
429  int dxMin,
430  int dxMax,
431  int dyMin,
432  int dyMax,
433  int lx,
434  int ly);
435 
438 
441 
443 const char* ImfTiledInputFileName (const ImfTiledInputFile* in);
444 
447 
450 
453 
456 
457 /*
458 ** Lookup tables
459 */
460 
461 struct ImfLut;
462 typedef struct ImfLut ImfLut;
463 
466 
468 ImfLut* ImfNewRoundNBitLut (unsigned int n, int channels);
469 
471 void ImfDeleteLut (ImfLut* lut);
472 
474 void ImfApplyLut (ImfLut* lut, ImfRgba* data, int nData, int stride);
475 /*
476 ** Most recent error message
477 */
478 
480 const char* ImfErrorMessage (void);
481 
482 #ifdef __cplusplus
483 } /* extern "C" */
484 #endif
485 
486 #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:462
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:322
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:381
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:123
IMF_EXPORT int ImfOutputCurrentScanLine(const ImfOutputFile *out)
struct ImfTiledInputFile ImfTiledInputFile
Definition: ImfCRgbaFile.h:410
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:292
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)