contrib/mul/vil3d/vil3d_memory_image.h
Go to the documentation of this file.
00001 // This is mul/vil3d/vil3d_memory_image.h
00002 #ifndef vil3d_memory_image_h_
00003 #define vil3d_memory_image_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Ian Scott
00010 
00011 #include <vil3d/vil3d_image_resource.h>
00012 #include <vil3d/vil3d_image_view_base.h>
00013 
00014 //: Generic image implementation for PNM files
00015 // You can't create one of these yourself - use vil3d_new() instead.
00016 class vil3d_memory_image : public vil3d_image_resource
00017 {
00018   //: Management of the memory image is devolved to an internal image_view.
00019   vil3d_image_view_base* view_;
00020 
00021   //: Create an empty memory image.
00022   vil3d_memory_image();
00023 
00024   //: Create an in-memory image of given size and pixel type.
00025   // The pixel type must be scalar.
00026   vil3d_memory_image(unsigned ni, unsigned nj,
00027                      unsigned nk, unsigned nplanes,
00028                      vil_pixel_format format);
00029 
00030   friend vil3d_image_resource_sptr vil3d_new_image_resource(
00031     unsigned ni, unsigned nj, unsigned nk, unsigned nplanes,
00032     vil_pixel_format format);
00033 
00034  public:
00035 
00036 
00037   ~vil3d_memory_image() {delete view_;}
00038 
00039   //: Dimensions:  planes x width x height x components
00040   virtual unsigned nplanes() const { return view_->nplanes(); }
00041   virtual unsigned ni() const { return view_->ni(); }
00042   virtual unsigned nj() const { return view_->nj(); }
00043   virtual unsigned nk() const { return view_->nk(); }
00044 
00045   virtual enum vil_pixel_format pixel_format() const { return view_->pixel_format(); }
00046 
00047   //: Create a read/write view of a copy of this data.
00048   // \return 0 if unable to get view of correct size.
00049   virtual vil3d_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
00050                                                    unsigned j0, unsigned nj,
00051                                                    unsigned k0, unsigned nk) const;
00052 
00053   //: Create a view of this data.
00054   // \return 0 if unable to get view of correct size.
00055   virtual vil3d_image_view_base_sptr get_view(unsigned i0, unsigned ni,
00056                                               unsigned j0, unsigned nj,
00057                                               unsigned k0, unsigned nk) const;
00058 
00059   //: Put the data in this view back into the image source.
00060   virtual bool put_view(const vil3d_image_view_base& im,
00061                         unsigned i0, unsigned j0, unsigned k0);
00062 
00063   bool get_property(char const * /*tag*/, void * /*prop*/ = 0) const {return false;}
00064 };
00065 
00066 #endif // vil3d_memory_image_h_