core/vil1/file_formats/vil1_gen.h

Go to the documentation of this file.
00001 // This is core/vil1/file_formats/vil1_gen.h
00002 #ifndef vil1_gen_file_format_h_
00003 #define vil1_gen_file_format_h_
00004 //:
00005 // \file
00006 // \author awf@robots.ox.ac.uk 16 Feb 00
00007 //
00008 // \verbatim
00009 //  Modifications
00010 //   10/4/2001 Ian Scott (Manchester) Converted perceps header to doxygen
00011 //   3 October 2001 Peter Vanroose - Implemented get_property("top_row_first")
00012 //   12 Sept. 2002 Peter Vanroose - Changed type of params_ from float to int
00013 // \endverbatim
00014 
00015 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00016 #pragma interface
00017 #endif
00018 
00019 #include <vcl_string.h>
00020 #include <vil1/vil1_file_format.h>
00021 #include <vil1/vil1_image_impl.h>
00022 
00023 //: Loader for synthetically gend images
00024 // - vil1_load("gen:640x480:gray,128");
00025 // - vil1_load("gen:640x480:rgb,255,255,255");
00026 class vil1_gen_file_format : public vil1_file_format
00027 {
00028  public:
00029   virtual char const* tag() const;
00030   virtual vil1_image_impl* make_input_image(vil1_stream* vs);
00031   virtual vil1_image_impl* make_output_image(vil1_stream* /*vs*/, int /*planes*/,
00032                                              int /*width*/,
00033                                              int /*height*/,
00034                                              int /*components*/,
00035                                              int /*bits_per_component*/,
00036                                              vil1_component_format /*format*/) { return 0; }
00037 };
00038 
00039 enum vil1_gen_type
00040 {
00041   vil1_gen_gray,
00042   vil1_gen_rgb
00043 };
00044 
00045 //: Generic image implementation for PNM files
00046 class vil1_gen_generic_image : public vil1_image_impl
00047 {
00048   int width_;
00049   int height_;
00050   int components_;
00051   int bits_per_component_;
00052   int type_;
00053   int params_[4];
00054 
00055   friend class vil1_gen_file_format;
00056   void init(vcl_string const & s);
00057 
00058  public:
00059   vil1_gen_generic_image(vcl_string const & s) { init(s); }
00060   vil1_gen_generic_image(vcl_string const & s,
00061                          int planes,
00062                          int width,
00063                          int height,
00064                          int components,
00065                          int bits_per_component,
00066                          vil1_component_format format);
00067   ~vil1_gen_generic_image() {}
00068 
00069   //: Dimensions:  planes x width x height x components
00070   virtual int planes() const { return 1; }
00071   virtual int width() const { return width_; }
00072   virtual int height() const { return height_; }
00073   virtual int components() const { return components_; }
00074 
00075   virtual int bits_per_component() const { return bits_per_component_; }
00076   virtual enum vil1_component_format component_format() const { return VIL1_COMPONENT_FORMAT_UNSIGNED_INT; }
00077 
00078   //: Copy contents of this image to buf
00079   virtual bool get_section(void* buf, int x0, int y0, int width, int height) const;
00080   //: Copy contents of buf to this image
00081   virtual bool put_section(void const* buf, int x0, int y0, int width, int height);
00082 
00083   char const* file_format() const;
00084   bool get_property(char const *tag, void *prop = 0) const;
00085   vil1_image get_plane(unsigned int p) const;
00086 };
00087 
00088 #endif // vil1_gen_file_format_h_

Generated on Sat Nov 22 05:08:28 2008 for core/vil1 by  doxygen 1.5.1