OpenStructure
map_io_tiff_handler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 #ifndef DX_IO_tiff_IO_PLUGIN_OST_HH
21 #define DX_IO_tiff_IO_PLUGIN_OST_HH
22 
23 /*
24  Authors: Ansgar Philippsen, Andreas Schenk
25 */
26 
27 #include <boost/logic/tribool.hpp>
28 
29 #include "map_io_handler.hh"
30 
31 
32 
33 struct tiff;
34 
35 namespace ost { namespace io {
36 
38 {
39 
40  public:
41 
42  TIF(boost::logic::tribool normalize_on_save = boost::logic::indeterminate, Format bit_depth = OST_DEFAULT_FORMAT, bool sign = false, bool phasecolor = false, int subimage = -1);
43 
44  Format GetBitDepth() const;
45  void SetBitDepth ( Format bitdepth);
46 
47  bool GetSigned () const;
48  void SetSigned (bool sign);
49 
50  bool GetPhasecolor () const;
51  void SetPhasecolor (bool phasecolor);
52 
53  Format GetFormat () const;
54  void SetFormat (Format bit_depth);
55 
56  boost::logic::tribool GetNormalizeOnSave() const;
57  void SetNormalizeOnSave(boost::logic::tribool normalize_on_save);
58 
59  int GetSubimage() const;
60  void SetSubimage(int subimage);
61 
63 
64 
65  protected:
66 
67  TIF(String format_string, boost::logic::tribool normalize_on_save = boost::logic::indeterminate, Format bit_depth = OST_DEFAULT_FORMAT, bool sign = false, bool phasecolor = false, int subimage = -1);
68  void do_export(const img::MapHandle& image,tiff* tfile,const TIF& formattif) const;
69 
70  private:
71 
72  boost::logic::tribool normalize_on_save_;
73  Format bit_depth_;
74  bool signed_;
75  bool phasecolor_;
76  int subimage_;
77 
78 };
79 
80 
82 {
83  public:
87  virtual void Import(img::MapHandle& sh, const boost::filesystem::path& loc,
88  const ImageFormatBase& formatstruct);
89  virtual void Import(img::MapHandle& sh, std::istream& loc,
90  const ImageFormatBase& formatstruct);
91  virtual void Export(const img::MapHandle& sh,
92  const boost::filesystem::path& loc,
93  const ImageFormatBase& formatstruct) const;
94  virtual void Export(const img::MapHandle& sh, std::ostream& loc,
95  const ImageFormatBase& formatstruct) const;
96  static bool MatchContent(unsigned char* header);
97  static bool MatchType(const ImageFormatBase& type);
98  static bool MatchSuffix(const String& loc);
99  static String GetFormatName() { return String( "Tiff"); }
100  static String GetFormatDescription() { return String("Tagged Image File Format"); }
101 
102  protected:
103 
104  tiff* open_subimage_file(const boost::filesystem::path& location,
105  const TIF& formattif);
106  tiff* open_subimage_stream(std::istream& location,const TIF& formattif);
107  void load_image_data(tiff* tfile, img::ImageHandle& image,
108  const TIF& formattif);
109  virtual void do_export(const img::MapHandle& sh,tiff* tfile,
110  TIF& formatstruct) const;
111 
112 };
113 
115 
116 }} // ns
117 
118 #endif