core/vil/vil_blocked_image_facade.h
Go to the documentation of this file.
00001 // This is core/vil/vil_blocked_image_facade.h
00002 #ifndef vil_blocked_image_facade_h_
00003 #define vil_blocked_image_facade_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief A blocked image facade for any image resource
00010 // \author J. L. Mundy
00011 //
00012 // this class "wraps" any image resource and provides blocking methods
00013 //
00014 // not used? #include <vcl_vector.h>
00015 #include <vil/vil_blocked_image_resource.h>
00016 
00017 class vil_blocked_image_facade : public vil_blocked_image_resource
00018 {
00019  public:
00020   vil_blocked_image_facade(const vil_image_resource_sptr &src,
00021                            const unsigned sbi=0, const unsigned sbj=0);
00022   virtual ~vil_blocked_image_facade() {}
00023 
00024   inline virtual unsigned nplanes() const
00025   { return src_->nplanes();}
00026   inline virtual unsigned ni() const
00027   { return src_->ni();}
00028   inline virtual unsigned nj() const
00029   { return src_->nj();}
00030   //: Block size in columns
00031   inline virtual unsigned size_block_i() const
00032   { return sbi_;}
00033   //: Block size in rows
00034   inline virtual unsigned size_block_j() const
00035   { return sbj_;}
00036   //: Number of blocks in image width
00037   inline virtual unsigned n_block_i() const
00038   { if (sbi_>0)return (src_->ni()+sbi_-1)/sbi_; return 0; }
00039   //: Number of blocks in image height
00040   inline virtual unsigned n_block_j() const
00041   { if (sbj_>0)return (src_->nj()+sbj_-1)/sbj_; return 0; }
00042 
00043   inline virtual enum vil_pixel_format pixel_format() const
00044   { return src_->pixel_format();}
00045 
00046   inline virtual vil_image_view_base_sptr
00047   get_copy_view(unsigned i0, unsigned n_i, unsigned j0, unsigned n_j) const
00048   { return src_->get_copy_view(i0, n_i, j0, n_j);}
00049 
00050   inline virtual bool put_view(const vil_image_view_base& im,
00051                                unsigned i0, unsigned j0)
00052   { return src_->put_view(im, i0, j0);}
00053 
00054   //: Block access
00055   virtual vil_image_view_base_sptr get_block( unsigned  block_index_i,
00056                                               unsigned  block_index_j ) const;
00057 
00058   //: put the block into the resource at the indicated location
00059   virtual bool put_block(unsigned  block_index_i,
00060                          unsigned  block_index_j,
00061                          const vil_image_view_base& view);
00062 
00063 
00064   //: Extra property information
00065   virtual bool get_property(char const* tag, void* property_value = 0) const;
00066 
00067  protected:
00068   //Internal functions
00069   vil_image_view_base_sptr fill_block(vil_image_view_base_sptr& view) const;
00070 
00071   //:the image resource masquerading as a blocked resource
00072   vil_image_resource_sptr src_;
00073   //:block size in i
00074   unsigned sbi_;
00075   //:block size in j
00076   unsigned sbj_;
00077   vil_blocked_image_facade();//not meaningful
00078 };
00079 
00080 #endif // vil_blocked_image_facade_h_