00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CVD_INCLUDE_INTERNAL_IO_FITS_H
00022 #define CVD_INCLUDE_INTERNAL_IO_FITS_H
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 FITS
00034 {
00035
00036 using CVD::Internal::TypeList;
00037 using CVD::Internal::Head;
00038
00039
00040
00041
00043
00044
00045
00046
00047 class ReadPimpl;
00048 class reader
00049 {
00050 public:
00051 reader(std::istream&);
00052 ~reader();
00053
00054 ImageRef size();
00055
00056 void get_raw_pixel_line(unsigned char*);
00057 void get_raw_pixel_line(signed short*);
00058 void get_raw_pixel_line(unsigned short*);
00059 void get_raw_pixel_line(signed int*);
00060 void get_raw_pixel_line(float*);
00061 void get_raw_pixel_line(double*);
00062
00063 void get_raw_pixel_line(Rgb<unsigned char>*);
00064 void get_raw_pixel_line(Rgb<signed short>*);
00065 void get_raw_pixel_line(Rgb<unsigned short>*);
00066 void get_raw_pixel_line(Rgb<signed int>*);
00067 void get_raw_pixel_line(Rgb<float>*);
00068 void get_raw_pixel_line(Rgb<double>*);
00069
00070 void get_raw_pixel_line(Rgba<unsigned char>*);
00071 void get_raw_pixel_line(Rgba<signed short>*);
00072 void get_raw_pixel_line(Rgba<unsigned short>*);
00073 void get_raw_pixel_line(Rgba<signed int>*);
00074 void get_raw_pixel_line(Rgba<float>*);
00075 void get_raw_pixel_line(Rgba<double>*);
00076
00077 std::string datatype();
00078 std::string name();
00079
00080
00081 typedef TypeList<byte,
00082 TypeList<signed short,
00083 TypeList<unsigned short,
00084 TypeList<signed int,
00085 TypeList<float,
00086 TypeList<double,
00087 TypeList<Rgb<byte>,
00088 TypeList<Rgb<signed short>,
00089 TypeList<Rgb<unsigned short>,
00090 TypeList<Rgb<signed int>,
00091 TypeList<Rgb<float>,
00092 TypeList<Rgb<double>,
00093 TypeList<Rgba<byte>,
00094 TypeList<Rgba<signed short>,
00095 TypeList<Rgba<unsigned short>,
00096 TypeList<Rgba<signed int>,
00097 TypeList<Rgba<float>,
00098 TypeList<Rgba<double>,
00099 Head> > > > > > > > > > > > > > > > > > Types;
00100
00101 private:
00102 std::auto_ptr<ReadPimpl> t;
00103 };
00104
00105
00107
00108
00109
00110
00111 template<typename C> struct IntMapper { typedef int type;};
00112 template<> struct IntMapper<bool> { typedef unsigned char type; };
00113 template<> struct IntMapper<char> { typedef short type; };
00114 template<> struct IntMapper<unsigned char> { typedef unsigned char type; };
00115 template<> struct IntMapper<short> { typedef short type; };
00116 template<> struct IntMapper<unsigned short> { typedef unsigned short type; };
00117 template<> struct IntMapper<int> { typedef int type; };
00118
00119
00120 template<class ComponentIn, int is_integral> struct ComponentMapper_
00121 {
00122 typedef typename IntMapper<ComponentIn>::type type;
00123 };
00124
00125
00126 template<class ComponentIn> struct ComponentMapper_<ComponentIn, 0> { typedef double type; };
00127 template<> struct ComponentMapper_<float, 0> { typedef float type; };
00128
00129 template<class ComponentIn> struct ComponentMapper
00130 {
00131 typedef typename ComponentMapper_<ComponentIn, Pixel::traits<ComponentIn>::integral>::type type;
00132 };
00133
00134
00135 template<class ComponentIn> struct ComponentMapper<Rgb<ComponentIn> >
00136 {
00137 typedef Rgb<typename ComponentMapper_<ComponentIn, Pixel::traits<ComponentIn>::integral>::type> type;
00138 };
00139
00140 template<class ComponentIn> struct ComponentMapper<Rgba<ComponentIn> >
00141 {
00142 typedef Rgba<typename ComponentMapper_<ComponentIn, Pixel::traits<ComponentIn>::integral>::type> type;
00143 };
00144
00145 template<> struct ComponentMapper<Rgb8>
00146 {
00147 typedef Rgb<byte> type;
00148 };
00149
00150
00151
00152
00153 class WritePimpl;
00154
00155 class writer
00156 {
00157 public:
00158 writer(std::ostream&, ImageRef size, const std::string& type, const std::map<std::string, Parameter<> >& p);
00159 ~writer();
00160
00161 void write_raw_pixel_line(const unsigned char*);
00162 void write_raw_pixel_line(const short*);
00163 void write_raw_pixel_line(const unsigned short*);
00164 void write_raw_pixel_line(const int*);
00165 void write_raw_pixel_line(const float*);
00166 void write_raw_pixel_line(const double*);
00167
00168 void write_raw_pixel_line(const Rgb<unsigned char>*);
00169 void write_raw_pixel_line(const Rgb<short>*);
00170 void write_raw_pixel_line(const Rgb<unsigned short>*);
00171 void write_raw_pixel_line(const Rgb<int>*);
00172 void write_raw_pixel_line(const Rgb<float>*);
00173 void write_raw_pixel_line(const Rgb<double>*);
00174
00175 void write_raw_pixel_line(const Rgba<unsigned char>*);
00176 void write_raw_pixel_line(const Rgba<short>*);
00177 void write_raw_pixel_line(const Rgba<unsigned short>*);
00178 void write_raw_pixel_line(const Rgba<int>*);
00179 void write_raw_pixel_line(const Rgba<float>*);
00180 void write_raw_pixel_line(const Rgba<double>*);
00181
00182 template<class Incoming> struct Outgoing
00183 {
00184 typedef typename ComponentMapper<Incoming>::type type;
00185 };
00186
00187 private:
00188 WritePimpl* t;
00189 };
00190
00191 }
00192 }
00193 #endif