PageRenderTime 2225ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/3rdparty/openexr/IlmImf/ImfCRgbaFile.h

https://gitlab.com/generic-library/opencv
C Header | 467 lines | 254 code | 132 blank | 81 comment | 0 complexity | 3677c69affcad045a91fd51e285b43b2 MD5 | raw file
  1. /*
  2. Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
  3. Digital Ltd. LLC
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions are
  7. met:
  8. * Redistributions of source code must retain the above copyright
  9. notice, this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above
  11. copyright notice, this list of conditions and the following disclaimer
  12. in the documentation and/or other materials provided with the
  13. distribution.
  14. * Neither the name of Industrial Light & Magic nor the names of
  15. its contributors may be used to endorse or promote products derived
  16. from this software without specific prior written permission.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef INCLUDED_IMF_C_RGBA_FILE_H
  30. #define INCLUDED_IMF_C_RGBA_FILE_H
  31. #include <stdlib.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /*
  36. ** Interpreting unsigned shorts as 16-bit floating point numbers
  37. */
  38. typedef unsigned short ImfHalf;
  39. void ImfFloatToHalf (float f,
  40. ImfHalf *h);
  41. void ImfFloatToHalfArray (int n,
  42. const float f[/*n*/],
  43. ImfHalf h[/*n*/]);
  44. float ImfHalfToFloat (ImfHalf h);
  45. void ImfHalfToFloatArray (int n,
  46. const ImfHalf h[/*n*/],
  47. float f[/*n*/]);
  48. /*
  49. ** RGBA pixel; memory layout must be the same as struct Imf::Rgba.
  50. */
  51. struct ImfRgba
  52. {
  53. ImfHalf r;
  54. ImfHalf g;
  55. ImfHalf b;
  56. ImfHalf a;
  57. };
  58. typedef struct ImfRgba ImfRgba;
  59. /*
  60. ** Magic number; this must be the same as Imf::MAGIC
  61. */
  62. #define IMF_MAGIC 20000630
  63. /*
  64. ** Version number; this must be the same as Imf::EXR_VERSION
  65. */
  66. #define IMF_VERSION_NUMBER 2
  67. /*
  68. ** Line order; values must the the same as in Imf::LineOrder.
  69. */
  70. #define IMF_INCREASING_Y 0
  71. #define IMF_DECREASING_Y 1
  72. #define IMF_RAMDOM_Y 2
  73. /*
  74. ** Compression types; values must be the same as in Imf::Compression.
  75. */
  76. #define IMF_NO_COMPRESSION 0
  77. #define IMF_RLE_COMPRESSION 1
  78. #define IMF_ZIPS_COMPRESSION 2
  79. #define IMF_ZIP_COMPRESSION 3
  80. #define IMF_PIZ_COMPRESSION 4
  81. #define IMF_PXR24_COMPRESSION 5
  82. #define IMF_B44_COMPRESSION 6
  83. #define IMF_B44A_COMPRESSION 7
  84. /*
  85. ** Channels; values must be the same as in Imf::RgbaChannels.
  86. */
  87. #define IMF_WRITE_R 0x01
  88. #define IMF_WRITE_G 0x02
  89. #define IMF_WRITE_B 0x04
  90. #define IMF_WRITE_A 0x08
  91. #define IMF_WRITE_Y 0x10
  92. #define IMF_WRITE_C 0x20
  93. #define IMF_WRITE_RGB 0x07
  94. #define IMF_WRITE_RGBA 0x0f
  95. #define IMF_WRITE_YC 0x30
  96. #define IMF_WRITE_YA 0x18
  97. #define IMF_WRITE_YCA 0x38
  98. /*
  99. ** Level modes; values must be the same as in Imf::LevelMode
  100. */
  101. #define IMF_ONE_LEVEL 0
  102. #define IMF_MIPMAP_LEVELS 1
  103. #define IMF_RIPMAP_LEVELS 2
  104. /*
  105. ** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
  106. */
  107. #define IMF_ROUND_DOWN 0
  108. #define IMF_ROUND_UP 1
  109. /*
  110. ** RGBA file header
  111. */
  112. struct ImfHeader;
  113. typedef struct ImfHeader ImfHeader;
  114. ImfHeader * ImfNewHeader (void);
  115. void ImfDeleteHeader (ImfHeader *hdr);
  116. ImfHeader * ImfCopyHeader (const ImfHeader *hdr);
  117. void ImfHeaderSetDisplayWindow (ImfHeader *hdr,
  118. int xMin, int yMin,
  119. int xMax, int yMax);
  120. void ImfHeaderDisplayWindow (const ImfHeader *hdr,
  121. int *xMin, int *yMin,
  122. int *xMax, int *yMax);
  123. void ImfHeaderSetDataWindow (ImfHeader *hdr,
  124. int xMin, int yMin,
  125. int xMax, int yMax);
  126. void ImfHeaderDataWindow (const ImfHeader *hdr,
  127. int *xMin, int *yMin,
  128. int *xMax, int *yMax);
  129. void ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,
  130. float pixelAspectRatio);
  131. float ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
  132. void ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,
  133. float x, float y);
  134. void ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
  135. float *x, float *y);
  136. void ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,
  137. float width);
  138. float ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
  139. void ImfHeaderSetLineOrder (ImfHeader *hdr,
  140. int lineOrder);
  141. int ImfHeaderLineOrder (const ImfHeader *hdr);
  142. void ImfHeaderSetCompression (ImfHeader *hdr,
  143. int compression);
  144. int ImfHeaderCompression (const ImfHeader *hdr);
  145. int ImfHeaderSetIntAttribute (ImfHeader *hdr,
  146. const char name[],
  147. int value);
  148. int ImfHeaderIntAttribute (const ImfHeader *hdr,
  149. const char name[],
  150. int *value);
  151. int ImfHeaderSetFloatAttribute (ImfHeader *hdr,
  152. const char name[],
  153. float value);
  154. int ImfHeaderSetDoubleAttribute (ImfHeader *hdr,
  155. const char name[],
  156. double value);
  157. int ImfHeaderFloatAttribute (const ImfHeader *hdr,
  158. const char name[],
  159. float *value);
  160. int ImfHeaderDoubleAttribute (const ImfHeader *hdr,
  161. const char name[],
  162. double *value);
  163. int ImfHeaderSetStringAttribute (ImfHeader *hdr,
  164. const char name[],
  165. const char value[]);
  166. int ImfHeaderStringAttribute (const ImfHeader *hdr,
  167. const char name[],
  168. const char **value);
  169. int ImfHeaderSetBox2iAttribute (ImfHeader *hdr,
  170. const char name[],
  171. int xMin, int yMin,
  172. int xMax, int yMax);
  173. int ImfHeaderBox2iAttribute (const ImfHeader *hdr,
  174. const char name[],
  175. int *xMin, int *yMin,
  176. int *xMax, int *yMax);
  177. int ImfHeaderSetBox2fAttribute (ImfHeader *hdr,
  178. const char name[],
  179. float xMin, float yMin,
  180. float xMax, float yMax);
  181. int ImfHeaderBox2fAttribute (const ImfHeader *hdr,
  182. const char name[],
  183. float *xMin, float *yMin,
  184. float *xMax, float *yMax);
  185. int ImfHeaderSetV2iAttribute (ImfHeader *hdr,
  186. const char name[],
  187. int x, int y);
  188. int ImfHeaderV2iAttribute (const ImfHeader *hdr,
  189. const char name[],
  190. int *x, int *y);
  191. int ImfHeaderSetV2fAttribute (ImfHeader *hdr,
  192. const char name[],
  193. float x, float y);
  194. int ImfHeaderV2fAttribute (const ImfHeader *hdr,
  195. const char name[],
  196. float *x, float *y);
  197. int ImfHeaderSetV3iAttribute (ImfHeader *hdr,
  198. const char name[],
  199. int x, int y, int z);
  200. int ImfHeaderV3iAttribute (const ImfHeader *hdr,
  201. const char name[],
  202. int *x, int *y, int *z);
  203. int ImfHeaderSetV3fAttribute (ImfHeader *hdr,
  204. const char name[],
  205. float x, float y, float z);
  206. int ImfHeaderV3fAttribute (const ImfHeader *hdr,
  207. const char name[],
  208. float *x, float *y, float *z);
  209. int ImfHeaderSetM33fAttribute (ImfHeader *hdr,
  210. const char name[],
  211. const float m[3][3]);
  212. int ImfHeaderM33fAttribute (const ImfHeader *hdr,
  213. const char name[],
  214. float m[3][3]);
  215. int ImfHeaderSetM44fAttribute (ImfHeader *hdr,
  216. const char name[],
  217. const float m[4][4]);
  218. int ImfHeaderM44fAttribute (const ImfHeader *hdr,
  219. const char name[],
  220. float m[4][4]);
  221. /*
  222. ** RGBA output file
  223. */
  224. struct ImfOutputFile;
  225. typedef struct ImfOutputFile ImfOutputFile;
  226. ImfOutputFile * ImfOpenOutputFile (const char name[],
  227. const ImfHeader *hdr,
  228. int channels);
  229. int ImfCloseOutputFile (ImfOutputFile *out);
  230. int ImfOutputSetFrameBuffer (ImfOutputFile *out,
  231. const ImfRgba *base,
  232. size_t xStride,
  233. size_t yStride);
  234. int ImfOutputWritePixels (ImfOutputFile *out,
  235. int numScanLines);
  236. int ImfOutputCurrentScanLine (const ImfOutputFile *out);
  237. const ImfHeader * ImfOutputHeader (const ImfOutputFile *out);
  238. int ImfOutputChannels (const ImfOutputFile *out);
  239. /*
  240. ** Tiled RGBA output file
  241. */
  242. struct ImfTiledOutputFile;
  243. typedef struct ImfTiledOutputFile ImfTiledOutputFile;
  244. ImfTiledOutputFile * ImfOpenTiledOutputFile (const char name[],
  245. const ImfHeader *hdr,
  246. int channels,
  247. int xSize, int ySize,
  248. int mode, int rmode);
  249. int ImfCloseTiledOutputFile (ImfTiledOutputFile *out);
  250. int ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,
  251. const ImfRgba *base,
  252. size_t xStride,
  253. size_t yStride);
  254. int ImfTiledOutputWriteTile (ImfTiledOutputFile *out,
  255. int dx, int dy,
  256. int lx, int ly);
  257. int ImfTiledOutputWriteTiles (ImfTiledOutputFile *out,
  258. int dxMin, int dxMax,
  259. int dyMin, int dyMax,
  260. int lx, int ly);
  261. const ImfHeader * ImfTiledOutputHeader (const ImfTiledOutputFile *out);
  262. int ImfTiledOutputChannels (const ImfTiledOutputFile *out);
  263. int ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);
  264. int ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);
  265. int ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);
  266. int ImfTiledOutputLevelRoundingMode
  267. (const ImfTiledOutputFile *out);
  268. /*
  269. ** RGBA input file
  270. */
  271. struct ImfInputFile;
  272. typedef struct ImfInputFile ImfInputFile;
  273. ImfInputFile * ImfOpenInputFile (const char name[]);
  274. int ImfCloseInputFile (ImfInputFile *in);
  275. int ImfInputSetFrameBuffer (ImfInputFile *in,
  276. ImfRgba *base,
  277. size_t xStride,
  278. size_t yStride);
  279. int ImfInputReadPixels (ImfInputFile *in,
  280. int scanLine1,
  281. int scanLine2);
  282. const ImfHeader * ImfInputHeader (const ImfInputFile *in);
  283. int ImfInputChannels (const ImfInputFile *in);
  284. const char * ImfInputFileName (const ImfInputFile *in);
  285. /*
  286. ** Tiled RGBA input file
  287. */
  288. struct ImfTiledInputFile;
  289. typedef struct ImfTiledInputFile ImfTiledInputFile;
  290. ImfTiledInputFile * ImfOpenTiledInputFile (const char name[]);
  291. int ImfCloseTiledInputFile (ImfTiledInputFile *in);
  292. int ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,
  293. ImfRgba *base,
  294. size_t xStride,
  295. size_t yStride);
  296. int ImfTiledInputReadTile (ImfTiledInputFile *in,
  297. int dx, int dy,
  298. int lx, int ly);
  299. int ImfTiledInputReadTiles (ImfTiledInputFile *in,
  300. int dxMin, int dxMax,
  301. int dyMin, int dyMax,
  302. int lx, int ly);
  303. const ImfHeader * ImfTiledInputHeader (const ImfTiledInputFile *in);
  304. int ImfTiledInputChannels (const ImfTiledInputFile *in);
  305. const char * ImfTiledInputFileName (const ImfTiledInputFile *in);
  306. int ImfTiledInputTileXSize (const ImfTiledInputFile *in);
  307. int ImfTiledInputTileYSize (const ImfTiledInputFile *in);
  308. int ImfTiledInputLevelMode (const ImfTiledInputFile *in);
  309. int ImfTiledInputLevelRoundingMode
  310. (const ImfTiledInputFile *in);
  311. /*
  312. ** Lookup tables
  313. */
  314. struct ImfLut;
  315. typedef struct ImfLut ImfLut;
  316. ImfLut * ImfNewRound12logLut (int channels);
  317. ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels);
  318. void ImfDeleteLut (ImfLut *lut);
  319. void ImfApplyLut (ImfLut *lut,
  320. ImfRgba *data,
  321. int nData,
  322. int stride);
  323. /*
  324. ** Most recent error message
  325. */
  326. const char * ImfErrorMessage (void);
  327. #ifdef __cplusplus
  328. } /* extern "C" */
  329. #endif
  330. #endif