#ifndef PNM_CVDIMAGE_H #define PNM_CVDIMAGE_H #include #include #include #include #include #include #include #include #include namespace CVD { namespace CVDimage { using CVD::Internal::Head; using CVD::Internal::TypeList; 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(bayer_bggr*); void get_raw_pixel_line(bayer_rggb*); void get_raw_pixel_line(bayer_grbg*); void get_raw_pixel_line(bayer_gbrg*); void get_raw_pixel_line(Rgb*); void get_raw_pixel_line(Rgba*); std::string datatype(); std::string name(); typedef TypeList, TypeList, Head>>>>>>> Types; static bool first_byte_matches(const int b) { return b == 'C'; } private: std::unique_ptr t; }; 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 byte*); void write_raw_pixel_line(const bayer_bggr*); void write_raw_pixel_line(const bayer_rggb*); void write_raw_pixel_line(const bayer_grbg*); void write_raw_pixel_line(const bayer_gbrg*); void write_raw_pixel_line(const Rgb*); void write_raw_pixel_line(const Rgba*); template struct Outgoing { typedef byte type; }; static const int top_row_first = 1; protected: std::unique_ptr t; }; template <> struct writer::Outgoing { typedef bayer_bggr type; }; template <> struct writer::Outgoing { typedef bayer_rggb type; }; template <> struct writer::Outgoing { typedef bayer_grbg type; }; template <> struct writer::Outgoing { typedef bayer_gbrg type; }; template struct writer::Outgoing> { typedef Rgb type; }; template struct writer::Outgoing> { typedef Rgba type; }; template <> struct writer::Outgoing { typedef Rgb type; }; } } #endif