bioformats  5.1.2
IFD.h
1 /*
2  * #%L
3  * OME-BIOFORMATS 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_BIOFORMATS_TIFF_IFD_H
39 #define OME_BIOFORMATS_TIFF_IFD_H
40 
41 #include <string>
42 
43 #include <ome/compat/memory.h>
44 
45 #include <ome/bioformats/CoreMetadata.h>
46 #include <ome/bioformats/TileCoverage.h>
47 #include <ome/bioformats/tiff/TileInfo.h>
48 #include <ome/bioformats/tiff/Types.h>
49 #include <ome/bioformats/VariantPixelBuffer.h>
50 
51 #include <ome/xml/model/enums/PixelType.h>
52 
53 namespace ome
54 {
55  namespace bioformats
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 
179  void
180  setRawField(tag_type tag,
181  ...);
182 
189  template<typename TagCategory>
191  getField(TagCategory tag)
192  {
193  return Field<TagCategory>(this->shared_from_this(), tag);
194  }
195 
202  template<typename TagCategory>
203  const Field<TagCategory>
204  getField(TagCategory tag) const
205  {
206  return Field<TagCategory>(const_cast<IFD *>(this)->shared_from_this(), tag);
207  }
208 
214  TileType
215  getTileType() const;
216 
222  void
223  setTileType(TileType type);
224 
233  getCurrentTile() const;
234 
246  void
248 
255  TileInfo
256  getTileInfo();
257 
264  const TileInfo
265  getTileInfo() const;
266 
272  std::vector<TileCoverage>&
273  getTileCoverage();
274 
280  const std::vector<TileCoverage>&
281  getTileCoverage() const;
282 
288  uint32_t
289  getImageWidth() const;
290 
296  void
297  setImageWidth(uint32_t width);
298 
304  uint32_t
305  getImageHeight() const;
306 
312  void
313  setImageHeight(uint32_t height);
314 
320  uint32_t
321  getTileWidth() const;
322 
328  void
329  setTileWidth(uint32_t width);
330 
336  uint32_t
337  getTileHeight() const;
338 
344  void
345  setTileHeight(uint32_t height);
346 
358  getPixelType() const;
359 
369  void
371 
377  uint16_t
378  getBitsPerSample() const;
379 
385  void
386  setBitsPerSample(uint16_t samples);
387 
393  uint16_t
394  getSamplesPerPixel() const;
395 
401  void
402  setSamplesPerPixel(uint16_t samples);
403 
410  getPlanarConfiguration() const;
411 
417  void
419 
427 
433  void
435 
441  void
442  readImage(VariantPixelBuffer& buf) const;
443 
448  void
450  dimension_size_type subC) const;
451 
466  void
471  dimension_size_type h) const;
472 
477  void
483  dimension_size_type subC) const;
484 
490  void
492 
498  void
499  writeImage(const VariantPixelBuffer& buf);
500 
505  void
506  writeImage(const VariantPixelBuffer& buf,
507  dimension_size_type subC);
508 
522  void
523  writeImage(const VariantPixelBuffer& source,
528 
533  void
534  writeImage(const VariantPixelBuffer& source,
539  dimension_size_type subC);
540 
546  ome::compat::shared_ptr<IFD>
547  next() const;
548 
554  bool
555  last() const;
556  };
557 
558  }
559  }
560 }
561 
562 #endif // OME_BIOFORMATS_TIFF_IFD_H
563 
564 /*
565  * Local Variables:
566  * mode:C++
567  * End:
568  */
void setImageWidth(uint32_t width)
Set the image width.
Definition: IFD.cpp:856
Tile information for an IFD.
Definition: TileInfo.h:61
void setCurrentTile(dimension_size_type tile)
Set the current tile being written.
Definition: IFD.cpp:814
uint32_t getTileWidth() const
Get the tile width.
Definition: IFD.cpp:882
void setTileWidth(uint32_t width)
Set the tile width.
Definition: IFD.cpp:901
Internal implementation details of OffsetIFD.
Definition: IFD.cpp:582
dimension_size_type getCurrentTile() const
Get the current tile being written.
Definition: IFD.cpp:808
Memory type substitution.
Field< TagCategory > getField(TagCategory tag)
Get a Field by its tag enumeration.
Definition: IFD.h:191
uint32_t getImageWidth() const
Get the image width.
Definition: IFD.cpp:844
uint16_t directory_index_type
IFD index.
Definition: Types.h:53
void setBitsPerSample(uint16_t samples)
Set bits per sample.
Definition: IFD.cpp:1081
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:673
void setSamplesPerPixel(uint16_t samples)
Set samples per pixel.
Definition: IFD.cpp:1104
void setTileHeight(uint32_t height)
Set the tile height.
Definition: IFD.cpp:936
TileInfo getTileInfo()
Get tiling metadata.
Definition: IFD.cpp:820
ome::compat::shared_ptr< IFD > next() const
Get next directory.
Definition: IFD.cpp:1321
Field representing a tag value.
Definition: Field.h:157
IFD(ome::compat::shared_ptr< TIFF > &tiff, offset_type offset)
Constructor (not public).
Definition: IFD.cpp:653
uint32_t getTileHeight() const
Get the tile height.
Definition: IFD.cpp:915
ome::compat::shared_ptr< TIFF > & getTIFF() const
Get the source TIFF this descriptor belongs to.
Definition: IFD.cpp:726
PlanarConfiguration getPlanarConfiguration() const
Get planar configuration.
Definition: IFD.cpp:1111
void readLookupTable(VariantPixelBuffer &buf) const
Read a lookup table into a pixel buffer.
Definition: IFD.cpp:1216
static ome::compat::shared_ptr< IFD > current(ome::compat::shared_ptr< TIFF > &tiff)
Get the current IFD.
Definition: IFD.cpp:698
void setTileType(TileType type)
Set the tile type.
Definition: IFD.cpp:802
uint64_t offset_type
IFD offset.
Definition: Types.h:56
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
void writeImage(const VariantPixelBuffer &buf)
Write a whole image plane from a pixel buffer.
Definition: IFD.cpp:1262
void makeCurrent() const
Make this IFD the current directory.
Definition: IFD.cpp:706
ome::compat::shared_ptr< Impl > impl
Private implementation details.
Definition: IFD.h:74
void setPlanarConfiguration(PlanarConfiguration planarconfig)
Set planar configuration.
Definition: IFD.cpp:1123
PlanarConfiguration
Planar configuration of samples.
Definition: Types.h:167
PhotometricInterpretation
Photometric interpretation of pixel data.
Definition: Types.h:149
TileType getTileType() const
Get the tile type.
Definition: IFD.cpp:780
void setRawField(tag_type tag,...)
Set a field by its tag number.
Definition: IFD.cpp:759
PhotometricInterpretation getPhotometricInterpretation() const
Get photometric interpretation.
Definition: IFD.cpp:1130
uint16_t getSamplesPerPixel() const
Get samples per pixel.
Definition: IFD.cpp:1092
IFD & operator=(const IFD &)
Assignment operator (deleted).
virtual ~IFD()
Destructor.
Definition: IFD.cpp:668
const Field< TagCategory > getField(TagCategory tag) const
Get a Field by its tag enumeration.
Definition: IFD.h:204
PixelType enumeration.
Definition: PixelType.h:70
uint32_t getImageHeight() const
Get the image height.
Definition: IFD.cpp:863
bool last() const
Check if this is the last directory.
Definition: IFD.cpp:1342
void setPixelType(::ome::xml::model::enums::PixelType type)
Set the OME data model PixelType.
Definition: IFD.cpp:1030
::ome::xml::model::enums::PixelType getPixelType() const
Get the OME data model PixelType.
Definition: IFD.cpp:950
std::vector< TileCoverage > & getTileCoverage()
Get tile coverage cache.
Definition: IFD.cpp:832
void getRawField(tag_type tag,...) const
Get a field by its tag number.
Definition: IFD.cpp:738
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:72
Image File Directory (IFD).
Definition: IFD.h:71
void setImageHeight(uint32_t height)
Set the image height.
Definition: IFD.cpp:875
static ome::compat::shared_ptr< IFD > openOffset(ome::compat::shared_ptr< TIFF > &tiff, offset_type offset)
Open an IFD.
Definition: IFD.cpp:689
void readImage(VariantPixelBuffer &buf) const
Read a whole image plane into a pixel buffer.
Definition: IFD.cpp:1149
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
void setPhotometricInterpretation(PhotometricInterpretation photometric)
Set photometric interpretation.
Definition: IFD.cpp:1142
unsigned int tag_type
Tag number.
Definition: Types.h:59
TileType
Type of tile.
Definition: Types.h:208
offset_type getOffset() const
Get the directory offset.
Definition: IFD.cpp:732
uint16_t getBitsPerSample() const
Get bits per sample.
Definition: IFD.cpp:1069