#ifndef CVD_INCLUDE_INTERNAL_IO_FITS_H #define CVD_INCLUDE_INTERNAL_IO_FITS_H #include #include #include #include #include #include namespace CVD { namespace FITS { using CVD::Internal::Head; using CVD::Internal::TypeList; //Probably not the best way to deal with FITS. Data is unlikely to be RGBA, for //instance. Maybe it would be best to implement loading of tr1::array and Vector. //////////////////////////////////////////////////////////////////////////////// // // FITS reading // class ReadPimpl; class Reader { public: Reader(std::istream&); ~Reader(); ImageRef size(); bool top_row_first(); void get_raw_pixel_line(unsigned char*); void get_raw_pixel_line(signed short*); void get_raw_pixel_line(unsigned short*); void get_raw_pixel_line(signed int*); void get_raw_pixel_line(float*); void get_raw_pixel_line(double*); void get_raw_pixel_line(Rgb*); void get_raw_pixel_line(Rgb*); void get_raw_pixel_line(Rgb*); void get_raw_pixel_line(Rgb*); void get_raw_pixel_line(Rgb*); void get_raw_pixel_line(Rgb*); void get_raw_pixel_line(Rgba*); void get_raw_pixel_line(Rgba*); void get_raw_pixel_line(Rgba*); void get_raw_pixel_line(Rgba*); void get_raw_pixel_line(Rgba*); void get_raw_pixel_line(Rgba*); std::string datatype(); std::string name(); typedef TypeList, TypeList, TypeList, TypeList, TypeList, TypeList, TypeList, TypeList, TypeList, TypeList, TypeList, TypeList, Head>>>>>>>>>>>>>>>>>> Types; static bool first_byte_matches(const int b) { return b == 'S'; } private: std::unique_ptr t; }; //////////////////////////////////////////////////////////////////////////////// // // FITS writing, copied and modified from tiff.h // template struct IntMapper { typedef int type; }; template <> struct IntMapper { typedef unsigned char type; }; template <> struct IntMapper { typedef short type; }; template <> struct IntMapper { typedef unsigned char type; }; template <> struct IntMapper { typedef short type; }; template <> struct IntMapper { typedef unsigned short type; }; template <> struct IntMapper { typedef int type; }; //Mapping for integral types template struct ComponentMapper_ { typedef typename IntMapper::type type; }; //Mapping for non integral types template struct ComponentMapper_ { typedef double type; }; template <> struct ComponentMapper_ { typedef float type; }; template struct ComponentMapper { typedef typename ComponentMapper_::integral>::type type; }; //Mapping for Rgbish types template struct ComponentMapper> { typedef Rgb::integral>::type> type; }; template struct ComponentMapper> { typedef Rgba::integral>::type> type; }; template <> struct ComponentMapper { typedef Rgb type; }; class WritePimpl; class writer { public: writer(std::ostream&, ImageRef size, const std::string& type, const std::map>& p); ~writer(); void write_raw_pixel_line(const unsigned char*); void write_raw_pixel_line(const short*); void write_raw_pixel_line(const unsigned short*); void write_raw_pixel_line(const int*); void write_raw_pixel_line(const float*); void write_raw_pixel_line(const double*); void write_raw_pixel_line(const Rgb*); void write_raw_pixel_line(const Rgb*); void write_raw_pixel_line(const Rgb*); void write_raw_pixel_line(const Rgb*); void write_raw_pixel_line(const Rgb*); void write_raw_pixel_line(const Rgb*); void write_raw_pixel_line(const Rgba*); void write_raw_pixel_line(const Rgba*); void write_raw_pixel_line(const Rgba*); void write_raw_pixel_line(const Rgba*); void write_raw_pixel_line(const Rgba*); void write_raw_pixel_line(const Rgba*); template struct Outgoing { typedef typename ComponentMapper::type type; }; static const int top_row_first = 1; private: WritePimpl* t; }; } } #endif