Go to the documentation of this file.00001
00002 #ifndef vil_pnm_file_format_h_
00003 #define vil_pnm_file_format_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <vil/vil_image_resource.h>
00020 #include <vil/vil_file_format.h>
00021 #include <vil/vil_stream.h>
00022
00023 class vil_image_view_base;
00024
00025
00026
00027 class vil_pnm_file_format : public vil_file_format
00028 {
00029 public:
00030 virtual char const* tag() const;
00031 virtual vil_image_resource_sptr make_input_image(vil_stream* vs);
00032 virtual vil_image_resource_sptr make_output_image(vil_stream* vs,
00033 unsigned ni,
00034 unsigned nj,
00035 unsigned nplanes,
00036 vil_pixel_format format);
00037 };
00038
00039
00040 class vil_pbm_file_format : public vil_pnm_file_format
00041 {
00042 public:
00043 virtual char const* tag() const { return "pbm"; }
00044 };
00045
00046
00047 class vil_pgm_file_format : public vil_pnm_file_format
00048 {
00049 public:
00050 virtual char const* tag() const { return "pgm"; }
00051 };
00052
00053
00054 class vil_ppm_file_format : public vil_pnm_file_format
00055 {
00056 public:
00057 virtual char const* tag() const { return "ppm"; }
00058 };
00059
00060
00061 class vil_pnm_image : public vil_image_resource
00062 {
00063 vil_stream* vs_;
00064 int magic_;
00065 unsigned ni_;
00066 unsigned nj_;
00067 unsigned long int maxval_;
00068
00069 vil_streampos start_of_data_;
00070 unsigned ncomponents_;
00071 unsigned bits_per_component_;
00072
00073
00074 vil_pixel_format format_;
00075
00076 bool read_header();
00077 bool write_header();
00078
00079 friend class vil_pnm_file_format;
00080
00081 public:
00082 vil_pnm_image (vil_stream* is, unsigned ni,
00083 unsigned nj, unsigned nplanes,
00084 vil_pixel_format format);
00085 vil_pnm_image(vil_stream* is);
00086 ~vil_pnm_image();
00087
00088
00089
00090 virtual unsigned nplanes() const { return ncomponents_; }
00091 virtual unsigned ni() const { return ni_; }
00092 virtual unsigned nj() const { return nj_; }
00093
00094 virtual enum vil_pixel_format pixel_format() const {return format_; }
00095
00096 virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
00097 unsigned j0, unsigned nj) const;
00098
00099 virtual bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0);
00100
00101 char const* file_format() const;
00102 bool get_property(char const *tag, void *prop = 0) const;
00103 };
00104
00105 #endif // vil_pnm_file_format_h_