From: Foster B. <fos...@us...> - 2006-02-03 18:34:24
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6755/adobe/gil/core Modified Files: algorithm.hpp channel.hpp cmyk.hpp color_convert.hpp gil_concept.hpp gil_config.hpp gray.hpp image.hpp image_view_factory.hpp lab.hpp metafunctions.hpp pixel.hpp pixel_iterator.hpp rgb.hpp rgba.hpp typedefs.hpp utilities.hpp variant.hpp Log Message: asl 1.0.13 Index: image.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/gil/core/image.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** image.hpp 24 Jan 2006 19:38:49 -0000 1.2 --- image.hpp 3 Feb 2006 18:33:37 -0000 1.3 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ *************** *** 11,18 **** //////////////////////////////////////////////////////////////////////////////////////// ! /// \file /// \brief Templated image /// \author Lubomir Bourdev and Hailin Jin \n ! /// Adobe Systems Incorporated /// /// --- 11,18 ---- //////////////////////////////////////////////////////////////////////////////////////// ! /// \file /// \brief Templated image /// \author Lubomir Bourdev and Hailin Jin \n ! /// Adobe Systems Incorporated /// /// *************** *** 29,37 **** #ifdef _MSC_VER #pragma warning(push) ! #pragma warning(disable : 4244) // conversion from 'gil::image<V,ALLOC>::coord_type' to 'int', possible loss of data (visual studio compiler doesn't realize that the two types are the same) #endif //////////////////////////////////////////////////////////////////////////////////////// ! /// \class image_view /// \ingroup ImageView /// \brief A lightweight object that interprets memory as a 2D array of pixels. --- 29,37 ---- #ifdef _MSC_VER #pragma warning(push) ! #pragma warning(disable : 4244) // conversion from 'gil::image<V,ALLOC>::coord_type' to 'int', possible loss of data (visual studio compiler doesn't realize that the two types are the same) #endif //////////////////////////////////////////////////////////////////////////////////////// ! /// \class image_view /// \ingroup ImageView /// \brief A lightweight object that interprets memory as a 2D array of pixels. *************** *** 60,175 **** template <typename LOC> class pixel_image_iterator; ! template <typename LOC> // Models 2D Pixel Locator class image_view { ! GIL_CLASS_REQUIRE(LOC, GIL, PixelLocatorConcept); public: // typedefs required by ConstRandomAccessNDImageViewConcept ! static const size_t num_dimensions=2; ! typedef typename LOC::value_type value_type; ! typedef typename LOC::reference reference; // result of dereferencing ! typedef typename LOC::coord_type coord_type; // 1D difference type (same for all dimensions) ! typedef coord_type difference_type; // result of operator-(1d_iterator,1d_iterator) ! typedef value_type domain_type; ! typedef typename LOC::point_type point_type; ! typedef LOC locator; ! typedef image_view<typename LOC::const_type> const_type; // same as this type, but over const values ! template <size_t D> struct axis { ! typedef typename LOC::template axis<D>::coord_type coord_type; // difference_type along each dimension ! typedef typename LOC::template axis<D>::iterator iterator; // 1D iterator type along each dimension ! }; ! typedef pixel_image_iterator<LOC> iterator; // 1D iterator type for each pixel left-to-right inside top-to-bottom ! typedef std::reverse_iterator<iterator> reverse_iterator; ! typedef size_t size_type; // typedefs required by ConstRandomAccess2DImageViewConcept ! typedef locator xy_locator; ! typedef typename xy_locator::x_iterator x_iterator; // pixel iterator along a row ! typedef typename xy_locator::y_iterator y_iterator; // pixel iterator along a column ! typedef typename xy_locator::x_coord_type x_coord_type; ! typedef typename xy_locator::y_coord_type y_coord_type; // typedefs required by ConstRandomAccess2DImageViewConcept ! typedef image_view<typename LOC::dynamic_step_type> dynamic_step_type; ! typedef typename LOC::channel_type channel_type; // type of the channel of a pixel ! typedef typename LOC::color_space_type color_space_type;// tag indicating the color space of an image ! image_view() : _dimensions(0,0) {} ! template <typename VIEW> image_view(const VIEW& iv) : _dimensions(iv.dimensions()), _pixels(iv.pixels()) {} ! template <typename L2> image_view(const point_type& sz , const L2& loc) : _dimensions(sz), _pixels(loc) {} ! template <typename L2> image_view(coord_type width, coord_type height, const L2& loc) : _dimensions(x_coord_type(width),y_coord_type(height)), _pixels(loc) {} ! image_view(const point_type& sz , const x_iterator& x_it, coord_type row_bytes) : _dimensions(sz), _pixels(x_it, row_bytes) {} ! image_view(coord_type width, coord_type height, const x_iterator& x_it, coord_type row_bytes) : _dimensions(x_coord_type(width),y_coord_type(height)), _pixels(x_it, row_bytes) {} ! template <typename VIEW> image_view& operator=(const VIEW& iv) { _pixels=iv.pixels(); _dimensions=iv.dimensions(); return *this; } ! image_view& operator=(const image_view& iv) { _pixels=iv.pixels(); _dimensions=iv.dimensions(); return *this; } ! template <typename VIEW> bool operator==(const VIEW& v) const { return pixels()==v.pixels() && dimensions()==v.dimensions(); } ! template <typename VIEW> bool operator!=(const VIEW& v) const { return !(*this==v); } ! template <typename L2> friend void swap(image_view<L2>& x, image_view<L2>& y); ! const point_type& dimensions() const { return _dimensions; } ! const locator& pixels() const { return _pixels; } ! x_coord_type width() const { return dimensions().x; } ! y_coord_type height() const { return dimensions().y; } ! difference_type row_bytes() const { return _pixels.row_bytes(); } // number of bytes per row ! difference_type pix_bytestep() const { return _pixels.pix_bytestep(); } // number of bytes between two adjacent pixels on the same row ! //\{@ ! /// \name 1D navigation ! size_type size() const { return width()*height(); } ! iterator begin() const { return iterator(_pixels,_dimensions.x); } ! iterator end() const { return begin()+size(); } // potential performance problem! ! reverse_iterator rbegin() const { return reverse_iterator(end()); } ! reverse_iterator rend() const { return reverse_iterator(begin()); } ! reference operator[](difference_type i) const { return begin()[i]; } // potential performance problem! ! iterator at(const point_type& p)const { return begin()+p.y*width()+p.x; } ! iterator at(x_coord_type x, y_coord_type y)const { return begin()+y*width()+x; } ! //\}@ ! //\{@ ! /// \name 2-D navigation ! reference operator()(const point_type& p) const { return _pixels(p.x,p.y); } ! reference operator()(x_coord_type x, y_coord_type y)const { return _pixels(x,y); } ! template <size_t D> typename axis<D>::iterator axis_iterator(const point_type& p) const { return _pixels.axis_iterator<D>(p); } ! xy_locator xy_at(x_coord_type x, y_coord_type y) const { return _pixels+point_type(x_coord_type(x),y_coord_type(y)); } ! locator xy_at(const point_type& p) const { return _pixels+p; } ! //\}@ ! //\{@ ! /// \name X navigation ! x_iterator x_at(x_coord_type x, y_coord_type y) const { return _pixels.x_at(x,y); } ! x_iterator x_at(const point_type& p) const { return _pixels.x_at(p); } ! x_iterator row_begin(y_coord_type y) const { return x_at(0,y); } ! x_iterator row_end(y_coord_type y) const { return x_at(width(),y); } ! //\}@ ! //\{@ ! /// \name Y navigation ! y_iterator y_at(x_coord_type x, y_coord_type y) const { return xy_at(x,y).y(); } ! y_iterator y_at(const point_type& p) const { return xy_at(p).y(); } ! y_iterator col_begin(x_coord_type x) const { return y_at(x,0); } ! y_iterator col_end(x_coord_type x) const { return y_at(x,height()); } ! //\}@ private: ! template <typename L2> friend class image_view; ! point_type _dimensions; ! xy_locator _pixels; }; template <typename L2> inline void swap(image_view<L2>& x, image_view<L2>& y) { ! std::swap(x._dimensions,y._dimensions); ! std::swap(x._pixels, y._pixels); // TODO: Extend further } //////////////////////////////////////////////////////////////////////////////////////// ! /// \class image /// \ingroup Image /// \brief container interface over image view --- 60,175 ---- template <typename LOC> class pixel_image_iterator; ! template <typename LOC> // Models 2D Pixel Locator class image_view { ! GIL_CLASS_REQUIRE(LOC, GIL, PixelLocatorConcept); public: // typedefs required by ConstRandomAccessNDImageViewConcept ! static const std::size_t num_dimensions=2; ! typedef typename LOC::value_type value_type; ! typedef typename LOC::reference reference; // result of dereferencing ! typedef typename LOC::coord_type coord_type; // 1D difference type (same for all dimensions) ! typedef coord_type difference_type; // result of operator-(1d_iterator,1d_iterator) ! typedef value_type domain_type; ! typedef typename LOC::point_type point_type; ! typedef LOC locator; ! typedef image_view<typename LOC::const_type> const_type; // same as this type, but over const values ! template <std::size_t D> struct axis { ! typedef typename LOC::template axis<D>::coord_type coord_type; // difference_type along each dimension ! typedef typename LOC::template axis<D>::iterator iterator; // 1D iterator type along each dimension ! }; ! typedef pixel_image_iterator<LOC> iterator; // 1D iterator type for each pixel left-to-right inside top-to-bottom ! typedef std::reverse_iterator<iterator> reverse_iterator; ! typedef size_t size_type; // typedefs required by ConstRandomAccess2DImageViewConcept ! typedef locator xy_locator; ! typedef typename xy_locator::x_iterator x_iterator; // pixel iterator along a row ! typedef typename xy_locator::y_iterator y_iterator; // pixel iterator along a column ! typedef typename xy_locator::x_coord_type x_coord_type; ! typedef typename xy_locator::y_coord_type y_coord_type; // typedefs required by ConstRandomAccess2DImageViewConcept ! typedef image_view<typename LOC::dynamic_step_type> dynamic_step_type; ! typedef typename LOC::channel_type channel_type; // type of the channel of a pixel ! typedef typename LOC::color_space_type color_space_type;// tag indicating the color space of an image ! image_view() : _dimensions(0,0) {} ! template <typename VIEW> image_view(const VIEW& iv) : _dimensions(iv.dimensions()), _pixels(iv.pixels()) {} ! template <typename L2> image_view(const point_type& sz , const L2& loc) : _dimensions(sz), _pixels(loc) {} ! template <typename L2> image_view(coord_type width, coord_type height, const L2& loc) : _dimensions(x_coord_type(width),y_coord_type(height)), _pixels(loc) {} ! image_view(const point_type& sz , const x_iterator& x_it, coord_type row_bytes) : _dimensions(sz), _pixels(x_it, row_bytes) {} ! image_view(coord_type width, coord_type height, const x_iterator& x_it, coord_type row_bytes) : _dimensions(x_coord_type(width),y_coord_type(height)), _pixels(x_it, row_bytes) {} ! template <typename VIEW> image_view& operator=(const VIEW& iv) { _pixels=iv.pixels(); _dimensions=iv.dimensions(); return *this; } ! image_view& operator=(const image_view& iv) { _pixels=iv.pixels(); _dimensions=iv.dimensions(); return *this; } ! template <typename VIEW> bool operator==(const VIEW& v) const { return pixels()==v.pixels() && dimensions()==v.dimensions(); } ! template <typename VIEW> bool operator!=(const VIEW& v) const { return !(*this==v); } ! template <typename L2> friend void swap(image_view<L2>& x, image_view<L2>& y); ! const point_type& dimensions() const { return _dimensions; } ! const locator& pixels() const { return _pixels; } ! x_coord_type width() const { return dimensions().x; } ! y_coord_type height() const { return dimensions().y; } ! difference_type row_bytes() const { return _pixels.row_bytes(); } // number of bytes per row ! difference_type pix_bytestep() const { return _pixels.pix_bytestep(); } // number of bytes between two adjacent pixels on the same row ! //\{@ ! /// \name 1D navigation ! size_type size() const { return width()*height(); } ! iterator begin() const { return iterator(_pixels,_dimensions.x); } ! iterator end() const { return begin()+size(); } // potential performance problem! ! reverse_iterator rbegin() const { return reverse_iterator(end()); } ! reverse_iterator rend() const { return reverse_iterator(begin()); } ! reference operator[](difference_type i) const { return begin()[i]; } // potential performance problem! ! iterator at(const point_type& p)const { return begin()+p.y*width()+p.x; } ! iterator at(x_coord_type x, y_coord_type y)const { return begin()+y*width()+x; } ! //\}@ ! //\{@ ! /// \name 2-D navigation ! reference operator()(const point_type& p) const { return _pixels(p.x,p.y); } ! reference operator()(x_coord_type x, y_coord_type y)const { return _pixels(x,y); } ! template <std::size_t D> typename axis<D>::iterator axis_iterator(const point_type& p) const { return _pixels.axis_iterator<D>(p); } ! xy_locator xy_at(x_coord_type x, y_coord_type y) const { return _pixels+point_type(x_coord_type(x),y_coord_type(y)); } ! locator xy_at(const point_type& p) const { return _pixels+p; } ! //\}@ ! //\{@ ! /// \name X navigation ! x_iterator x_at(x_coord_type x, y_coord_type y) const { return _pixels.x_at(x,y); } ! x_iterator x_at(const point_type& p) const { return _pixels.x_at(p); } ! x_iterator row_begin(y_coord_type y) const { return x_at(0,y); } ! x_iterator row_end(y_coord_type y) const { return x_at(width(),y); } ! //\}@ ! //\{@ ! /// \name Y navigation ! y_iterator y_at(x_coord_type x, y_coord_type y) const { return xy_at(x,y).y(); } ! y_iterator y_at(const point_type& p) const { return xy_at(p).y(); } ! y_iterator col_begin(x_coord_type x) const { return y_at(x,0); } ! y_iterator col_end(x_coord_type x) const { return y_at(x,height()); } ! //\}@ private: ! template <typename L2> friend class image_view; ! point_type _dimensions; ! xy_locator _pixels; }; template <typename L2> inline void swap(image_view<L2>& x, image_view<L2>& y) { ! std::swap(x._dimensions,y._dimensions); ! std::swap(x._pixels, y._pixels); // TODO: Extend further } //////////////////////////////////////////////////////////////////////////////////////// ! /// \class image /// \ingroup Image /// \brief container interface over image view *************** *** 181,297 **** template <typename V2,typename ALLOC2> void swap(image<V2,ALLOC2>& im1,image<V2,ALLOC2>& im2); ! template <typename V, typename ALLOC=std::allocator<unsigned char> > class image { public: ! typedef ALLOC allocator_type; ! typedef V view_type; ! typedef typename view_type::const_type const_view_type; ! typedef typename view_type::point_type point_type; ! typedef typename view_type::coord_type coord_type; ! typedef coord_type x_coord_type; ! typedef coord_type y_coord_type; ! typedef typename view_type::iterator iterator; ! typedef iterator pointer; ! typedef typename const_view_type::iterator const_iterator; ! typedef const_iterator const_pointer; ! typedef typename view_type::difference_type difference_type; ! typedef typename view_type::value_type value_type; ! typedef typename view_type::reference reference; ! typedef typename const_view_type::reference const_reference; ! typedef typename view_type::size_type size_type; ! typedef typename view_type::reverse_iterator reverse_iterator; ! typedef typename const_view_type::reverse_iterator const_reverse_iterator; ! ! const_iterator begin() const { return const_view(*this).begin(); } ! const_iterator end() const { return const_view(*this).end(); } ! const_reverse_iterator rbegin() const { return const_view(*this).rbegin(); } ! const_reverse_iterator rend() const { return const_view(*this).rend(); } ! iterator begin() { return _view.begin(); } ! iterator end() { return _view.end(); } ! reverse_iterator rbegin() { return _view.rbegin(); } ! reverse_iterator rend() { return _view.rend(); } ! reference operator[](size_type i) { return _view[i]; } ! const_reference operator[](size_type i) const { return const_view(*this)[i]; } // Warning: Slow!! ! size_type size() const { return _view.size(); } ! size_type max_size() const { return size(); } ! bool empty() const { return size()==0; } ! const point_type& dimensions() const { return _view.dimensions(); } ! x_coord_type width() const { return _view.width(); } ! y_coord_type height() const { return _view.height(); } ! image() {} ! // image that allocates own data. Calls new/delete[] ! image(const point_type& dimensions, unsigned int alignment=1) { create_with_own_data(dimensions,alignment); } ! image(x_coord_type width, y_coord_type height, unsigned int alignment=1) { create_with_own_data(point_type(width,height),alignment); } ! image(const image& img) : _alloc(img._alloc) { ! create_with_own_data(const_view(img).dimensions()); // TODO: Use the same alignment ! copy_pixels(const_view(img),_view); } template <typename V2,typename ALLOC2> image(const image<V2,ALLOC2>& img) :_alloc(img._alloc) { ! create_with_own_data(view(img).dimensions()); ! copy_pixels(view(img),_view); } ! template <typename IMG> image& operator=(const IMG& img) { image tmp(img); swap(tmp); return *this; } ! image& operator=(const image& img) { image tmp(img); swap(tmp); return *this; } ! ~image() { ! size_t size_in_bytes=_view.row_bytes()*_view.height(); if(std::iterator_traits<typename V::x_iterator>::is_planar) ! size_in_bytes*=V::color_space_type::num_channels; _alloc.deallocate((unsigned char*)&(_view(0,0)[0]),size_in_bytes); } ! template <typename V2, typename ALLOC2> friend const V2& view(image<V2,ALLOC2>& img); ! template <typename V2, typename ALLOC2> friend const typename V2::const_type& const_view(const image<V2,ALLOC2>& img); ! ALLOC& allocator() { return _alloc; } ! ALLOC const& allocator() const { return _alloc; } ! template <typename V2,typename ALLOC2> ! friend void swap(image<V2,ALLOC2>& im1,image<V2,ALLOC2>& im2); ! void swap(image& img) { GIL::swap(*this,img); } // required by boost::MutableContainerConcept private: ! view_type _view; // contains pointer to the pixels, the image size and ways to navigate pixels allocator_type _alloc; template <bool> class is_planar {}; ! void create_with_own_data(const point_type& dimensions, unsigned int alignment=1) { ! BOOST_STATIC_ASSERT(!has_dynamic_step<typename V::x_iterator>::value); ! create_with_own_data_(dimensions,alignment,is_planar<std::iterator_traits<typename V::x_iterator>::is_planar>()); ! } ! void create_with_own_data_(const point_type& dimensions, unsigned int alignment, is_planar<false>) { ! size_t rowsize_in_bytes=get_aligned(dimensions.x*sizeof(typename V::value_type),alignment); unsigned char* tmp=_alloc.allocate(rowsize_in_bytes*dimensions.y); ! try { ! _view=V(dimensions,typename V::x_iterator(tmp),rowsize_in_bytes); ! } catch(...) { ! _alloc.deallocate(tmp, rowsize_in_bytes*dimensions.y); ! throw; ! } ! } void create_with_own_data_(const point_type& dimensions, unsigned int alignment, is_planar<true>) { ! size_t planesize_in_bytes=get_aligned(dimensions.x*dimensions.y*sizeof(typename V::channel_type),alignment); ! size_t image_size_in_bytes=planesize_in_bytes*V::color_space_type::num_channels; ! unsigned char* tmp=_alloc.allocate(image_size_in_bytes); ! try { ! _view=V(dimensions, typename V::x_iterator(tmp,planesize_in_bytes),dimensions.x*sizeof(typename V::channel_type)); ! } catch(...) { ! _alloc.deallocate(tmp, image_size_in_bytes); ! throw; ! } } --- 181,297 ---- template <typename V2,typename ALLOC2> void swap(image<V2,ALLOC2>& im1,image<V2,ALLOC2>& im2); ! template <typename V, typename ALLOC=std::allocator<unsigned char> > class image { public: ! typedef ALLOC allocator_type; ! typedef V view_type; ! typedef typename view_type::const_type const_view_type; ! typedef typename view_type::point_type point_type; ! typedef typename view_type::coord_type coord_type; ! typedef coord_type x_coord_type; ! typedef coord_type y_coord_type; ! typedef typename view_type::iterator iterator; ! typedef iterator pointer; ! typedef typename const_view_type::iterator const_iterator; ! typedef const_iterator const_pointer; ! typedef typename view_type::difference_type difference_type; ! typedef typename view_type::value_type value_type; ! typedef typename view_type::reference reference; ! typedef typename const_view_type::reference const_reference; ! typedef typename view_type::size_type size_type; ! typedef typename view_type::reverse_iterator reverse_iterator; ! typedef typename const_view_type::reverse_iterator const_reverse_iterator; ! ! const_iterator begin() const { return const_view(*this).begin(); } ! const_iterator end() const { return const_view(*this).end(); } ! const_reverse_iterator rbegin() const { return const_view(*this).rbegin(); } ! const_reverse_iterator rend() const { return const_view(*this).rend(); } ! iterator begin() { return _view.begin(); } ! iterator end() { return _view.end(); } ! reverse_iterator rbegin() { return _view.rbegin(); } ! reverse_iterator rend() { return _view.rend(); } ! reference operator[](size_type i) { return _view[i]; } ! const_reference operator[](size_type i) const { return const_view(*this)[i]; } // Warning: Slow!! ! size_type size() const { return _view.size(); } ! size_type max_size() const { return size(); } ! bool empty() const { return size()==0; } ! const point_type& dimensions() const { return _view.dimensions(); } ! x_coord_type width() const { return _view.width(); } ! y_coord_type height() const { return _view.height(); } ! image() {} ! // image that allocates own data. Calls new/delete[] ! image(const point_type& dimensions, unsigned int alignment=1) { create_with_own_data(dimensions,alignment); } ! image(x_coord_type width, y_coord_type height, unsigned int alignment=1) { create_with_own_data(point_type(width,height),alignment); } ! image(const image& img) : _alloc(img._alloc) { ! create_with_own_data(const_view(img).dimensions()); // TODO: Use the same alignment ! copy_pixels(const_view(img),_view); } template <typename V2,typename ALLOC2> image(const image<V2,ALLOC2>& img) :_alloc(img._alloc) { ! create_with_own_data(view(img).dimensions()); ! copy_pixels(view(img),_view); } ! template <typename IMG> image& operator=(const IMG& img) { image tmp(img); swap(tmp); return *this; } ! image& operator=(const image& img) { image tmp(img); swap(tmp); return *this; } ! ~image() { ! std::size_t size_in_bytes=_view.row_bytes()*_view.height(); if(std::iterator_traits<typename V::x_iterator>::is_planar) ! size_in_bytes*=V::color_space_type::num_channels; _alloc.deallocate((unsigned char*)&(_view(0,0)[0]),size_in_bytes); } ! template <typename V2, typename ALLOC2> friend const V2& view(image<V2,ALLOC2>& img); ! template <typename V2, typename ALLOC2> friend const typename V2::const_type& const_view(const image<V2,ALLOC2>& img); ! ALLOC& allocator() { return _alloc; } ! ALLOC const& allocator() const { return _alloc; } ! template <typename V2,typename ALLOC2> ! friend void swap(image<V2,ALLOC2>& im1,image<V2,ALLOC2>& im2); ! void swap(image& img) { GIL::swap(*this,img); } // required by boost::MutableContainerConcept private: ! view_type _view; // contains pointer to the pixels, the image size and ways to navigate pixels allocator_type _alloc; template <bool> class is_planar {}; ! void create_with_own_data(const point_type& dimensions, unsigned int alignment=1) { ! BOOST_STATIC_ASSERT(!has_dynamic_step<typename V::x_iterator>::value); ! create_with_own_data_(dimensions,alignment,is_planar<std::iterator_traits<typename V::x_iterator>::is_planar>()); ! } ! void create_with_own_data_(const point_type& dimensions, unsigned int alignment, is_planar<false>) { ! std::size_t rowsize_in_bytes=get_aligned(dimensions.x*sizeof(typename V::value_type),alignment); unsigned char* tmp=_alloc.allocate(rowsize_in_bytes*dimensions.y); ! try { ! _view=V(dimensions,typename V::x_iterator(tmp),rowsize_in_bytes); ! } catch(...) { ! _alloc.deallocate(tmp, rowsize_in_bytes*dimensions.y); ! throw; ! } ! } void create_with_own_data_(const point_type& dimensions, unsigned int alignment, is_planar<true>) { ! std::size_t planesize_in_bytes=get_aligned(dimensions.x*dimensions.y*sizeof(typename V::channel_type),alignment); ! std::size_t image_size_in_bytes=planesize_in_bytes*V::color_space_type::num_channels; ! unsigned char* tmp=_alloc.allocate(image_size_in_bytes); ! try { ! _view=V(dimensions, typename V::x_iterator(tmp,planesize_in_bytes),dimensions.x*sizeof(typename V::channel_type)); ! } catch(...) { ! _alloc.deallocate(tmp, image_size_in_bytes); ! throw; ! } } *************** *** 302,306 **** if (&im1==&im2) return true; if (const_view(im1).dimensions()!=const_view(im2).dimensions()) return false; ! return std::equal(const_view(im1).begin(),const_view(im1).end(),const_view(im2).begin()); // TODO: change this to equal_pixels (for performance) } template <typename V1,typename V2> --- 302,306 ---- if (&im1==&im2) return true; if (const_view(im1).dimensions()!=const_view(im2).dimensions()) return false; ! return std::equal(const_view(im1).begin(),const_view(im1).end(),const_view(im2).begin()); // TODO: change this to equal_pixels (for performance) } template <typename V1,typename V2> *************** *** 309,340 **** template <typename V2,typename ALLOC2> inline void swap(image<V2,ALLOC2>& im1,image<V2,ALLOC2>& im2) { ! swap(im1._view, im2._view); ! std::swap(im1.allocator(), im2.allocator()); } template <typename C> class variant; namespace detail { ! template <typename VC> // Models View Concept Space ! struct any_image_get_view { ! typedef variant<VC> result_type; ! template <typename V> result_type operator()( image<V>& img) const { return result_type(view(img)); } ! }; ! template <typename VC> // Models ConstView Concept Space ! struct any_image_get_const_view { ! typedef variant<VC> result_type; ! template <typename V> result_type operator()(const image<V>& img) const { return result_type(const_view(img)); } ! }; ! struct any_image_view_get_num_channels { ! typedef int result_type; ! template <typenam... [truncated message content] |