00001
00002 #ifndef vil1_pnm_file_format_h_
00003 #define vil1_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 #include <vil1/vil1_file_format.h>
00019 #include <vil1/vil1_image_impl.h>
00020
00021
00022 class vil1_pnm_file_format : public vil1_file_format
00023 {
00024 public:
00025 virtual char const* tag() const;
00026 virtual vil1_image_impl* make_input_image(vil1_stream* vs);
00027 virtual vil1_image_impl* make_output_image(vil1_stream* vs, int planes,
00028 int width,
00029 int height,
00030 int components,
00031 int bits_per_component,
00032 vil1_component_format format);
00033 };
00034
00035
00036 class vil1_pnm_generic_image : public vil1_image_impl
00037 {
00038 vil1_stream* vs_;
00039 int magic_;
00040 int width_;
00041 int height_;
00042 unsigned long int maxval_;
00043
00044 int start_of_data_;
00045 int components_;
00046 int bits_per_component_;
00047
00048 bool read_header();
00049 bool write_header();
00050
00051 friend class vil1_pnm_file_format;
00052 public:
00053
00054 vil1_pnm_generic_image(vil1_stream* is);
00055 vil1_pnm_generic_image(vil1_stream* is, int planes,
00056 int width,
00057 int height,
00058 int components,
00059 int bits_per_component,
00060 vil1_component_format format);
00061 ~vil1_pnm_generic_image();
00062
00063
00064 virtual int planes() const { return 1; }
00065 virtual int width() const { return width_; }
00066 virtual int height() const { return height_; }
00067 virtual int components() const { return components_; }
00068
00069 virtual int bits_per_component() const { return bits_per_component_; }
00070 virtual enum vil1_component_format component_format() const { return VIL1_COMPONENT_FORMAT_UNSIGNED_INT; }
00071
00072
00073 virtual bool get_section(void* buf, int x0, int y0, int width, int height) const;
00074
00075 virtual bool put_section(void const* buf, int x0, int y0, int width, int height);
00076
00077 char const* file_format() const;
00078 bool get_property(char const *tag, void *prop = 0) const;
00079 vil1_image get_plane(unsigned int p) const;
00080 };
00081
00082 #endif // vil1_pnm_file_format_h_