Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84094 - trunk/boost/gil
From: chhenning_at_[hidden]
Date: 2013-04-30 10:11:34


Author: chhenning
Date: 2013-04-30 10:11:33 EDT (Tue, 30 Apr 2013)
New Revision: 84094
URL: http://svn.boost.org/trac/boost/changeset/84094

Log:
Some fixes when recreating an image.
Text files modified:
   trunk/boost/gil/image.hpp | 40 +++++++++++++++++++++++++++++++++++-----
   1 files changed, 35 insertions(+), 5 deletions(-)

Modified: trunk/boost/gil/image.hpp
==============================================================================
--- trunk/boost/gil/image.hpp (original)
+++ trunk/boost/gil/image.hpp 2013-04-30 10:11:33 EDT (Tue, 30 Apr 2013)
@@ -153,12 +153,18 @@
 
     void recreate(const point_t& dims, std::size_t alignment=0, const Alloc alloc_in = Alloc())
     {
- if( dims == _view.dimensions() && _align_in_bytes == alignment )
+ if( dims == _view.dimensions()
+ && _align_in_bytes == alignment
+ && alloc_in == _alloc
+ )
         {
             return;
         }
 
- if( _allocated_bytes >= total_allocated_size_in_bytes( dims ) )
+ if( _allocated_bytes >= total_allocated_size_in_bytes( dims )
+ && _align_in_bytes == alignment
+ && alloc_in == _alloc
+ )
         {
             destruct_pixels( _view );
 
@@ -180,14 +186,38 @@
     }
 
     void recreate(const point_t& dims,
- const Pixel& p_in, std::size_t alignment, const Alloc alloc_in = Alloc()) {
- if (dims!=_view.dimensions() || _align_in_bytes!=alignment || alloc_in!=_alloc) {
+ const Pixel& p_in, std::size_t alignment = 0, const Alloc alloc_in = Alloc())
+ {
+ if( dims == _view.dimensions()
+ && _align_in_bytes == alignment
+ && alloc_in == _alloc
+ )
+ {
+ return;
+ }
+
+ if( _allocated_bytes >= total_allocated_size_in_bytes( dims )
+ && _align_in_bytes == alignment
+ && alloc_in == _alloc
+ )
+ {
+ destruct_pixels( _view );
+
+ create_view( dims
+ , typename boost::conditional< IsPlanar, mpl::true_, mpl::false_ >::type()
+ );
+
+ uninitialized_fill_pixels(_view, p_in);
+ }
+ else
+ {
             image tmp(dims, p_in, alignment, alloc_in);
             swap(tmp);
         }
     }
+
     void recreate(x_coord_t width, y_coord_t height,
- const Pixel& p_in, std::size_t alignment, const Alloc alloc_in = Alloc()) {
+ const Pixel& p_in, std::size_t alignment = 0, const Alloc alloc_in = Alloc()) {
         recreate(point_t(width,height),p_in,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