00001
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005
00006
00007
00008
00009 #include "vil1_image_proxy.h"
00010 #include <vcl_string.h>
00011 #include <vil1/vil1_load.h>
00012
00013 struct vil1_image_proxy_impl : public vil1_image_impl
00014 {
00015 vcl_string filename;
00016
00017
00018 int planes_;
00019 int width_;
00020 int height_;
00021 int components_;
00022 int bits_per_component_;
00023 vil1_component_format component_format_;
00024 vcl_string file_format_;
00025
00026 vil1_image_proxy_impl(char const *file) : filename(file) {
00027
00028 vil1_image I = vil1_load(filename.c_str());
00029 #define macro(p) p##_ = I.p()
00030 macro(planes);
00031 macro(width);
00032 macro(height);
00033 macro(components);
00034 macro(bits_per_component);
00035 macro(component_format);
00036 #undef macro
00037 file_format_ = I.file_format();
00038 }
00039
00040
00041 int planes() const { return planes_; }
00042 int width() const { return width_; }
00043 int height() const { return height_; }
00044 int components() const { return components_; }
00045 int bits_per_component() const { return bits_per_component_; }
00046 enum vil1_component_format component_format() const { return component_format_; }
00047 char const *file_format() const { return file_format_.c_str(); }
00048
00049
00050 vil1_image get_plane(unsigned int p) const { return vil1_load(filename.c_str()).get_plane(p); }
00051
00052 bool get_section(void *buf, int x0, int y0, int width, int height) const
00053 { return vil1_load(filename.c_str()).get_section(buf, x0, y0, width, height); }
00054 bool put_section(void const *buf, int x0, int y0, int width, int height)
00055 { return vil1_load(filename.c_str()).put_section(buf, x0, y0, width, height); }
00056
00057 bool get_property(char const *tag, void *property_value) const
00058 { return vil1_load(filename.c_str()).get_property(tag, property_value); }
00059 bool set_property(char const *tag, void const *property_value) const
00060 { return vil1_load(filename.c_str()).set_property(tag, property_value); }
00061
00062
00063 virtual vcl_string is_a() const;
00064
00065
00066 virtual bool is_class(vcl_string const&) const;
00067 };
00068
00069 vil1_image_proxy::vil1_image_proxy(char const *file)
00070 : vil1_image(new vil1_image_proxy_impl(file))
00071 {
00072 }
00073
00074
00075 vcl_string vil1_image_proxy_impl::is_a() const
00076 {
00077 static const vcl_string class_name_="vil1_image_proxy_impl";
00078 return class_name_;
00079 }
00080
00081
00082 bool vil1_image_proxy_impl::is_class(vcl_string const& s) const
00083 {
00084 return s==vil1_image_proxy_impl::is_a() || vil1_image_impl::is_class(s);
00085 }