INTEGRATION: CWS basebmp01 (1.3.20); FILE MERGED
2007/05/22 09:59:17 thb 1.3.20.1: #147378# Added support for foreign formats (via GenericColorImageAccessor); fixed typos in CompositeIterator and StridedArrayIterator; fixed comparisons for (Packed)PixelIterator and StridedArrayIterator (which got negative strides wrong); avoiding unnecessary copying in scale_image() now; cleaned up bitmapdevice.cxx from cruft/ad hoc debug code; made unit tests run again
This commit is contained in:
parent
f6d09649a0
commit
1f04937e1d
1 changed files with 27 additions and 5 deletions
|
@ -4,9 +4,9 @@
|
|||
*
|
||||
* $RCSfile: scaleimage.hxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: thb $ $Date: 2006-07-28 12:43:20 $
|
||||
* last change: $Author: hr $ $Date: 2007-06-27 12:41:07 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
|
@ -39,6 +39,7 @@
|
|||
#include <osl/diagnose.h>
|
||||
|
||||
#include <vigra/tuple.hxx>
|
||||
#include <vigra/copyimage.hxx>
|
||||
#include <vigra/basicimage.hxx>
|
||||
#include <vigra/iteratortraits.hxx>
|
||||
|
||||
|
@ -119,6 +120,10 @@ void scaleLine( SourceIter s_begin,
|
|||
|
||||
@param d_acc
|
||||
Destination accessor
|
||||
|
||||
@param bMustCopy
|
||||
When true, scaleImage always copies source, even when doing 1:1
|
||||
copy
|
||||
*/
|
||||
template< class SourceIter, class SourceAcc,
|
||||
class DestIter, class DestAcc >
|
||||
|
@ -127,7 +132,8 @@ void scaleImage( SourceIter s_begin,
|
|||
SourceAcc s_acc,
|
||||
DestIter d_begin,
|
||||
DestIter d_end,
|
||||
DestAcc d_acc )
|
||||
DestAcc d_acc,
|
||||
bool bMustCopy=false )
|
||||
{
|
||||
const int src_width ( s_end.x - s_begin.x );
|
||||
const int src_height( s_end.y - s_begin.y );
|
||||
|
@ -135,6 +141,16 @@ void scaleImage( SourceIter s_begin,
|
|||
const int dest_width ( d_end.x - d_begin.x );
|
||||
const int dest_height( d_end.y - d_begin.y );
|
||||
|
||||
if( !bMustCopy &&
|
||||
src_width == dest_width &&
|
||||
src_height == dest_height )
|
||||
{
|
||||
// no scaling involved, can simply copy
|
||||
vigra::copyImage( s_begin, s_end, s_acc,
|
||||
d_begin, d_acc );
|
||||
return;
|
||||
}
|
||||
|
||||
typedef vigra::BasicImage<typename SourceAcc::value_type> TmpImage;
|
||||
typedef typename TmpImage::traverser TmpImageIter;
|
||||
|
||||
|
@ -166,14 +182,20 @@ void scaleImage( SourceIter s_begin,
|
|||
}
|
||||
|
||||
/** Scale an image, range tuple version
|
||||
|
||||
@param bMustCopy
|
||||
When true, scaleImage always copies source, even when doing 1:1
|
||||
copy
|
||||
*/
|
||||
template< class SourceIter, class SourceAcc,
|
||||
class DestIter, class DestAcc >
|
||||
inline void scaleImage( vigra::triple<SourceIter,SourceIter,SourceAcc> const& src,
|
||||
vigra::triple<DestIter,DestIter,DestAcc> const& dst )
|
||||
vigra::triple<DestIter,DestIter,DestAcc> const& dst,
|
||||
bool bMustCopy=false )
|
||||
{
|
||||
scaleImage(src.first,src.second,src.third,
|
||||
dst.first,dst.second,dst.third);
|
||||
dst.first,dst.second,dst.third,
|
||||
bMustCopy);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue