00001
00002 #ifndef vil1_mit_file_format_h_
00003 #define vil1_mit_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
00020
00021
00022
00023
00024 #include <vil1/vil1_file_format.h>
00025 #include <vil1/vil1_image_impl.h>
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class vil1_mit_file_format : public vil1_file_format
00039 {
00040 public:
00041 virtual char const* tag() const;
00042 virtual vil1_image_impl* make_input_image(vil1_stream* vs);
00043 virtual vil1_image_impl* make_output_image(vil1_stream* vs, int planes,
00044 int width,
00045 int height,
00046 int components,
00047 int bits_per_component,
00048 vil1_component_format format);
00049 };
00050
00051
00052 class vil1_mit_generic_image : public vil1_image_impl
00053 {
00054 vil1_stream* is_;
00055 int magic_;
00056 int width_;
00057 int height_;
00058 int maxval_;
00059
00060 int start_of_data_;
00061 int components_;
00062 int bits_per_component_;
00063
00064 int type_;
00065 int bits_per_pixel_;
00066
00067 bool read_header();
00068 bool write_header();
00069
00070 friend class vil1_mit_file_format;
00071 public:
00072
00073 vil1_mit_generic_image(vil1_stream* is);
00074 vil1_mit_generic_image(vil1_stream* is, int planes,
00075 int width,
00076 int height,
00077 int components,
00078 int bits_per_component,
00079 vil1_component_format format);
00080 ~vil1_mit_generic_image();
00081
00082
00083 virtual int planes() const { return 1; }
00084 virtual int width() const { return width_; }
00085 virtual int height() const { return height_; }
00086 virtual int components() const { return components_; }
00087
00088 virtual int bits_per_component() const
00089 {
00090 return (type_ != 2) ? bits_per_pixel_ : bits_per_pixel_ / 3;
00091 }
00092
00093 virtual int bytes_per_pixel() const
00094 {
00095 return bits_per_pixel_ / 8;
00096 }
00097
00098 virtual enum vil1_component_format component_format() const
00099 {
00100 if (type_ == 1 || type_ == 2) return VIL1_COMPONENT_FORMAT_UNSIGNED_INT;
00101 else return VIL1_COMPONENT_FORMAT_IEEE_FLOAT;
00102 }
00103
00104
00105 virtual bool get_section(void* buf, int x0, int y0, int width, int height) const;
00106 virtual bool put_section(void const* buf, int x0, int y0, int width, int height);
00107
00108
00109
00110
00111
00112
00113 char const* file_format() const;
00114 bool get_property(char const *tag, void *prop = 0) const;
00115 vil1_image get_plane(unsigned int p) const;
00116 };
00117
00118 #endif // vil1_mit_file_format_h_