vil_image_resource_plugin.h
Go to the documentation of this file.
1 // This is core/vil/vil_image_resource_plugin.h
2 #ifndef vil_image_resource_plugin_h_
3 #define vil_image_resource_plugin_h_
4 //:
5 // \file
6 // \brief Interface for loading new image formats
7 //
8 // This class provides an interface for loading images in new formats
9 // \author Franck Bettinger
10 // \date Sun Mar 17 22:57:00 2002
11 
12 #include <string>
13 #ifdef _MSC_VER
14 # include <vcl_msvc_warnings.h>
15 #endif
17 #include <vil/vil_image_resource.h>
18 
19 //=======================================================================
20 
21 //: A base class for a plugin for vil images loading
22 // This class provides an interface for loading images in new formats
23 
25 {
26  public:
27 
28  //: Default constructor
30 
31  //: Destructor
32  ~vil_image_resource_plugin() override = default;
33 
34  //: Name of the class
35  virtual std::string is_a() const { return "vil_image_resource_plugin"; }
36 
38 
39  unsigned ni() const override { return 0; }
40  unsigned nj() const override { return 0; }
41  unsigned nplanes() const override { return 0; }
42 
43  bool get_property(char const * /*tag*/, void * /*property_value*/=nullptr) const override { return false; }
44  vil_image_view_base_sptr get_copy_view(unsigned /*i0*/, unsigned /*ni*/, unsigned /*j0*/, unsigned /*nj*/) const override
45  { return vil_image_view_base_sptr(nullptr); }
46 
47  bool put_view(vil_image_view_base const& /*im*/, unsigned /*i0*/, unsigned /*j0*/) override { return false; }
48 
49  //: Attempt to load image from named file.
50  // \return true if successful
51  virtual bool load_the_image(vil_image_view_base_sptr& image, const std::string & path)
52  { return load_the_image(image,path,filetype_,colour_); }
53 
54  //: Attempt to load image from named file.
55  // \param filetype String hinting at what image format is
56  // \param colour define whether to load images as colour or grey-scale.
57  // Options are '' (i.e. rely on image), 'Grey' or 'RGB'
58  // \return true if successful
59  virtual bool load_the_image(vil_image_view_base_sptr& image,
60  const std::string & path,
61  const std::string & filetype,
62  const std::string & colour);
63 
64  //: Register a vil_image_resource_plugin to the list of plugins
65  static void register_plugin(vil_image_resource_plugin* plugin);
66 
67  //: Delete all registered plugins
68  static void delete_all_plugins();
69 
70  //: Set the desired image size
71  virtual void set_size(int width, int height) { width_=width; height_=height; }
72 
73  //: Check whether a filename is a potential candidate for loading and if it is available.
74  virtual bool can_be_loaded(const std::string& filename);
75 
76  //: Set the colour options
77  void set_colour(const std::string& colour) { colour_=colour; }
78 
79  //: Set the filetype options
80  void set_filetype(const std::string& filetype) { filetype_=filetype; }
81 
82  protected:
83 
84  //: file type
85  std::string filetype_;
86 
87  //: colour
88  std::string colour_;
89 
91  unsigned int ni_;
92  unsigned int nj_;
93  unsigned int nplanes_;
94  int width_;
95  int height_;
96 };
97 
98 #endif // vil_image_resource_plugin_h_
An abstract base class of smart pointers to actual image data in memory.
vil_pixel_format
Describes the type of the concrete data.
vil_smart_ptr< vil_image_view_base > vil_image_view_base_sptr
Definition: vil_fwd.h:18
unsigned nplanes() const override
Dimensions: Planes x ni x nj.
static void register_plugin(vil_image_resource_plugin *plugin)
Register a vil_image_resource_plugin to the list of plugins.
~vil_image_resource_plugin() override=default
Destructor.
A base class reference-counting view of some image data.
unsigned nj() const override
Dimensions: Planes x ni x nj.
virtual bool can_be_loaded(const std::string &filename)
Check whether a filename is a potential candidate for loading and if it is available.
unsigned ni() const override
Dimensions: Planes x ni x nj.
vil_image_resource_plugin()
Default constructor.
vil_image_view_base_sptr get_copy_view(unsigned, unsigned, unsigned, unsigned) const override
Create a read/write view of a copy of this data.
virtual std::string is_a() const
Name of the class.
bool put_view(vil_image_view_base const &, unsigned, unsigned) override
Put the data in this view back into the image source.
virtual bool load_the_image(vil_image_view_base_sptr &image, const std::string &path)
Attempt to load image from named file.
Abstract representation of an image source or image destination.
void set_filetype(const std::string &filetype)
Set the filetype options.
void set_colour(const std::string &colour)
Set the colour options.
vil_pixel_format pixel_format() const override
Pixel Format.
bool get_property(char const *, void *=nullptr) const override
Extra property information.
static void delete_all_plugins()
Delete all registered plugins.
Representation of a generic image source or destination.
virtual void set_size(int width, int height)
Set the desired image size.
A base class for a plugin for vil images loading.