ome-files  0.3.0
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 <memory>
42 #include <string>
43 
44 #include <ome/files/CoreMetadata.h>
45 #include <ome/files/TileCoverage.h>
46 #include <ome/files/tiff/TileInfo.h>
47 #include <ome/files/tiff/Types.h>
48 #include <ome/files/VariantPixelBuffer.h>
49 
50 #include <ome/xml/model/enums/PixelType.h>
51 
52 namespace ome
53 {
54  namespace files
55  {
56  namespace tiff
57  {
58 
59  class TIFF;
60 
62  template<typename Tag>
63  class Field;
64 
70  class IFD : public std::enable_shared_from_this<IFD>
71  {
72  private:
73  class Impl;
75  std::shared_ptr<Impl> impl;
76 
77  protected:
79  IFD(std::shared_ptr<TIFF>& tiff,
80  offset_type offset);
81 
83  IFD(std::shared_ptr<TIFF>& tiff);
84 
85  private:
87  IFD (const IFD&);
88 
90  IFD&
91  operator= (const IFD&);
92 
93  public:
95  virtual ~IFD();
96 
106  static std::shared_ptr<IFD>
107  openIndex(std::shared_ptr<TIFF>& tiff,
108  directory_index_type index);
109 
117  static std::shared_ptr<IFD>
118  openOffset(std::shared_ptr<TIFF>& tiff,
119  offset_type offset);
120 
127  static std::shared_ptr<IFD>
128  current(std::shared_ptr<TIFF>& tiff);
129 
135  std::shared_ptr<TIFF>&
136  getTIFF() const;
137 
143  void
144  makeCurrent() const;
145 
154  getOffset() const;
155 
166  void
167  getRawField(tag_type tag,
168  ...) const;
169 
181  void
183  ...) const;
184 
195  void
196  setRawField(tag_type tag,
197  ...);
198 
205  template<typename TagCategory>
207  getField(TagCategory tag)
208  {
209  return Field<TagCategory>(this->shared_from_this(), tag);
210  }
211 
218  template<typename TagCategory>
219  const Field<TagCategory>
220  getField(TagCategory tag) const
221  {
222  return Field<TagCategory>(const_cast<IFD *>(this)->shared_from_this(), tag);
223  }
224 
230  TileType
231  getTileType() const;
232 
238  void
239  setTileType(TileType type);
240 
249  getCurrentTile() const;
250 
262  void
264 
271  TileInfo
272  getTileInfo();
273 
280  const TileInfo
281  getTileInfo() const;
282 
288  std::vector<TileCoverage>&
289  getTileCoverage();
290 
296  const std::vector<TileCoverage>&
297  getTileCoverage() const;
298 
304  uint32_t
305  getImageWidth() const;
306 
312  void
313  setImageWidth(uint32_t width);
314 
320  uint32_t
321  getImageHeight() const;
322 
328  void
329  setImageHeight(uint32_t height);
330 
336  uint32_t
337  getTileWidth() const;
338 
344  void
345  setTileWidth(uint32_t width);
346 
352  uint32_t
353  getTileHeight() const;
354 
360  void
361  setTileHeight(uint32_t height);
362 
374  getPixelType() const;
375 
385  void
387 
393  uint16_t
394  getBitsPerSample() const;
395 
401  void
402  setBitsPerSample(uint16_t samples);
403 
409  uint16_t
410  getSamplesPerPixel() const;
411 
417  void
418  setSamplesPerPixel(uint16_t samples);
419 
426  getPlanarConfiguration() const;
427 
433  void
435 
443 
449  void
451 
458  getCompression() const;
459 
465  void
466  setCompression(Compression compression);
467 
473  void
474  readImage(VariantPixelBuffer& buf) const;
475 
480  void
482  dimension_size_type subC) const;
483 
498  void
503  dimension_size_type h) const;
504 
509  void
515  dimension_size_type subC) const;
516 
522  void
524 
530  void
531  writeImage(const VariantPixelBuffer& buf);
532 
537  void
538  writeImage(const VariantPixelBuffer& buf,
539  dimension_size_type subC);
540 
554  void
555  writeImage(const VariantPixelBuffer& source,
560 
565  void
566  writeImage(const VariantPixelBuffer& source,
571  dimension_size_type subC);
572 
578  std::shared_ptr<IFD>
579  next() const;
580 
586  bool
587  last() const;
588  };
589 
590  }
591  }
592 }
593 
594 #endif // OME_FILES_TIFF_IFD_H
595 
596 /*
597  * Local Variables:
598  * mode:C++
599  * End:
600  */
TileType
Type of tile.
Definition: Types.h:217
void setPlanarConfiguration(PlanarConfiguration planarconfig)
Set planar configuration.
Definition: IFD.cpp:1176
void setTileHeight(uint32_t height)
Set the tile height.
Definition: IFD.cpp:965
void setSamplesPerPixel(uint16_t samples)
Set samples per pixel.
Definition: IFD.cpp:1157
static std::shared_ptr< IFD > openOffset(std::shared_ptr< TIFF > &tiff, offset_type offset)
Open an IFD.
Definition: IFD.cpp:682
std::shared_ptr< Impl > impl
Private implementation details.
Definition: IFD.h:73
void setCompression(Compression compression)
Set compression scheme.
Definition: IFD.cpp:1214
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:58
uint32_t getTileWidth() const
Get the tile width.
Definition: IFD.cpp:911
void setCurrentTile(dimension_size_type tile)
Set the current tile being written.
Definition: IFD.cpp:843
Tile information for an IFD.
Definition: TileInfo.h:61
void setPixelType(::ome::xml::model::enums::PixelType type)
Set the OME data model PixelType.
Definition: IFD.cpp:1079
PlanarConfiguration
Planar configuration of samples.
Definition: Types.h:176
void getRawField(tag_type tag,...) const
Get a field by its tag number.
Definition: IFD.cpp:726
void setPhotometricInterpretation(PhotometricInterpretation photometric)
Set photometric interpretation.
Definition: IFD.cpp:1195
unsigned int tag_type
Tag number.
Definition: Types.h:68
void makeCurrent() const
Make this IFD the current directory.
Definition: IFD.cpp:699
PhotometricInterpretation getPhotometricInterpretation() const
Get photometric interpretation.
Definition: IFD.cpp:1183
PlanarConfiguration getPlanarConfiguration() const
Get planar configuration.
Definition: IFD.cpp:1164
void readLookupTable(VariantPixelBuffer &buf) const
Read a lookup table into a pixel buffer.
Definition: IFD.cpp:1288
uint32_t getTileHeight() const
Get the tile height.
Definition: IFD.cpp:944
static std::shared_ptr< IFD > openIndex(std::shared_ptr< TIFF > &tiff, directory_index_type index)
Open an IFD by index.
Definition: IFD.cpp:666
Compression
Compression technique.
Definition: Types.h:93
static std::shared_ptr< IFD > current(std::shared_ptr< TIFF > &tiff)
Get the current IFD.
Definition: IFD.cpp:691
uint64_t offset_type
IFD offset.
Definition: Types.h:65
uint16_t getSamplesPerPixel() const
Get samples per pixel.
Definition: IFD.cpp:1145
const Field< TagCategory > getField(TagCategory tag) const
Get a Field by its tag enumeration.
Definition: IFD.h:220
std::shared_ptr< IFD > next() const
Get next directory.
Definition: IFD.cpp:1427
Open Microscopy Environment C++.
void setTileType(TileType type)
Set the tile type.
Definition: IFD.cpp:831
std::vector< TileCoverage > & getTileCoverage()
Get tile coverage cache.
Definition: IFD.cpp:861
void writeImage(const VariantPixelBuffer &buf)
Write a whole image plane from a pixel buffer.
Definition: IFD.cpp:1334
virtual ~IFD()
Destructor.
Definition: IFD.cpp:661
void setTileWidth(uint32_t width)
Set the tile width.
Definition: IFD.cpp:930
void setRawField(tag_type tag,...)
Set a field by its tag number.
Definition: IFD.cpp:784
uint32_t getImageHeight() const
Get the image height.
Definition: IFD.cpp:892
offset_type getOffset() const
Get the directory offset.
Definition: IFD.cpp:720
bool last() const
Check if this is the last directory.
Definition: IFD.cpp:1448
void readImage(VariantPixelBuffer &buf) const
Read a whole image plane into a pixel buffer.
Definition: IFD.cpp:1221
TileType getTileType() const
Get the tile type.
Definition: IFD.cpp:809
Field representing a tag value.
Definition: Field.h:156
void setImageHeight(uint32_t height)
Set the image height.
Definition: IFD.cpp:904
Internal implementation details of OffsetIFD.
Definition: IFD.cpp:573
::ome::xml::model::enums::PixelType getPixelType() const
Get the OME data model PixelType.
Definition: IFD.cpp:979
IFD(std::shared_ptr< TIFF > &tiff, offset_type offset)
Constructor (not public).
Definition: IFD.cpp:646
std::shared_ptr< TIFF > & getTIFF() const
Get the source TIFF this descriptor belongs to.
Definition: IFD.cpp:714
void setImageWidth(uint32_t width)
Set the image width.
Definition: IFD.cpp:885
void setBitsPerSample(uint16_t samples)
Set bits per sample.
Definition: IFD.cpp:1134
PhotometricInterpretation
Photometric interpretation of pixel data.
Definition: Types.h:158
TileInfo getTileInfo()
Get tiling metadata.
Definition: IFD.cpp:849
uint16_t directory_index_type
IFD index.
Definition: Types.h:62
Compression getCompression() const
Get compression scheme.
Definition: IFD.cpp:1202
Image File Directory (IFD).
Definition: IFD.h:70
uint16_t getBitsPerSample() const
Get bits per sample.
Definition: IFD.cpp:1122
void getRawFieldDefaulted(tag_type tag,...) const
Get a field by its tag number, falling back to default if unset.
Definition: IFD.cpp:755
Field< TagCategory > getField(TagCategory tag)
Get a Field by its tag enumeration.
Definition: IFD.h:207
dimension_size_type getCurrentTile() const
Get the current tile being written.
Definition: IFD.cpp:837
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
uint32_t getImageWidth() const
Get the image width.
Definition: IFD.cpp:873
IFD & operator=(const IFD &)
Assignment operator (deleted).