00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PNM_TIFF
00022 #define PNM_TIFF
00023
00024 #include <iostream>
00025 #include <memory>
00026 #include <vector>
00027 #include <string>
00028 #include <cvd/image.h>
00029 #include <cvd/internal/load_and_save.h>
00030
00031 namespace CVD
00032 {
00033 namespace TIFF
00034 {
00035
00036 using CVD::Internal::TypeList;
00037 using CVD::Internal::Head;
00038
00039
00041
00042
00043
00044
00045 class TIFFPimpl;
00046 class tiff_reader
00047 {
00048 public:
00049 tiff_reader(std::istream&);
00050 ~tiff_reader();
00051
00052 ImageRef size();
00053
00054 void get_raw_pixel_line(bool*);
00055 void get_raw_pixel_line(unsigned char*);
00056 void get_raw_pixel_line(unsigned short*);
00057 void get_raw_pixel_line(float*);
00058 void get_raw_pixel_line(double*);
00059
00060 void get_raw_pixel_line(Rgb<unsigned char>*);
00061 void get_raw_pixel_line(Rgb<unsigned short>*);
00062 void get_raw_pixel_line(Rgb<float>*);
00063 void get_raw_pixel_line(Rgb<double>*);
00064
00065 void get_raw_pixel_line(Rgba<unsigned char>*);
00066 void get_raw_pixel_line(Rgba<unsigned short>*);
00067 void get_raw_pixel_line(Rgba<float>*);
00068 void get_raw_pixel_line(Rgba<double>*);
00069
00070 std::string datatype();
00071 std::string name();
00072
00073
00074 typedef TypeList<bool,
00075 TypeList<byte,
00076 TypeList<unsigned short,
00077 TypeList<float,
00078 TypeList<double,
00079 TypeList<Rgb<byte>,
00080 TypeList<Rgb<unsigned short>,
00081 TypeList<Rgb<float>,
00082 TypeList<Rgb<double>,
00083 TypeList<Rgba<byte>,
00084 TypeList<Rgba<unsigned short>,
00085 TypeList<Rgba<float>,
00086 TypeList<Rgba<double>,
00087 Head> > > > > > > > > > > > > Types;
00088
00089 private:
00090 std::auto_ptr<TIFFPimpl> t;
00091 };
00092
00093
00095
00096
00097
00098
00099
00100
00101
00102
00103 template<int g1, int g8> struct IntMapper { typedef unsigned short type;};
00104 template<> struct IntMapper<1, 0> { typedef unsigned char type; };
00105 template<> struct IntMapper<0, 0> { typedef bool type; };
00106
00107
00108
00109 template<class ComponentIn, int is_integral> struct ComponentMapper_
00110 {
00111 typedef typename IntMapper<
00112 (Pixel::traits<ComponentIn>::bits_used > 1),
00113 (Pixel::traits<ComponentIn>::bits_used > 8)
00114 >::type type;
00115 };
00116
00117
00118 template<class ComponentIn> struct ComponentMapper_<ComponentIn, 0> { typedef double type; };
00119 template<> struct ComponentMapper_<float, 0> { typedef float type; };
00120
00121 template<class ComponentIn> struct ComponentMapper
00122 {
00123 typedef typename ComponentMapper_<ComponentIn, Pixel::traits<ComponentIn>::integral>::type type;
00124 };
00125
00126
00127 template<class ComponentIn> struct ComponentMapper<Rgb<ComponentIn> >
00128 {
00129 typedef Rgb<typename ComponentMapper_<ComponentIn, Pixel::traits<ComponentIn>::integral>::type> type;
00130 };
00131
00132 template<class ComponentIn> struct ComponentMapper<Rgba<ComponentIn> >
00133 {
00134 typedef Rgba<typename ComponentMapper_<ComponentIn, Pixel::traits<ComponentIn>::integral>::type> type;
00135 };
00136
00137 template<> struct ComponentMapper<Rgb8>
00138 {
00139 typedef Rgb<byte> type;
00140 };
00141
00142
00143
00144 class TIFFWritePimpl;
00145
00146 class tiff_writer
00147 {
00148 public:
00149 tiff_writer(std::ostream&, ImageRef size, const std::string& type, const std::map<std::string, Parameter<> >& p);
00150 ~tiff_writer();
00151
00152 void write_raw_pixel_line(const bool*);
00153 void write_raw_pixel_line(const unsigned char*);
00154 void write_raw_pixel_line(const unsigned short*);
00155 void write_raw_pixel_line(const float*);
00156 void write_raw_pixel_line(const double*);
00157
00158 void write_raw_pixel_line(const Rgb<unsigned char>*);
00159 void write_raw_pixel_line(const Rgb<unsigned short>*);
00160 void write_raw_pixel_line(const Rgb<float>*);
00161 void write_raw_pixel_line(const Rgb<double>*);
00162
00163 void write_raw_pixel_line(const Rgba<unsigned char>*);
00164 void write_raw_pixel_line(const Rgba<unsigned short>*);
00165 void write_raw_pixel_line(const Rgba<float>*);
00166 void write_raw_pixel_line(const Rgba<double>*);
00167
00168 template<class Incoming> struct Outgoing
00169 {
00170 typedef typename ComponentMapper<Incoming>::type type;
00171 };
00172
00173 private:
00174 std::auto_ptr<TIFFWritePimpl> t;
00175 };
00176
00177
00178 }
00179 }
00180 #endif