core/vil1/vil1_copy.cxx

Go to the documentation of this file.
00001 // This is core/vil1/vil1_copy.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \brief Contains function vil1_copy()
00008 // \author Andrew W. Fitzgibbon, Oxford RRG
00009 // \date 16 Feb 00
00010 //
00011 // \verbatim
00012 //  Modifications
00013 //   7 June 2001 - Peter Vanroose - fixed rowsize_bytes for 1-bit pixel type
00014 // \endverbatim
00015 //-----------------------------------------------------------------------------
00016 
00017 #include "vil1_copy.h"
00018 
00019 #include <vcl_cassert.h>
00020 #include <vil1/vil1_image.h>
00021 #include <vil1/vil1_memory_image.h>
00022 
00023 void vil1_copy(vil1_image const& in, vil1_image& out)
00024 {
00025 #define assert_dimension_equal(dim) assert(in.dim() == out.dim())
00026   assert_dimension_equal(height);
00027   assert_dimension_equal(width);
00028   assert_dimension_equal(bits_per_component);
00029   assert_dimension_equal(planes);
00030   assert_dimension_equal(components);
00031 #undef assert_dimension_equal
00032 //assert((in.components() * in.planes()) == (out.components() * out.planes()));
00033 
00034   int height = in.height();
00035   int width = in.width();
00036 
00037   // Simple implementation copies the whole buffer at once
00038   // This is only valid if planes and components are identical,
00039   // not just their product.  Hence the assert above.
00040   unsigned char* buf = new unsigned char[in.get_size_bytes()];
00041 #ifdef DEBUG
00042   vcl_cerr << "...vil1_copy() doing get_section()\n";
00043 #endif
00044   in.get_section(buf, 0, 0, width, height);
00045 #ifdef DEBUG
00046   vcl_cerr << "...vil1_copy() doing put_section()\n";
00047 #endif
00048   out.put_section(buf, 0, 0, width, height);
00049 #ifdef DEBUG
00050   vcl_cerr << "...vil1_copy() done\n";
00051 #endif
00052   delete[] buf;
00053 }
00054 
00055 vil1_memory_image
00056 vil1_copy(vil1_image const& src)
00057 {
00058   vil1_memory_image dst( src.planes(), src.width(), src.height(), src.components(),
00059                          src.bits_per_component(), src.component_format() );
00060   vil1_copy( src, dst );
00061   return dst;
00062 }

Generated on Sat Oct 11 05:08:18 2008 for core/vil1 by  doxygen 1.5.1