00001
00002 #ifndef vil_bmp_file_format_h_
00003 #define vil_bmp_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 class vil_stream;
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <vil/vil_file_format.h>
00033 #include <vil/vil_image_resource.h>
00034 #include <vil/vil_stream.h>
00035 #include "vil_bmp_file_header.h"
00036 #include "vil_bmp_core_header.h"
00037 #include "vil_bmp_info_header.h"
00038 class vil_image_view_base;
00039
00040
00041
00042 class vil_bmp_file_format : public vil_file_format
00043 {
00044 public:
00045 virtual char const* tag() const;
00046 virtual vil_image_resource_sptr make_input_image(vil_stream* vs);
00047 virtual vil_image_resource_sptr make_output_image(vil_stream* vs,
00048 unsigned nx,
00049 unsigned ny,
00050 unsigned nplanes,
00051 vil_pixel_format format);
00052 };
00053
00054
00055 class vil_bmp_image : public vil_image_resource
00056 {
00057 public:
00058 vil_bmp_image(vil_stream* is, unsigned ni,
00059 unsigned nj, unsigned nplanes, vil_pixel_format format);
00060 vil_bmp_image(vil_stream* is);
00061 ~vil_bmp_image();
00062
00063
00064 virtual unsigned nplanes() const {
00065 return (core_hdr.bitsperpixel<24)?1:core_hdr.bitsperpixel/8; }
00066 virtual unsigned ni() const { return core_hdr.width; }
00067 virtual unsigned nj() const { return core_hdr.height; }
00068
00069 virtual enum vil_pixel_format pixel_format() const {return VIL_PIXEL_FORMAT_BYTE; }
00070
00071
00072
00073 virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
00074 unsigned j0, unsigned nj) const;
00075
00076
00077 virtual bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0);
00078
00079 char const* file_format() const;
00080 bool get_property(char const *tag, void *prop = 0) const;
00081 private:
00082 vil_stream* is_;
00083
00084 bool read_header();
00085 bool write_header();
00086
00087 friend class vil_bmp_file_format;
00088
00089 vil_bmp_file_header file_hdr;
00090 vil_bmp_core_header core_hdr;
00091 vil_bmp_info_header info_hdr;
00092 vil_streampos bit_map_start;
00093 #if 0
00094 uchar **freds_colormap;
00095
00096 xBITMAPINFOHEADER header;
00097 xBITMAPFILEHEADER fbmp;
00098 int pixsize;
00099 int** local_color_map_;
00100 #endif // 0
00101 };
00102
00103
00104 #endif // vil_bmp_file_format_h_