1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef INCLUDED_IMF_DEEP_IMAGE_IO_H
7 #define INCLUDED_IMF_DEEP_IMAGE_IO_H
8 
9 //----------------------------------------------------------------------------
10 //
11 //      Functions to load deep images from OpenEXR files
12 //      and to save deep images in OpenEXR files.
13 //
14 //----------------------------------------------------------------------------
15 
16 #include "ImfUtilExport.h"
17 #include "ImfNamespace.h"
18 
19 #include "ImfDeepImage.h"
20 #include "ImfImageDataWindow.h"
21 
22 OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
23 
24 
25 //
26 // saveDeepImage (n, h, i,d) or
27 // saveDeepImage (n, i)
28 //
29 //      Saves image i in an OpenEXR file with name n.  The file will be
30 //      tiled if the image has more than one level, or if a header, h, is
31 //      given and contains a tile description attribute; otherwise the
32 //      file will be scan-line based.
33 //
34 //      If header h is given, then the channel list in h is replaced with
35 //      the channel list in i, and the levelMode and the levelRounding mode
36 //      fields of the tile description are replaced with the level mode
37 //      and the levelRounding mode of i.  In addition, if the data window
38 //      source flag, d, is set to USE_IMAGE_DATA_WINDOW, then the data
39 //      window in the image is copied into the header; if d is set to
40 //      USE_HEADER_DATA_WINDOW, then the data window in the header is
41 //      replaced with the intersection of the original data window in the
42 //      header and the data window in the image.  The modified header then
43 //      becomes the header of the image file.
44 //
45 
46 IMFUTIL_EXPORT
47 void
48 saveDeepImage
49     (const std::string &fileName,
50      const Header &hdr,
51      const DeepImage &img,
52      DataWindowSource dws = USE_IMAGE_DATA_WINDOW);
53 
54 IMFUTIL_EXPORT
55 void
56 saveDeepImage
57     (const std::string &fileName,
58      const DeepImage &img);
59 
60 //
61 // loadDeepImage (n, h, i) or
62 // loadDeepImage (n, i)
63 //
64 //      Loads deep image i from the OpenEXR file with name n.
65 //
66 //      If header h is given, then the header of the file is copied into h.
67 //
68 
69 IMFUTIL_EXPORT
70 void
71 loadDeepImage
72     (const std::string &fileName,
73      Header &hdr,
74      DeepImage &img);
75 
76 
77 IMFUTIL_EXPORT
78 void
79 loadDeepImage
80     (const std::string &fileName,
81      DeepImage &img);
82 
83 
84 //
85 // saveDeepScanLineImage (n, h, i, d) or
86 // saveDeepScanLineImage (n, i)
87 //
88 //      Saves image i in a scan-line based deep OpenEXR file with file name n.
89 //
90 //      If header h is given, then the channel list in h is replaced with
91 //      the channel list in i.  In addition, if the data window source flag, d,
92 //      is set to USE_IMAGE_DATA_WINDOW, then the data window in the image is
93 //      copied into the header; if d is set to USE_HEADER_DATA_WINDOW, then
94 //      the data window in the header is replaced with the intersection of
95 //      the original data window in the header and the data window in the
96 //      image.  The modified header then becomes the header of the image file.
97 //
98 
99 IMFUTIL_EXPORT
100 void
101 saveDeepScanLineImage
102     (const std::string &fileName,
103      const Header &hdr,
104      const DeepImage &img,
105      DataWindowSource dws = USE_IMAGE_DATA_WINDOW);
106 
107 IMFUTIL_EXPORT
108 void
109 saveDeepScanLineImage
110     (const std::string &fileName,
111      const DeepImage &img);
112 
113 
114 //
115 // loadDeepScanLineImage (n, h, i) or
116 // loadDeepScanLineImage (n, i)
117 //
118 //      Loads image i from a scan-line based deep OpenEXR file with file name n.
119 //      If header h is given, then the header of the file is copied into h.
120 //
121 
122 IMFUTIL_EXPORT
123 void
124 loadDeepScanLineImage
125     (const std::string &fileName,
126      Header &hdr,
127      DeepImage &img);
128 
129 IMFUTIL_EXPORT
130 void
131 loadDeepScanLineImage
132     (const std::string &fileName,
133      DeepImage &img);
134 
135 //
136 // saveDeepTiledImage (n, h, i, d) or
137 // saveDeepTiledImage (n, i)
138 //
139 //      Saves image i in a tiled deep OpenEXR file with file name n.
140 //
141 //      If header h is given, then the channel list in h is replaced with
142 //      the channel list i, and the levelMode and the levelRounding mode
143 //      fields of the tile description are replaced with the level mode
144 //      and the levelRounding mode of i.  In addition, if the data window
145 //      source flag, d, is set to USE_IMAGE_DATA_WINDOW, then the data
146 //      window in the image is copied into the header; if d is set to
147 //      USE_HEADER_DATA_WINDOW, then the data window in the header is
148 //      replaced with the intersection of the original data window in the
149 //      header and the data window in the image.  The modified header then
150 //      becomes the header of the image file.
151 //
152 //      Note: USE_HEADER_DATA_WINDOW can only be used for images with
153 //      level mode ONE_LEVEL.
154 //
155 
156 IMFUTIL_EXPORT
157 void
158 saveDeepTiledImage
159     (const std::string &fileName,
160      const Header &hdr,
161      const DeepImage &img,
162      DataWindowSource dws = USE_IMAGE_DATA_WINDOW);
163 
164 IMFUTIL_EXPORT
165 void
166 saveDeepTiledImage
167     (const std::string &fileName,
168      const DeepImage &img);
169 
170 //
171 // loadDeepTiledImage (n, h, i) or
172 // loadDeepTiledImage (n, i)
173 //
174 //      Loads image i from a tiled deep OpenEXR file with file name n.
175 //      If header h is given, then the header of the file is copied into h.
176 //
177 
178 IMFUTIL_EXPORT
179 void
180 loadDeepTiledImage
181     (const std::string &fileName,
182      Header &hdr,
183      DeepImage &img);
184 
185 IMFUTIL_EXPORT
186 void
187 loadDeepTiledImage
188     (const std::string &fileName,
189      DeepImage &img);
190 
191 OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
192 
193 #endif
194