vil_pnm.h
Go to the documentation of this file.
1 // This is core/vil/file_formats/vil_pnm.h
2 #ifndef vil_pnm_file_format_h_
3 #define vil_pnm_file_format_h_
4 //:
5 // \file
6 // \author awf@robots.ox.ac.uk
7 // \date 16 Feb 00
8 //
9 // \verbatim
10 // Modifications
11 // 7 June 2001 - Peter Vanroose - made pbm (magic P4) working
12 // 3 October 2001 Peter Vanroose - Implemented get_property("top_row_first")
13 // 20 Sep 2002 Ian Scott - Converted to vil.
14 //\endverbatim
15 
16 #include <vil/vil_image_resource.h>
17 #include <vil/vil_file_format.h>
18 #include <vil/vil_stream.h>
19 
21 
22 
23 //: Loader for PPM,PGM,PBM files
25 {
26  public:
27  char const* tag() const override;
30  unsigned ni,
31  unsigned nj,
32  unsigned nplanes,
33  vil_pixel_format format) override;
34 };
35 
36 //: Alias name for pnm; only tag() differs
38 {
39  public:
40  char const* tag() const override { return "pbm"; }
41 };
42 
43 //: Alias name for pnm; only tag() differs
45 {
46  public:
47  char const* tag() const override { return "pgm"; }
48 };
49 
50 //: Alias name for pnm; only tag() differs
52 {
53  public:
54  char const* tag() const override { return "ppm"; }
55 };
56 
57 //: Generic image implementation for PNM files
59 {
61  int magic_;
62  unsigned ni_;
63  unsigned nj_;
64  unsigned long int maxval_;
65 
67  unsigned ncomponents_;
69 
70  //: Describe the format of each pixel.
72 
73  bool read_header();
74  bool write_header();
75 
76  friend class vil_pnm_file_format;
77 
78  public:
79  vil_pnm_image (vil_stream* is, unsigned ni,
80  unsigned nj, unsigned nplanes,
81  vil_pixel_format format);
83  ~vil_pnm_image() override;
84 
85  // Inherit the documentation from vil_image_resource
86 
87  unsigned nplanes() const override { return ncomponents_; }
88  unsigned ni() const override { return ni_; }
89  unsigned nj() const override { return nj_; }
90 
91  enum vil_pixel_format pixel_format() const override {return format_; }
92 
93  vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
94  unsigned j0, unsigned nj) const override;
95 
96  bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0) override;
97 
98  char const* file_format() const override;
99  bool get_property(char const *tag, void *prop = nullptr) const override;
100 };
101 
102 #endif // vil_pnm_file_format_h_
Stream interface for VIL image loaders.
An abstract base class of smart pointers to actual image data in memory.
vil_pixel_format
Describes the type of the concrete data.
unsigned bits_per_component_
Definition: vil_pnm.h:68
bool get_property(char const *tag, void *prop=nullptr) const override
Extra property information.
Definition: vil_pnm.cxx:80
unsigned ni_
Definition: vil_pnm.h:62
char const * tag() const override
Return a character string which uniquely identifies this format.
Definition: vil_pnm.h:40
vil_streampos start_of_data_
Definition: vil_pnm.h:66
bool write_header()
Definition: vil_pnm.cxx:288
unsigned nj_
Definition: vil_pnm.h:63
char const * file_format() const override
Return a string describing the file format.
Definition: vil_pnm.cxx:92
Base class for image formats.
bool read_header()
This method accepts any valid PNM file (first 3 bytes "P1\n" to "P6\n").
Definition: vil_pnm.cxx:207
Alias name for pnm; only tag() differs.
Definition: vil_pnm.h:37
vil_image_resource_sptr make_output_image(vil_stream *vs, unsigned ni, unsigned nj, unsigned nplanes, vil_pixel_format format) override
Make a "generic_image" on which put_section may be applied.
Definition: vil_pnm.cxx:57
int magic_
Definition: vil_pnm.h:61
unsigned nplanes() const override
Dimensions: Planes x ni x nj.
Definition: vil_pnm.h:87
unsigned ncomponents_
Definition: vil_pnm.h:67
Alias name for pnm; only tag() differs.
Definition: vil_pnm.h:51
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
unsigned ni() const override
Dimensions: Planes x ni x nj.
Definition: vil_pnm.h:88
Loader for PPM,PGM,PBM files.
Definition: vil_pnm.h:24
char const * tag() const override
Return a character string which uniquely identifies this format.
Definition: vil_pnm.h:54
vil_image_resource_sptr make_input_image(vil_stream *vs) override
Attempt to make a generic_image which will read from vil_stream vs.
Definition: vil_pnm.cxx:42
Abstract representation of an image source or image destination.
Generic image implementation for PNM files.
Definition: vil_pnm.h:58
char const * tag() const override
Return a character string which uniquely identifies this format.
Definition: vil_pnm.h:47
char const * tag() const override
Return a character string which uniquely identifies this format.
Definition: vil_pnm.cxx:66
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
unsigned long int maxval_
Definition: vil_pnm.h:64
vil_pnm_image(vil_stream *is, unsigned ni, unsigned nj, unsigned nplanes, vil_pixel_format format)
Definition: vil_pnm.cxx:97
vil_pixel_format format_
Describe the format of each pixel.
Definition: vil_pnm.h:71
Alias name for pnm; only tag() differs.
Definition: vil_pnm.h:44
bool put_view(const vil_image_view_base &im, unsigned i0, unsigned j0) override
Put the data in this view back into the image source.
Definition: vil_pnm.cxx:474
vxl_int_32 vil_streampos
Definition: vil_stream.h:16
Representation of a generic image source or destination.
vil_stream * vs_
Definition: vil_pnm.h:60
unsigned nj() const override
Dimensions: Planes x ni x nj.
Definition: vil_pnm.h:89
Base class for image formats.
enum vil_pixel_format pixel_format() const override
Pixel Format.
Definition: vil_pnm.h:91
~vil_pnm_image() override
Definition: vil_pnm.cxx:145