vil_file_format.h
Go to the documentation of this file.
1 // This is core/vil/vil_file_format.h
2 #ifndef vil_file_format_h_
3 #define vil_file_format_h_
4 //:
5 // \file
6 // \brief Base class for image formats
7 // \author awf
8 
9 #include <list>
10 #include <vil/vil_fwd.h> // for vil_stream
11 #include <vil/vil_image_resource.h>
14 
15 //: Base class for image formats.
16 // There is one derived class for each handled file format in the
17 // directory file_formats. E.g. vil/file_formats/vil_pnm.h etc
19 {
20  public:
21  virtual ~vil_file_format();
22 
23  //: Return a character string which uniquely identifies this format.
24  //E.g. "pnm", "jpeg", etc.
25  virtual char const* tag() const = 0;
26 
27  //: Attempt to make a generic_image which will read from vil_stream vs.
28  // Reads enough of vs to determine if it's this format, and if not, returns 0.
29  // If it is, returns a subclass of vil_image_resource on which get_section may
30  // be applied.
32 
33  //: Read a pyramid resource from a list of image files in a directory
34  // ... or from an image file_format that supports multiple images per file.
36  make_input_pyramid_image(char const* /*directory_or_file*/)
37  {return nullptr;}
38 
39  //: Construct a pyramid image resource from a base image.
40  // All levels are stored in the same resource file. Each level has the same
41  // scale ratio (0.5) to the preceding level. Level 0 is the original
42  // base image. The resource is returned open for reading.
43  // The temporary directory is for storing intermediate image
44  // resources during the construction of the pyramid. Files are
45  // be removed from the directory after completion. If temp_dir is 0
46  // then the intermediate resources are created in memory.
48  make_pyramid_image_from_base(char const* /*filename*/,
49  vil_image_resource_sptr const& /*base_image*/,
50  unsigned /*nlevels*/,
51  char const* /*temp_dir*/)
52  {return nullptr;}
53 
55  make_pyramid_image_from_base(char const* directory,
56  vil_image_resource_sptr const& base_image,
57  unsigned int nlevels,
58  bool copy_base,
59  char const* level_file_format,
60  char const* filename) { return nullptr; } ;
61 
62  //: Make a "generic_image" on which put_section may be applied.
63  // The stream vs is assumed to be open for writing, as an image header may be
64  // written to it immediately.
65  // The width/height etc are explicitly specified, so that file_format implementors
66  // know what they need to do...
68  unsigned /*nx*/,
69  unsigned /*ny*/,
70  unsigned /*nplanes*/,
71  enum vil_pixel_format) = 0;
72  //: Construct a blocked output image resource
73  // Returns a null resource unless the format supports blocking
76  unsigned /*nx*/,
77  unsigned /*ny*/,
78  unsigned /*nplanes*/,
79  unsigned /*size_block_i*/,
80  unsigned /* size_block_j*/,
81  enum vil_pixel_format)
82  {return nullptr;}
83 
85  make_pyramid_output_image(char const* /*file*/)
86  {return nullptr;}
87 
88  public:
89  typedef std::list<vil_file_format*>::iterator iterator;
90  static std::list<vil_file_format*>& all();
91  static void add_file_format(vil_file_format* ff);
92 };
93 
94 #endif // vil_file_format_h_
vil_pixel_format
Describes the type of the concrete data.
virtual vil_blocked_image_resource_sptr make_blocked_output_image(vil_stream *, unsigned, unsigned, unsigned, unsigned, unsigned, enum vil_pixel_format)
Construct a blocked output image resource.
virtual vil_pyramid_image_resource_sptr make_input_pyramid_image(char const *)
Read a pyramid resource from a list of image files in a directory.
virtual vil_image_resource_sptr make_input_image(vil_stream *vs)=0
Attempt to make a generic_image which will read from vil_stream vs.
Base class for image formats.
std::list< vil_file_format * >::iterator iterator
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
A blocked representation of the image_resource.
static std::list< vil_file_format * > & all()
Representation of a pyramid resolution hierarchy.
virtual vil_pyramid_image_resource_sptr make_pyramid_output_image(char const *)
static void add_file_format(vil_file_format *ff)
The function will take ownership of ff;.
virtual char const * tag() const =0
Return a character string which uniquely identifies this format.
virtual ~vil_file_format()
virtual vil_pyramid_image_resource_sptr make_pyramid_image_from_base(char const *, vil_image_resource_sptr const &, unsigned, char const *)
Construct a pyramid image resource from a base image.
Representation of a generic image source or destination.
virtual vil_pyramid_image_resource_sptr make_pyramid_image_from_base(char const *directory, vil_image_resource_sptr const &base_image, unsigned int nlevels, bool copy_base, char const *level_file_format, char const *filename)
virtual vil_image_resource_sptr make_output_image(vil_stream *, unsigned, unsigned, unsigned, enum vil_pixel_format)=0
Make a "generic_image" on which put_section may be applied.