vil_memory_image.h
Go to the documentation of this file.
1 // This is core/vil/vil_memory_image.h
2 #ifndef vil_memory_image_h_
3 #define vil_memory_image_h_
4 //:
5 // \file
6 // \author Ian Scott
7 // \verbatim
8 // Modifications
9 // Peter Vanroose - 21 Aug.2003 - support added for _RGB_, _RGBA_ and _COMPLEX_ pixel_formats
10 // \endverbatim
11 
12 #include <cstring>
13 #include <vil/vil_image_resource.h>
15 #include <vil/vil_property.h>
16 #ifdef _MSC_VER
17 # include <vcl_msvc_warnings.h>
18 #endif
19 
20 //: Generic image implementation for PNM files
21 // You can't create one of these yourself - use vil_new_image_resource() instead.
23 {
24  //: Management of the memory image is devolved to an internal image_view.
26 
27  //: Create an empty memory image.
29 
30  //: Create an in-memory image of given size and pixel type.
31  // If not interleaved, pixel type must be scalar or nplanes must be 1.
32  // If n_interleaved_planes is not 1, pixel type must be scalar,
33  // and n_planes must be 1.
34  vil_memory_image(unsigned ni,
35  unsigned nj,
36  unsigned nplanes,
37  vil_pixel_format format,
38  unsigned n_interleaved_planes = 1);
39 
40  //: Create a wrapper around the given image_view
42 
43 
45  unsigned ni, unsigned nj, unsigned nplanes,
46  vil_pixel_format format);
47 
49  unsigned ni, unsigned nj, unsigned nplanes,
50  vil_pixel_format format);
51 
53  vil_image_view_base const & view);
54 
55  public:
56 
57  ~vil_memory_image() override {delete view_;}
58 
59  //: Dimensions: planes x width x height x components
60  unsigned nplanes() const override { return view_->nplanes(); }
61  unsigned ni() const override { return view_->ni(); }
62  unsigned nj() const override { return view_->nj(); }
63 
64  enum vil_pixel_format pixel_format() const override { return view_->pixel_format(); }
65 
66  //: Create a read/write view of a copy of this data.
67  // \return 0 if unable to get view of correct size.
68  vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
69  unsigned j0, unsigned nj) const override;
70 
71  //: Create a view of this data.
72  // \return 0 if unable to get view of correct size.
73  vil_image_view_base_sptr get_view(unsigned i0, unsigned ni,
74  unsigned j0, unsigned nj) const override;
75 
76  //: Put the data in this view back into the image source.
77  bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0) override;
78 
79  //: Declare that this is an in-memory image which is not read-only
80  bool get_property(char const * tag, void * prop = nullptr) const override
81  {
82  if (0==std::strcmp(tag, vil_property_memory))
83  return prop ? (*static_cast<bool*>(prop)) = true : true;
84 
85  return false;
86  }
87 };
88 
89 #endif // vil_memory_image_h_
bool get_property(char const *tag, void *prop=nullptr) const override
Declare that this is an in-memory image which is not read-only.
An abstract base class of smart pointers to actual image data in memory.
vil_pixel_format
Describes the type of the concrete data.
friend vil_image_resource_sptr vil_new_image_resource(unsigned ni, unsigned nj, unsigned nplanes, vil_pixel_format format)
Make a new image of given format.
Definition: vil_new.cxx:32
#define vil_property_memory
Indicate whether this is an in-memory image or an on-disk image.
Definition: vil_property.h:40
A base class reference-counting view of some image data.
unsigned nplanes() const override
Dimensions: planes x width x height x components.
unsigned ni() const override
Dimensions: Planes x ni x nj.
friend vil_image_resource_sptr vil_new_image_resource_interleaved(unsigned ni, unsigned nj, unsigned nplanes, vil_pixel_format format)
Make a new image of given format with interleaved planes.
Definition: vil_new.cxx:44
vil_image_view_base * view_
Management of the memory image is devolved to an internal image_view.
unsigned ni() const
Width.
unsigned nj() const
Height.
virtual enum vil_pixel_format pixel_format() const =0
Return a description of the concrete data pixel type.
Generic image implementation for PNM files.
~vil_memory_image() override
Abstract representation of an image source or image destination.
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
There is no class or function called vil_property.
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.
unsigned nplanes() const
Number of planes.
friend vil_image_resource_sptr vil_new_image_resource_of_view(vil_image_view_base const &view)
Make a new image resource that is a wrapper on an existing view's data.
Definition: vil_new.cxx:62
Representation of a generic image source or destination.
unsigned nj() const override
Dimensions: Planes x ni x nj.
enum vil_pixel_format pixel_format() const override
Pixel Format.
vil_image_view_base_sptr get_view() const
Create a read/write view of all the data.
vil_memory_image()
Create an empty memory image.