|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r84050 - trunk/boost/gil
From: chhenning_at_[hidden]
Date: 2013-04-25 20:50:47
Author: chhenning
Date: 2013-04-25 20:50:47 EDT (Thu, 25 Apr 2013)
New Revision: 84050
URL: http://svn.boost.org/trac/boost/changeset/84050
Log:
fixed a merging issue.
Text files modified:
trunk/boost/gil/image.hpp | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
Modified: trunk/boost/gil/image.hpp
==============================================================================
--- trunk/boost/gil/image.hpp (original)
+++ trunk/boost/gil/image.hpp 2013-04-25 20:50:47 EDT (Thu, 25 Apr 2013)
@@ -152,11 +152,34 @@
swap( _original_dims, img._original_dims );
}
- void recreate(const point_t& dims, std::size_t alignment=0, const Alloc alloc_in = Alloc()) {
- image tmp(dims, alignment, alloc_in);
- swap(tmp);
- }
+ void recreate(const point_t& dims, std::size_t alignment=0, const Alloc alloc_in = Alloc())
+ {
+ if( dims == _view.dimensions() && _align_in_bytes == alignment )
+ {
+ return;
+ }
+
+ std::size_t original_size = total_allocated_size_in_bytes( _original_dims );
+ std::size_t new_size = total_allocated_size_in_bytes( dims );
+
+ if( original_size >= new_size )
+ {
+ destruct_pixels( _view );
+
+ _view = view_t( dims
+ , typename view_t::locator( typename view_t::x_iterator( _memory )
+ , get_row_size_in_memunits( dims.x )
+ )
+ );
+ default_construct_pixels( _view );
+ }
+ else
+ {
+ image tmp(dims, alignment, alloc_in);
+ swap(tmp);
+ }
+ }
void recreate(x_coord_t width, y_coord_t height, std::size_t alignment=0, const Alloc alloc_in = Alloc()) {
recreate(point_t(width,height),alignment,alloc_in);
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk