ome-files 0.2.2

IFD.h
1 /*
2 * #%L
3 * OME-FILES C++ library for image IO.
4 * Copyright © 2006 - 2015 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_TIFF_IFD_H
39 #define OME_FILES_TIFF_IFD_H
40
41 #include <string>
42
43 #include <ome/compat/memory.h>
44
45 #include <ome/files/CoreMetadata.h>
46 #include <ome/files/TileCoverage.h>
47 #include <ome/files/tiff/TileInfo.h>
48 #include <ome/files/tiff/Types.h>
49 #include <ome/files/VariantPixelBuffer.h>
50
51 #include <ome/xml/model/enums/PixelType.h>
52
53 namespace ome
54 {
55 namespace files
56 {
57 namespace tiff
58 {
59
60 class TIFF;
61
63 template<typename Tag>
64 class Field;
65
71 class IFD : public ome::compat::enable_shared_from_this<IFD>
72 {
73 private:
74 class Impl;
76 ome::compat::shared_ptr<Impl> impl;
77
78 protected:
80 IFD(ome::compat::shared_ptr<TIFF>& tiff,
81 offset_type offset);
82
84 IFD(ome::compat::shared_ptr<TIFF>& tiff);
85
86 private:
88 IFD (const IFD&);
89
91 IFD&
92 operator= (const IFD&);
93
94 public:
96 virtual ~IFD();
97
105 static ome::compat::shared_ptr<IFD>
106 openIndex(ome::compat::shared_ptr<TIFF>& tiff,
107 directory_index_type index);
108
116 static ome::compat::shared_ptr<IFD>
117 openOffset(ome::compat::shared_ptr<TIFF>& tiff,
118 offset_type offset);
119
126 static ome::compat::shared_ptr<IFD>
127 current(ome::compat::shared_ptr<TIFF>& tiff);
128
134 ome::compat::shared_ptr<TIFF>&
135 getTIFF() const;
136
142 void
143 makeCurrent() const;
144
152 offset_type
153 getOffset() const;
154
165 void
166 getRawField(tag_type tag,
167 ...) const;
168
180 void
181 getRawFieldDefaulted(tag_type tag,
182 ...) const;
183
194 void
195 setRawField(tag_type tag,
196 ...);
197
204 template<typename TagCategory>
205 Field<TagCategory>
206 getField(TagCategory tag)
207 {
208 return Field<TagCategory>(this->shared_from_this(), tag);
209 }
210
217 template<typename TagCategory>
218 const Field<TagCategory>
219 getField(TagCategory tag) const
220 {
221 return Field<TagCategory>(const_cast<IFD *>(this)->shared_from_this(), tag);
222 }
223
229 TileType
230 getTileType() const;
231
237 void
238 setTileType(TileType type);
239
247 dimension_size_type
248 getCurrentTile() const;
249
261 void
262 setCurrentTile(dimension_size_type tile);
263
270 TileInfo
271 getTileInfo();
272
279 const TileInfo
280 getTileInfo() const;
281
287 std::vector<TileCoverage>&
288 getTileCoverage();
289
295 const std::vector<TileCoverage>&
296 getTileCoverage() const;
297
303 uint32_t
304 getImageWidth() const;
305
311 void
312 setImageWidth(uint32_t width);
313
319 uint32_t
320 getImageHeight() const;
321
327 void
328 setImageHeight(uint32_t height);
329
335 uint32_t
336 getTileWidth() const;
337
343 void
344 setTileWidth(uint32_t width);
345
351 uint32_t
352 getTileHeight() const;
353
359 void
360 setTileHeight(uint32_t height);
361
372 ::ome::xml::model::enums::PixelType
373 getPixelType() const;
374
384 void
385 setPixelType(::ome::xml::model::enums::PixelType type);
386
392 uint16_t
393 getBitsPerSample() const;
394
400 void
401 setBitsPerSample(uint16_t samples);
402
408 uint16_t
409 getSamplesPerPixel() const;
410
416 void
417 setSamplesPerPixel(uint16_t samples);
418
424 PlanarConfiguration
425 getPlanarConfiguration() const;
426
432 void
433 setPlanarConfiguration(PlanarConfiguration planarconfig);
434
440 PhotometricInterpretation
441 getPhotometricInterpretation() const;
442
448 void
449 setPhotometricInterpretation(PhotometricInterpretation photometric);
450
456 void
457 readImage(VariantPixelBuffer& buf) const;
458
463 void
464 readImage(VariantPixelBuffer& buf,
465 dimension_size_type subC) const;
466
481 void
482 readImage(VariantPixelBuffer& dest,
483 dimension_size_type x,
484 dimension_size_type y,
485 dimension_size_type w,
486 dimension_size_type h) const;
487
492 void
493 readImage(VariantPixelBuffer& dest,
494 dimension_size_type x,
495 dimension_size_type y,
496 dimension_size_type w,
497 dimension_size_type h,
498 dimension_size_type subC) const;
499
505 void
506 readLookupTable(VariantPixelBuffer& buf) const;
507
513 void
514 writeImage(const VariantPixelBuffer& buf);
515
520 void
521 writeImage(const VariantPixelBuffer& buf,
522 dimension_size_type subC);
523
537 void
538 writeImage(const VariantPixelBuffer& source,
539 dimension_size_type x,
540 dimension_size_type y,
541 dimension_size_type w,
542 dimension_size_type h);
543
548 void
549 writeImage(const VariantPixelBuffer& source,
550 dimension_size_type x,
551 dimension_size_type y,
552 dimension_size_type w,
553 dimension_size_type h,
554 dimension_size_type subC);
555
561 ome::compat::shared_ptr<IFD>
562 next() const;
563
569 bool
570 last() const;
571 };
572
573 }
574 }
575 }
576
577 #endif // OME_FILES_TIFF_IFD_H
578
579 /*
580 * Local Variables:
581 * mode:C++
582 * End:
583 */
ome::files::tiff::TileType
TileType
Type of tile.
Definition: Types.h:217
ome::files::tiff::IFD::setPlanarConfiguration
void setPlanarConfiguration(PlanarConfiguration planarconfig)
Set planar configuration.
Definition: IFD.cpp:1178
ome::files::tiff::IFD::setTileHeight
void setTileHeight(uint32_t height)
Set the tile height.
Definition: IFD.cpp:967
ome::files::tiff::IFD::setSamplesPerPixel
void setSamplesPerPixel(uint16_t samples)
Set samples per pixel.
Definition: IFD.cpp:1159
ome::files::tiff::IFD::IFD
IFD(ome::compat::shared_ptr< TIFF > &tiff, offset_type offset)
Constructor (not public).
Definition: IFD.cpp:648
ome::files::tiff::IFD::getTIFF
ome::compat::shared_ptr< TIFF > & getTIFF() const
Get the source TIFF this descriptor belongs to.
Definition: IFD.cpp:716
ome::files::dimension_size_type
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
ome::files::tiff::IFD::getTileWidth
uint32_t getTileWidth() const
Get the tile width.
Definition: IFD.cpp:913
ome::files::tiff::IFD::setCurrentTile
void setCurrentTile(dimension_size_type tile)
Set the current tile being written.
Definition: IFD.cpp:845
ome::files::tiff::TileInfo
Tile information for an IFD.
Definition: TileInfo.h:61
ome::files::tiff::IFD::setPixelType
void setPixelType(::ome::xml::model::enums::PixelType type)
Set the OME data model PixelType.
Definition: IFD.cpp:1081
ome::files::tiff::PlanarConfiguration
PlanarConfiguration
Planar configuration of samples.
Definition: Types.h:176
ome::files::tiff::IFD::getRawField
void getRawField(tag_type tag,...) const
Get a field by its tag number.
Definition: IFD.cpp:728
ome::files::tiff::IFD::setPhotometricInterpretation
void setPhotometricInterpretation(PhotometricInterpretation photometric)
Set photometric interpretation.
Definition: IFD.cpp:1197
ome::files::tiff::tag_type
unsigned int tag_type
Tag number.
Definition: Types.h:68
ome::files::tiff::IFD::openOffset
static ome::compat::shared_ptr< IFD > openOffset(ome::compat::shared_ptr< TIFF > &tiff, offset_type offset)
Open an IFD.
Definition: IFD.cpp:684
ome::files::tiff::IFD::makeCurrent
void makeCurrent() const
Make this IFD the current directory.
Definition: IFD.cpp:701
ome::files::tiff::IFD::getPhotometricInterpretation
PhotometricInterpretation getPhotometricInterpretation() const
Get photometric interpretation.
Definition: IFD.cpp:1185
ome::files::tiff::IFD::getPlanarConfiguration
PlanarConfiguration getPlanarConfiguration() const
Get planar configuration.
Definition: IFD.cpp:1166
ome::files::tiff::IFD::readLookupTable
void readLookupTable(VariantPixelBuffer &buf) const
Read a lookup table into a pixel buffer.
Definition: IFD.cpp:1271
ome::files::tiff::IFD::getTileHeight
uint32_t getTileHeight() const
Get the tile height.
Definition: IFD.cpp:946
ome::files::tiff::offset_type
uint64_t offset_type
IFD offset.
Definition: Types.h:65
ome::files::tiff::IFD::getSamplesPerPixel
uint16_t getSamplesPerPixel() const
Get samples per pixel.
Definition: IFD.cpp:1147
ome::files::tiff::IFD::getField
const Field< TagCategory > getField(TagCategory tag) const
Get a Field by its tag enumeration.
Definition: IFD.h:219
ome
Open Microscopy Environment C++.
ome::files::tiff::IFD::setTileType
void setTileType(TileType type)
Set the tile type.
Definition: IFD.cpp:833
ome::files::tiff::IFD::getTileCoverage
std::vector< TileCoverage > & getTileCoverage()
Get tile coverage cache.
Definition: IFD.cpp:863
ome::files::tiff::IFD::writeImage
void writeImage(const VariantPixelBuffer &buf)
Write a whole image plane from a pixel buffer.
Definition: IFD.cpp:1317
ome::files::tiff::IFD::~IFD
virtual ~IFD()
Destructor.
Definition: IFD.cpp:663
ome::files::tiff::IFD::setTileWidth
void setTileWidth(uint32_t width)
Set the tile width.
Definition: IFD.cpp:932
ome::files::tiff::IFD::setRawField
void setRawField(tag_type tag,...)
Set a field by its tag number.
Definition: IFD.cpp:786
ome::files::tiff::IFD::getImageHeight
uint32_t getImageHeight() const
Get the image height.
Definition: IFD.cpp:894
memory.h
ome::files::tiff::IFD::getOffset
offset_type getOffset() const
Get the directory offset.
Definition: IFD.cpp:722
ome::files::tiff::IFD::last
bool last() const
Check if this is the last directory.
Definition: IFD.cpp:1431
ome::files::tiff::IFD::readImage
void readImage(VariantPixelBuffer &buf) const
Read a whole image plane into a pixel buffer.
Definition: IFD.cpp:1204
ome::files::tiff::IFD::getTileType
TileType getTileType() const
Get the tile type.
Definition: IFD.cpp:811
ome::files::tiff::IFD::next
ome::compat::shared_ptr< IFD > next() const
Get next directory.
Definition: IFD.cpp:1410
ome::files::tiff::IFD::impl
ome::compat::shared_ptr< Impl > impl
Private implementation details.
Definition: IFD.h:74
ome::files::tiff::Field
Field representing a tag value.
Definition: Field.h:157
ome::xml::model::enums::PixelType
ome::files::tiff::IFD::setImageHeight
void setImageHeight(uint32_t height)
Set the image height.
Definition: IFD.cpp:906
ome::files::tiff::IFD::Impl
Internal implementation details of OffsetIFD.
Definition: IFD.cpp:577
ome::files::tiff::IFD::current
static ome::compat::shared_ptr< IFD > current(ome::compat::shared_ptr< TIFF > &tiff)
Get the current IFD.
Definition: IFD.cpp:693
ome::files::tiff::IFD::getPixelType
::ome::xml::model::enums::PixelType getPixelType() const
Get the OME data model PixelType.
Definition: IFD.cpp:981
ome::files::tiff::IFD::setImageWidth
void setImageWidth(uint32_t width)
Set the image width.
Definition: IFD.cpp:887
ome::files::tiff::IFD::setBitsPerSample
void setBitsPerSample(uint16_t samples)
Set bits per sample.
Definition: IFD.cpp:1136
ome::files::tiff::PhotometricInterpretation
PhotometricInterpretation
Photometric interpretation of pixel data.
Definition: Types.h:158
ome::files::tiff::IFD::getTileInfo
TileInfo getTileInfo()
Get tiling metadata.
Definition: IFD.cpp:851
ome::files::tiff::directory_index_type
uint16_t directory_index_type
IFD index.
Definition: Types.h:62
ome::files::tiff::IFD
Image File Directory (IFD).
Definition: IFD.h:71
ome::files::tiff::IFD::getBitsPerSample
uint16_t getBitsPerSample() const
Get bits per sample.
Definition: IFD.cpp:1124
ome::files::tiff::IFD::getRawFieldDefaulted
void getRawFieldDefaulted(tag_type tag,...) const
Get a field by its tag number, falling back to default if unset.
Definition: IFD.cpp:757
ome::files::tiff::IFD::getField
Field< TagCategory > getField(TagCategory tag)
Get a Field by its tag enumeration.
Definition: IFD.h:206
ome::files::tiff::IFD::openIndex
static ome::compat::shared_ptr< IFD > openIndex(ome::compat::shared_ptr< TIFF > &tiff, directory_index_type index)
Open an IFD by index.
Definition: IFD.cpp:668
ome::files::tiff::IFD::getCurrentTile
dimension_size_type getCurrentTile() const
Get the current tile being written.
Definition: IFD.cpp:839
ome::files::VariantPixelBuffer
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
ome::files::tiff::IFD::getImageWidth
uint32_t getImageWidth() const
Get the image width.
Definition: IFD.cpp:875
ome::files::tiff::IFD::operator=
IFD & operator=(const IFD &)
Assignment operator (deleted).