ome-files 0.1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

OMETIFFWriter.h
1 /*
2 * #%L
3 * OME-FILES C++ library for image IO.
4 * Copyright © 2006 - 2014 Open Microscopy Environment:
5 * - Massachusetts Institute of Technology
6 * - National Institutes of Health
7 * - University of Dundee
8 * - Board of Regents of the University of Wisconsin-Madison
9 * - Glencoe Software, Inc.
10 * %%
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * The views and conclusions contained in the software and documentation are
33 * those of the authors and should not be interpreted as representing official
34 * policies, either expressed or implied, of any organization.
35 * #L%
36 */
37
38 #ifndef OME_FILES_OUT_OMETIFFWRITER_H
39 #define OME_FILES_OUT_OMETIFFWRITER_H
40
41 #include <ome/files/detail/FormatWriter.h>
42 #include <ome/files/detail/OMETIFF.h>
43
44 #include <ome/common/filesystem.h>
45 #include <ome/common/log.h>
46
47 #include <ome/xml/meta/OMEXMLMetadata.h>
48
49 namespace ome
50 {
51 namespace files
52 {
53 namespace tiff
54 {
55
56 class TIFF;
57 class IFD;
58
59 }
60
61 namespace out
62 {
63
67 class OMETIFFWriter : public ::ome::files::detail::FormatWriter
68 {
69 protected:
71 ome::common::Logger logger;
72
74 typedef std::map<boost::filesystem::path, std::string> file_uuid_map;
75
76 // In the Java reader, this is uuids + ifdCounts
78 struct TIFFState
79 {
81 std::string uuid;
83 ome::compat::shared_ptr<ome::files::tiff::TIFF> tiff;
85 dimension_size_type ifdCount;
86
92 TIFFState(ome::compat::shared_ptr<ome::files::tiff::TIFF>& tiff);
93
95 ~TIFFState();
96 };
97
99 typedef std::map<boost::filesystem::path, TIFFState> tiff_map;
100
101 // In the Java reader, this is imageLocations.
103 struct SeriesState
104 {
106 std::vector<detail::OMETIFFPlane> planes;
107 };
108
110 typedef std::vector<SeriesState> series_list;
111
113 boost::filesystem::path baseDir;
114
116 file_uuid_map files;
117
118 // Mutable to allow opening TIFFs when const.
120 mutable tiff_map tiffs;
121
123 tiff_map::iterator currentTIFF;
124
126 std::string flags;
127
129 series_list seriesState;
130
140 ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve> originalMetadataRetrieve;
141
143 ome::compat::shared_ptr<ome::xml::meta::OMEXMLMetadata> omeMeta;
144
145 private:
147 boost::optional<bool> bigTIFF;
148
149 public:
151 OMETIFFWriter();
152
154 virtual
155 ~OMETIFFWriter();
156
157 // Documented in superclass.
158 void
159 setId(const boost::filesystem::path& id);
160
161 // Documented in superclass.
162 void
163 close(bool fileOnly = false);
164
165 using FormatWriter::saveBytes;
166
167 // Documented in superclass.
168 void
169 setSeries(dimension_size_type series) const;
170
171 // Documented in superclass.
172 void
173 setPlane(dimension_size_type plane) const;
174
175 protected:
177 void
178 nextIFD() const;
179
181 void
182 setupIFD() const;
183
184 public:
185 // Documented in superclass.
186 void
187 saveBytes(dimension_size_type plane,
188 VariantPixelBuffer& buf,
189 dimension_size_type x,
190 dimension_size_type y,
191 dimension_size_type w,
192 dimension_size_type h);
193
194 private:
200 void
201 fillMetadata();
202
209 std::string
210 getOMEXML(const boost::filesystem::path& id);
211
218 void
219 saveComment(const boost::filesystem::path& id,
220 const std::string& xml);
221
222 // Java getUUID unimplemented; see uuid member of TIFFState.
223
224 // Java planeCount() unimplemented; use getImageCount()
225 // instead. Note the java implementation special-cases
226 // certain behaviour such as interleaving for certain pixel
227 // types; here the caller can specify exactly what they want.
228
229 public:
233 void
234 setBigTIFF(boost::optional<bool> big = true);
235
239 boost::optional<bool>
240 getBigTIFF() const;
241 };
242
243 }
244 }
245 }
246
247 #endif // OME_FILES_OUT_OMETIFFWRITER_H
248
249 /*
250 * Local Variables:
251 * mode:C++
252 * End:
253 */
ome::files::out::OMETIFFWriter::close
void close(bool fileOnly=false)
Close the currently open file.
Definition: OMETIFFWriter.cpp:542
ome::files::out::OMETIFFWriter::saveBytes
void saveBytes(dimension_size_type plane, VariantPixelBuffer &buf, dimension_size_type x, dimension_size_type y, dimension_size_type w, dimension_size_type h)
Save an image plane.
Definition: OMETIFFWriter.cpp:673
ome::files::out::OMETIFFWriter::setupIFD
void setupIFD() const
Set IFD parameters for the current series.
Definition: OMETIFFWriter.cpp:633
ome::files::out::OMETIFFWriter::baseDir
boost::filesystem::path baseDir
Base path for computing relative paths in the OME-XML.
Definition: OMETIFFWriter.h:113
ome::common::Logger
logging::sources::severity_logger_mt< logging::trivial::severity_level > Logger
ome::files::out::OMETIFFWriter::~OMETIFFWriter
virtual ~OMETIFFWriter()
Destructor.
Definition: OMETIFFWriter.cpp:434
ome::files::out::OMETIFFWriter::TIFFState::ifdCount
dimension_size_type ifdCount
Number of IFDs written.
Definition: OMETIFFWriter.h:85
ome::files::out::OMETIFFWriter::seriesState
series_list seriesState
State of each series.
Definition: OMETIFFWriter.h:129
ome::files::out::OMETIFFWriter::omeMeta
ome::compat::shared_ptr< ome::xml::meta::OMEXMLMetadata > omeMeta
OME-XML metadata for embedding in the TIFF.
Definition: OMETIFFWriter.h:143
ome::files::dimension_size_type
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
ome::files::out::OMETIFFWriter::TIFFState::tiff
ome::compat::shared_ptr< ome::files::tiff::TIFF > tiff
TIFF file handle.
Definition: OMETIFFWriter.h:83
ome::files::out::OMETIFFWriter::tiff_map
std::map< boost::filesystem::path, TIFFState > tiff_map
Map filename to TIFF state.
Definition: OMETIFFWriter.h:99
ome::files::out::OMETIFFWriter::logger
ome::common::Logger logger
Message logger.
Definition: OMETIFFWriter.h:71
ome::files::out::OMETIFFWriter::getBigTIFF
boost::optional< bool > getBigTIFF() const
Query use of BigTIFF support.
Definition: OMETIFFWriter.cpp:910
ome::files::FormatWriter::saveBytes
virtual void saveBytes(dimension_size_type plane, VariantPixelBuffer &buf)=0
Save an image plane.
ome::files::out::OMETIFFWriter::file_uuid_map
std::map< boost::filesystem::path, std::string > file_uuid_map
Map filename to UUID.
Definition: OMETIFFWriter.h:74
ome::files::out::OMETIFFWriter::tiffs
tiff_map tiffs
Open TIFF files.
Definition: OMETIFFWriter.h:120
ome::files::out::OMETIFFWriter::flags
std::string flags
TIFF flags.
Definition: OMETIFFWriter.h:126
ome::files::out::OMETIFFWriter::OMETIFFWriter
OMETIFFWriter()
Constructor.
Definition: OMETIFFWriter.cpp:420
ome::files::out::OMETIFFWriter::setPlane
void setPlane(dimension_size_type plane) const
Set the active plane.
Definition: OMETIFFWriter.cpp:613
ome::files::detail::FormatWriter
Interface for all biological file format writers (default behaviour).
Definition: FormatWriter.h:108
ome::files::detail::FormatWriter::series
dimension_size_type series
Current series.
Definition: FormatWriter.h:122
filesystem.h
ome::files::out::OMETIFFWriter::setSeries
void setSeries(dimension_size_type series) const
Set the active series.
Definition: OMETIFFWriter.cpp:600
ome
ome::files::out::OMETIFFWriter::originalMetadataRetrieve
ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve > originalMetadataRetrieve
Original MetadataRetrieve.
Definition: OMETIFFWriter.h:140
ome::files::out::OMETIFFWriter::files
file_uuid_map files
UUID to filename mapping.
Definition: OMETIFFWriter.h:116
ome::files::out::OMETIFFWriter::nextIFD
void nextIFD() const
Flush current IFD and create new IFD.
Definition: OMETIFFWriter.cpp:626
ome::files::out::OMETIFFWriter::SeriesState
Current state of an image series.
Definition: OMETIFFWriter.h:103
ome::files::out::OMETIFFWriter::getOMEXML
std::string getOMEXML(const boost::filesystem::path &id)
Get OME-XML for embedding into the specified TIFF file.
Definition: OMETIFFWriter.cpp:775
ome::files::out::OMETIFFWriter
TIFF writer with support for OME-XML metadata.
Definition: OMETIFFWriter.h:67
ome::files::out::OMETIFFWriter::TIFFState::uuid
std::string uuid
UUID of file.
Definition: OMETIFFWriter.h:81
ome::files::out::OMETIFFWriter::TIFFState
State of TIFF file.
Definition: OMETIFFWriter.h:78
ome::files::out::OMETIFFWriter::setBigTIFF
void setBigTIFF(boost::optional< bool > big=true)
Set use of BigTIFF support.
Definition: OMETIFFWriter.cpp:904
ome::files::detail::FormatWriter::plane
dimension_size_type plane
Current plane.
Definition: FormatWriter.h:125
ome::files::out::OMETIFFWriter::saveComment
void saveComment(const boost::filesystem::path &id, const std::string &xml)
Save OME-XML text in the first IFD of the specified TIFF file.
Definition: OMETIFFWriter.cpp:796
ome::files::out::OMETIFFWriter::SeriesState::planes
std::vector< detail::OMETIFFPlane > planes
Current state of each plane in an image series.
Definition: OMETIFFWriter.h:106
ome::files::out::OMETIFFWriter::fillMetadata
void fillMetadata()
Fill MetadataStore with cached metadata.
Definition: OMETIFFWriter.cpp:700
ome::files::out::OMETIFFWriter::setId
void setId(const boost::filesystem::path &id)
Set the current file name.
Definition: OMETIFFWriter.cpp:446
ome::files::out::OMETIFFWriter::TIFFState::~TIFFState
~TIFFState()
Destructor.
Definition: OMETIFFWriter.cpp:416
log.h
ome::files::out::OMETIFFWriter::TIFFState::TIFFState
TIFFState(ome::compat::shared_ptr< ome::files::tiff::TIFF > &tiff)
Constructor.
Definition: OMETIFFWriter.cpp:409
ome::files::VariantPixelBuffer
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
ome::files::out::OMETIFFWriter::currentTIFF
tiff_map::iterator currentTIFF
Current TIFF file.
Definition: OMETIFFWriter.h:123
ome::files::out::OMETIFFWriter::series_list
std::vector< SeriesState > series_list
Vector of SeriesState objects.
Definition: OMETIFFWriter.h:110
ome::common::xml
ome::files::out::OMETIFFWriter::bigTIFF
boost::optional< bool > bigTIFF
Write a Big TIFF.
Definition: OMETIFFWriter.h:147