ome-files  0.2.3
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 
153  getOffset() const;
154 
165  void
166  getRawField(tag_type tag,
167  ...) const;
168 
180  void
182  ...) const;
183 
194  void
195  setRawField(tag_type tag,
196  ...);
197 
204  template<typename 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 
248  getCurrentTile() const;
249 
261  void
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 
373  getPixelType() const;
374 
384  void
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 
425  getPlanarConfiguration() const;
426 
432  void
434 
442 
448  void
450 
456  void
457  readImage(VariantPixelBuffer& buf) const;
458 
463  void
465  dimension_size_type subC) const;
466 
481  void
486  dimension_size_type h) const;
487 
492  void
498  dimension_size_type subC) const;
499 
505  void
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,
543 
548  void
549  writeImage(const VariantPixelBuffer& source,
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  */
TileType
Type of tile.
Definition: Types.h:217
void setPlanarConfiguration(PlanarConfiguration planarconfig)
Set planar configuration.
Definition: IFD.cpp:1178
void setTileHeight(uint32_t height)
Set the tile height.
Definition: IFD.cpp:967
void setSamplesPerPixel(uint16_t samples)
Set samples per pixel.
Definition: IFD.cpp:1159
IFD(ome::compat::shared_ptr< TIFF > &tiff, offset_type offset)
Constructor (not public).
Definition: IFD.cpp:648
ome::compat::shared_ptr< TIFF > & getTIFF() const
Get the source TIFF this descriptor belongs to.
Definition: IFD.cpp:716
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
uint32_t getTileWidth() const
Get the tile width.
Definition: IFD.cpp:913
void setCurrentTile(dimension_size_type tile)
Set the current tile being written.
Definition: IFD.cpp:845
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:1081
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:728
void setPhotometricInterpretation(PhotometricInterpretation photometric)
Set photometric interpretation.
Definition: IFD.cpp:1197
unsigned int tag_type
Tag number.
Definition: Types.h:68
static ome::compat::shared_ptr< IFD > openOffset(ome::compat::shared_ptr< TIFF > &tiff, offset_type offset)
Open an IFD.
Definition: IFD.cpp:684
void makeCurrent() const
Make this IFD the current directory.
Definition: IFD.cpp:701
PhotometricInterpretation getPhotometricInterpretation() const
Get photometric interpretation.
Definition: IFD.cpp:1185
PlanarConfiguration getPlanarConfiguration() const
Get planar configuration.
Definition: IFD.cpp:1166
void readLookupTable(VariantPixelBuffer &buf) const
Read a lookup table into a pixel buffer.
Definition: IFD.cpp:1271
uint32_t getTileHeight() const
Get the tile height.
Definition: IFD.cpp:946
uint64_t offset_type
IFD offset.
Definition: Types.h:65
uint16_t getSamplesPerPixel() const
Get samples per pixel.
Definition: IFD.cpp:1147
const Field< TagCategory > getField(TagCategory tag) const
Get a Field by its tag enumeration.
Definition: IFD.h:219
Open Microscopy Environment C++.
void setTileType(TileType type)
Set the tile type.
Definition: IFD.cpp:833
std::vector< TileCoverage > & getTileCoverage()
Get tile coverage cache.
Definition: IFD.cpp:863
void writeImage(const VariantPixelBuffer &buf)
Write a whole image plane from a pixel buffer.
Definition: IFD.cpp:1317
virtual ~IFD()
Destructor.
Definition: IFD.cpp:663
void setTileWidth(uint32_t width)
Set the tile width.
Definition: IFD.cpp:932
void setRawField(tag_type tag,...)
Set a field by its tag number.
Definition: IFD.cpp:786
uint32_t getImageHeight() const
Get the image height.
Definition: IFD.cpp:894
offset_type getOffset() const
Get the directory offset.
Definition: IFD.cpp:722
bool last() const
Check if this is the last directory.
Definition: IFD.cpp:1431
void readImage(VariantPixelBuffer &buf) const
Read a whole image plane into a pixel buffer.
Definition: IFD.cpp:1204
TileType getTileType() const
Get the tile type.
Definition: IFD.cpp:811
ome::compat::shared_ptr< IFD > next() const
Get next directory.
Definition: IFD.cpp:1410
ome::compat::shared_ptr< Impl > impl
Private implementation details.
Definition: IFD.h:74
Field representing a tag value.
Definition: Field.h:157
void setImageHeight(uint32_t height)
Set the image height.
Definition: IFD.cpp:906
Internal implementation details of OffsetIFD.
Definition: IFD.cpp:577
static ome::compat::shared_ptr< IFD > current(ome::compat::shared_ptr< TIFF > &tiff)
Get the current IFD.
Definition: IFD.cpp:693
::ome::xml::model::enums::PixelType getPixelType() const
Get the OME data model PixelType.
Definition: IFD.cpp:981
void setImageWidth(uint32_t width)
Set the image width.
Definition: IFD.cpp:887
void setBitsPerSample(uint16_t samples)
Set bits per sample.
Definition: IFD.cpp:1136
PhotometricInterpretation
Photometric interpretation of pixel data.
Definition: Types.h:158
TileInfo getTileInfo()
Get tiling metadata.
Definition: IFD.cpp:851
uint16_t directory_index_type
IFD index.
Definition: Types.h:62
Image File Directory (IFD).
Definition: IFD.h:71
uint16_t getBitsPerSample() const
Get bits per sample.
Definition: IFD.cpp:1124
void getRawFieldDefaulted(tag_type tag,...) const
Get a field by its tag number, falling back to default if unset.
Definition: IFD.cpp:757
Field< TagCategory > getField(TagCategory tag)
Get a Field by its tag enumeration.
Definition: IFD.h:206
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
dimension_size_type getCurrentTile() const
Get the current tile being written.
Definition: IFD.cpp:839
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
uint32_t getImageWidth() const
Get the image width.
Definition: IFD.cpp:875
IFD & operator=(const IFD &)
Assignment operator (deleted).