summaryrefslogtreecommitdiff
path: root/basebmp
diff options
context:
space:
mode:
authorThorsten Behrens <thb@openoffice.org>2006-06-02 12:57:26 +0000
committerThorsten Behrens <thb@openoffice.org>2006-06-02 12:57:26 +0000
commitdb83a2292b3e75df100bf377c5202b11f423c9d7 (patch)
treef6d178f005e5071029fcc097247d85020a5e7df2 /basebmp
parent1ee80e3be2f120116180be826d0fc203c54be8f3 (diff)
#i65904# Completed mask support; fixed color difference bug; added more tests
Diffstat (limited to 'basebmp')
-rw-r--r--basebmp/inc/basebmp/accessoradapters.hxx58
-rw-r--r--basebmp/inc/basebmp/color.hxx17
-rw-r--r--basebmp/inc/basebmp/scanlineformats.hxx10
-rw-r--r--basebmp/source/bitmapdevice.cxx102
-rw-r--r--basebmp/source/debug.cxx31
-rw-r--r--basebmp/test/basictest.cxx6
-rw-r--r--basebmp/test/bmpdemo.cxx27
-rw-r--r--basebmp/test/bmptest.cxx224
-rw-r--r--basebmp/test/masktest.cxx181
-rw-r--r--basebmp/test/tools.cxx57
-rw-r--r--basebmp/test/tools.hxx39
11 files changed, 663 insertions, 89 deletions
diff --git a/basebmp/inc/basebmp/accessoradapters.hxx b/basebmp/inc/basebmp/accessoradapters.hxx
index 2c2d5d8f3753..0a6ffe7c661b 100644
--- a/basebmp/inc/basebmp/accessoradapters.hxx
+++ b/basebmp/inc/basebmp/accessoradapters.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: accessoradapters.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: thb $ $Date: 2006-06-02 08:36:14 $
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:24 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -168,6 +168,58 @@ public:
}
};
+/** Accessor adapter that blends input value against fixed color value
+ */
+template< class WrappedAccessor,
+ typename ColorType > class ConstantColorBlendAccessorAdapter
+{
+private:
+ WrappedAccessor maWrappee;
+ ColorType maBlendColor;
+
+public:
+ typedef typename WrappedAccessor::value_type value_type;
+
+ ConstantColorBlendAccessorAdapter() :
+ maWrappee(),
+ maBlendColor()
+ {}
+
+ ConstantColorBlendAccessorAdapter( WrappedAccessor acc,
+ ColorType col ) :
+ maWrappee(acc),
+ maBlendColor(col)
+ {}
+
+ template< typename IteratorType > value_type operator()(IteratorType const& i) const
+ {
+ return maWrappee(i);
+ }
+ template< typename IteratorType, class Difference >
+ value_type operator()(IteratorType const& i, Difference const& diff) const
+ {
+ return maWrappee(i,diff);
+ }
+
+ template< typename V, typename IteratorType >
+ void set(V const& value, IteratorType const& i) const
+ {
+ maWrappee.set(
+ maBlendColor*value,
+ i );
+ }
+
+ template< typename V, typename IteratorType, class Difference >
+ void set(V const& value, IteratorType const& i, Difference const& diff) const
+ {
+ maWrappee.set(
+ maBlendColor*value,
+ i,
+ diff );
+ }
+};
+
+
// Some common accessor wrappers
// ------------------------------------------------------------
@@ -204,7 +256,7 @@ template< typename T > struct MaskFunctor
// Faster mask (assuming mask accessor output is already either 0 or 1)
template< typename T > struct FastMaskFunctor
{
- T operator()( T v, T m ) const
+ template< typename T1, typename T2> T operator()( T1 v, T2 m ) const
{
return m*v;
}
diff --git a/basebmp/inc/basebmp/color.hxx b/basebmp/inc/basebmp/color.hxx
index ff9e6c4469ff..6928a14df23f 100644
--- a/basebmp/inc/basebmp/color.hxx
+++ b/basebmp/inc/basebmp/color.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: color.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: thb $ $Date: 2006-05-31 10:12:11 $
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:25 $
*
* 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 @@
#ifndef _SAL_TYPES_H_
#include <sal/types.h>
#endif
+#include <vigra/mathutil.hxx>
#include <math.h>
namespace basebmp
@@ -67,9 +68,15 @@ public:
sal_uInt32 getValue() const { return mnColor; }
operator sal_uInt32() const { return mnColor; }
- Color operator-( Color col ) const { return Color(getRed()-col.getRed(),
- getGreen()-col.getGreen(),
- getBlue()-col.getBlue()); }
+ Color operator-( Color col ) const { return Color(vigra::abs((int)getRed()-col.getRed()),
+ vigra::abs((int)getGreen()-col.getGreen()),
+ vigra::abs((int)getBlue()-col.getBlue())); }
+ Color operator*( sal_uInt8 n ) const { return Color(n*getRed()/SAL_MAX_UINT8,
+ n*getGreen()/SAL_MAX_UINT8,
+ n*getBlue()/SAL_MAX_UINT8); }
+ Color operator*( double n ) const { return Color((sal_uInt8)(n*getRed()+.5),
+ (sal_uInt8)(n*getGreen()+.5),
+ (sal_uInt8)(n*getBlue()+.5)); }
double magnitude() const { return sqrt(getRed()*getRed()
+ getGreen()*getGreen()
+ getBlue()*getBlue()); }
diff --git a/basebmp/inc/basebmp/scanlineformats.hxx b/basebmp/inc/basebmp/scanlineformats.hxx
index db7befdedc2d..cabda6cef69a 100644
--- a/basebmp/inc/basebmp/scanlineformats.hxx
+++ b/basebmp/inc/basebmp/scanlineformats.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: scanlineformats.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: thb $ $Date: 2006-06-02 08:36:14 $
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,8 +70,8 @@
namespace basebmp { namespace Format
{
- static const sal_Int32 ONE_BIT_MSB_TC_MASK = (sal_Int32)0x01;
- static const sal_Int32 ONE_BIT_LSB_TC_MASK = (sal_Int32)0x02;
+ static const sal_Int32 ONE_BIT_MSB_GRAY = (sal_Int32)0x01;
+ static const sal_Int32 ONE_BIT_LSB_GRAY = (sal_Int32)0x02;
static const sal_Int32 ONE_BIT_MSB_PAL = (sal_Int32)0x03;
static const sal_Int32 ONE_BIT_LSB_PAL = (sal_Int32)0x04;
static const sal_Int32 TWO_BIT_MSB_PAL = (sal_Int32)0x05;
@@ -79,7 +79,7 @@ namespace basebmp { namespace Format
static const sal_Int32 FOUR_BIT_MSB_PAL = (sal_Int32)0x07;
static const sal_Int32 FOUR_BIT_LSB_PAL = (sal_Int32)0x08;
static const sal_Int32 EIGHT_BIT_PAL = (sal_Int32)0x09;
- static const sal_Int32 EIGHT_BIT_TC_MASK = (sal_Int32)0x0A;
+ static const sal_Int32 EIGHT_BIT_GRAY = (sal_Int32)0x0A;
static const sal_Int32 SIXTEEN_BIT_TC_MASK = (sal_Int32)0x0B;
static const sal_Int32 TWENTYFOUR_BIT_TC_MASK = (sal_Int32)0x0C;
static const sal_Int32 THIRTYTWO_BIT_TC_MASK = (sal_Int32)0x0D;
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index bd7425bf4526..eb40b57c7dce 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: bitmapdevice.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: thb $ $Date: 2006-06-02 08:50:38 $
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:25 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -475,7 +475,9 @@ namespace
pAlpha->maAccessor,
maBegin + vigra::Diff2D(rDstPoint.getX(),
rDstPoint.getY()),
- maAccessor );
+ ConstantColorBlendAccessorAdapter<DestAccessor,Color>(
+ maAccessor,
+ rSrcColor) );
}
virtual void drawMaskedColor_i(Color rSrcColor,
@@ -865,19 +867,16 @@ void BitmapDevice::drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
DrawMode drawMode )
{
const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
- const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX()+1,rSrcSize.getY()+1 );
- const basegfx::B2IVector& rDstSize( getSize() );
- const basegfx::B2IRange aDstBounds( 0,0,rDstSize.getX()+1,rDstSize.getY()+1 );
-
- basegfx::B2IRange aSrcRange( rSrcRect );
- basegfx::B2IRange aDestRange( rDstRect );
+ const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
+ basegfx::B2IRange aSrcRange( rSrcRect );
+ basegfx::B2IRange aDestRange( rDstRect );
if( clipAreaImpl( aDestRange,
aSrcRange,
- aDstBounds,
+ mpImpl->maBounds,
aSrcBounds ))
{
- assertImageRange(aDestRange,aDstBounds);
+ assertImageRange(aDestRange,mpImpl->maBounds);
assertImageRange(aSrcRange,aSrcBounds);
if( isCompatibleBitmap( rSrcBitmap ) )
@@ -894,19 +893,16 @@ void BitmapDevice::drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
const BitmapDeviceSharedPtr& rClip )
{
const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
- const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX()+1,rSrcSize.getY()+1 );
- const basegfx::B2IVector& rDstSize( getSize() );
- const basegfx::B2IRange aDstBounds( 0,0,rDstSize.getX()+1,rDstSize.getY()+1 );
-
- basegfx::B2IRange aSrcRange( rSrcRect );
- basegfx::B2IRange aDestRange( rDstRect );
+ const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
+ basegfx::B2IRange aSrcRange( rSrcRect );
+ basegfx::B2IRange aDestRange( rDstRect );
if( clipAreaImpl( aDestRange,
aSrcRange,
- aDstBounds,
+ mpImpl->maBounds,
aSrcBounds ))
{
- assertImageRange(aDestRange,aDstBounds);
+ assertImageRange(aDestRange,mpImpl->maBounds);
assertImageRange(aSrcRange,aSrcBounds);
if( isCompatibleBitmap( rSrcBitmap ) &&
@@ -927,19 +923,16 @@ void BitmapDevice::drawMaskedColor( Color rSrcColor,
const basegfx::B2IPoint& rDstPoint )
{
const basegfx::B2IVector& rSrcSize( rAlphaMask->getSize() );
- const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX()+1,rSrcSize.getY()+1 );
- const basegfx::B2IVector& rDstSize( getSize() );
- const basegfx::B2IRange aDstBounds( 0,0,rDstSize.getX()+1,rDstSize.getY()+1 );
-
- basegfx::B2IRange aSrcRange( rSrcRect );
- basegfx::B2IPoint aDestPoint( rDstPoint );
+ const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
+ basegfx::B2IRange aSrcRange( rSrcRect );
+ basegfx::B2IPoint aDestPoint( rDstPoint );
if( clipAreaImpl( aSrcRange,
aDestPoint,
aSrcBounds,
- aDstBounds ))
+ mpImpl->maBounds ))
{
- assertImagePoint(aDestPoint,aDstBounds);
+ assertImagePoint(aDestPoint,mpImpl->maBounds);
assertImageRange(aSrcRange,aSrcBounds);
if( isCompatibleAlphaMask( rAlphaMask ) )
@@ -956,19 +949,16 @@ void BitmapDevice::drawMaskedColor( Color rSrcColor,
const BitmapDeviceSharedPtr& rClip )
{
const basegfx::B2IVector& rSrcSize( rAlphaMask->getSize() );
- const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX()+1,rSrcSize.getY()+1 );
- const basegfx::B2IVector& rDstSize( getSize() );
- const basegfx::B2IRange aDstBounds( 0,0,rDstSize.getX()+1,rDstSize.getY()+1 );
-
- basegfx::B2IRange aSrcRange( rSrcRect );
- basegfx::B2IPoint aDestPoint( rDstPoint );
+ const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
+ basegfx::B2IRange aSrcRange( rSrcRect );
+ basegfx::B2IPoint aDestPoint( rDstPoint );
if( clipAreaImpl( aSrcRange,
aDestPoint,
aSrcBounds,
- aDstBounds ))
+ mpImpl->maBounds ))
{
- assertImagePoint(aDestPoint,aDstBounds);
+ assertImagePoint(aDestPoint,mpImpl->maBounds);
assertImageRange(aSrcRange,aSrcBounds);
if( isCompatibleAlphaMask( rAlphaMask ) &&
@@ -992,19 +982,16 @@ void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
OSL_ASSERT( rMask->getSize() == rSrcBitmap->getSize() );
const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
- const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX()+1,rSrcSize.getY()+1 );
- const basegfx::B2IVector& rDstSize( getSize() );
- const basegfx::B2IRange aDstBounds( 0,0,rDstSize.getX()+1,rDstSize.getY()+1 );
-
- basegfx::B2IRange aSrcRange( rSrcRect );
- basegfx::B2IRange aDestRange( rDstRect );
+ const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
+ basegfx::B2IRange aSrcRange( rSrcRect );
+ basegfx::B2IRange aDestRange( rDstRect );
if( clipAreaImpl( aDestRange,
aSrcRange,
- aDstBounds,
+ mpImpl->maBounds,
aSrcBounds ))
{
- assertImageRange(aDestRange,aDstBounds);
+ assertImageRange(aDestRange,mpImpl->maBounds);
assertImageRange(aSrcRange,aSrcBounds);
if( isCompatibleBitmap( rSrcBitmap ) &&
@@ -1029,19 +1016,16 @@ void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
OSL_ASSERT( rMask->getSize() == rSrcBitmap->getSize() );
const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
- const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX()+1,rSrcSize.getY()+1 );
- const basegfx::B2IVector& rDstSize( getSize() );
- const basegfx::B2IRange aDstBounds( 0,0,rDstSize.getX()+1,rDstSize.getY()+1 );
-
- basegfx::B2IRange aSrcRange( rSrcRect );
- basegfx::B2IRange aDestRange( rDstRect );
+ const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
+ basegfx::B2IRange aSrcRange( rSrcRect );
+ basegfx::B2IRange aDestRange( rDstRect );
if( clipAreaImpl( aDestRange,
aSrcRange,
- aDstBounds,
+ mpImpl->maBounds,
aSrcBounds ))
{
- assertImageRange(aDestRange,aDstBounds);
+ assertImageRange(aDestRange,mpImpl->maBounds);
assertImageRange(aSrcRange,aSrcBounds);
if( isCompatibleBitmap( rSrcBitmap ) &&
@@ -1076,9 +1060,9 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
// HACK: 1bpp and 32bpp only, currently
if( nScanlineFormat == Format::ONE_BIT_MSB_PAL
- || nScanlineFormat == Format::ONE_BIT_MSB_TC_MASK )
+ || nScanlineFormat == Format::ONE_BIT_MSB_GRAY )
nScanlineStride = (rSize.getX() + 7) >> 3;
- else if( nScanlineFormat == Format::EIGHT_BIT_TC_MASK )
+ else if( nScanlineFormat == Format::EIGHT_BIT_GRAY )
nScanlineStride = rSize.getX();
else if( nScanlineFormat == Format::THIRTYTWO_BIT_TC_MASK )
nScanlineStride = 4*rSize.getX();
@@ -1100,7 +1084,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
switch( nScanlineFormat )
{
- case Format::ONE_BIT_MSB_TC_MASK:
+ case Format::ONE_BIT_MSB_GRAY:
{
return BitmapDeviceSharedPtr(
new OneBitMsbMaskRenderer(
@@ -1143,7 +1127,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
pPal ));
}
- case Format::EIGHT_BIT_TC_MASK:
+ case Format::EIGHT_BIT_GRAY:
{
return BitmapDeviceSharedPtr(
new EightBitTrueColorRenderer(
@@ -1197,9 +1181,9 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
// HACK: 1bpp and 32bpp only, currently
if( nScanlineFormat == Format::ONE_BIT_MSB_PAL
- || nScanlineFormat == Format::ONE_BIT_MSB_TC_MASK )
+ || nScanlineFormat == Format::ONE_BIT_MSB_GRAY )
nScanlineStride = (rSize.getX() + 7) >> 3;
- else if( nScanlineFormat == Format::EIGHT_BIT_TC_MASK )
+ else if( nScanlineFormat == Format::EIGHT_BIT_GRAY )
nScanlineStride = rSize.getX();
else if( nScanlineFormat == Format::THIRTYTWO_BIT_TC_MASK )
nScanlineStride = 4*rSize.getX();
@@ -1214,7 +1198,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
switch( nScanlineFormat )
{
- case Format::ONE_BIT_MSB_TC_MASK:
+ case Format::ONE_BIT_MSB_GRAY:
{
return BitmapDeviceSharedPtr(
new OneBitMsbMaskRenderer(
@@ -1253,7 +1237,7 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
rPalette ));
}
- case Format::EIGHT_BIT_TC_MASK:
+ case Format::EIGHT_BIT_GRAY:
{
return BitmapDeviceSharedPtr(
new EightBitTrueColorRenderer(
diff --git a/basebmp/source/debug.cxx b/basebmp/source/debug.cxx
index e4b331757202..d789f39b1d79 100644
--- a/basebmp/source/debug.cxx
+++ b/basebmp/source/debug.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: debug.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: thb $ $Date: 2006-05-31 10:12:12 $
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,10 +79,30 @@ namespace basebmp
{
switch( nScanlineFormat )
{
+ case Format::ONE_BIT_MSB_GRAY:
+ return "ONE_BIT_MSB_GRAY";
+ case Format::ONE_BIT_LSB_GRAY:
+ return "ONE_BIT_LSB_GRAY";
case Format::ONE_BIT_MSB_PAL:
return "ONE_BIT_MSB_PAL";
- case Format::EIGHT_BIT_TC_MASK:
- return "EIGHT_BIT_TC_MASK";
+ case Format::ONE_BIT_LSB_PAL:
+ return "ONE_BIT_LSB_PAL";
+ case Format::TWO_BIT_MSB_PAL:
+ return "TWO_BIT_MSB_PAL";
+ case Format::TWO_BIT_LSB_PAL:
+ return "TWO_BIT_LSB_PAL";
+ case Format::FOUR_BIT_MSB_PAL:
+ return "FOUR_BIT_MSB_PAL";
+ case Format::FOUR_BIT_LSB_PAL:
+ return "FOUR_BIT_LSB_PAL";
+ case Format::EIGHT_BIT_PAL:
+ return "EIGHT_BIT_PAL";
+ case Format::EIGHT_BIT_GRAY:
+ return "EIGHT_BIT_GRAY";
+ case Format::SIXTEEN_BIT_TC_MASK:
+ return "SIXTEEN_BIT_TC_MASK";
+ case Format::TWENTYFOUR_BIT_TC_MASK:
+ return "TWENTYFOUR_BIT_TC_MASK";
case Format::THIRTYTWO_BIT_TC_MASK:
return "THIRTYTWO_BIT_TC_MASK";
default:
@@ -99,11 +119,12 @@ namespace basebmp
const sal_Int32 nScanlineFormat( rDevice->getScanlineFormat() );
rOutputStream
- << "/* basebmp::BitmapDevice memory dump */" << std::endl
+ << "/* basebmp::BitmapDevice content dump */" << std::endl
<< "/* Width = " << aSize.getX() << " */" << std::endl
<< "/* Height = " << aSize.getY() << " */" << std::endl
<< "/* TopDown = " << bTopDown << " */" << std::endl
<< "/* Format = " << getFormatString(nScanlineFormat) << " */" << std::endl
+ << "/* (dumped entries are already mapped RGBA color values) */" << std::endl
<< std::endl;
rOutputStream << std::hex;
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx
index 0ad47180988f..d4c2c4d9b2b8 100644
--- a/basebmp/test/basictest.cxx
+++ b/basebmp/test/basictest.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: basictest.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: thb $ $Date: 2006-05-31 10:12:13 $
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:25 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -104,7 +104,7 @@ public:
{
pDevice = createBitmapDevice( aSize,
true,
- Format::EIGHT_BIT_TC_MASK );
+ Format::EIGHT_BIT_GRAY );
const Color aCol4(0x01);
pDevice->setPixel( aPt, aCol4, DrawMode_PAINT );
diff --git a/basebmp/test/bmpdemo.cxx b/basebmp/test/bmpdemo.cxx
index b1312a597df1..99e9a5b14464 100644
--- a/basebmp/test/bmpdemo.cxx
+++ b/basebmp/test/bmpdemo.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: bmpdemo.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: thb $ $Date: 2006-06-02 08:36:14 $
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:25 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -69,6 +69,7 @@
#include <basebmp/color.hxx>
#include <basebmp/scanlineformats.hxx>
#include <basebmp/bitmapdevice.hxx>
+#include <basebmp/debug.hxx>
#include <rtl/bootstrap.hxx>
@@ -79,6 +80,8 @@
#include <boost/static_assert.hpp>
#include <algorithm>
+#include <iostream>
+#include <fstream>
using namespace ::com::sun::star;
@@ -998,10 +1001,10 @@ void TestWindow::Paint( const Rectangle& rRect )
const basegfx::B2ISize aSize(10,10);
basebmp::BitmapDeviceSharedPtr pBmp( basebmp::createBitmapDevice( aSize,
true,
- basebmp::Format::THIRTYTWO_BIT_TC_MASK ));
+ basebmp::Format::EIGHT_BIT_GRAY ));
basebmp::BitmapDeviceSharedPtr pDevice( basebmp::createBitmapDevice( aSize,
true,
- basebmp::Format::THIRTYTWO_BIT_TC_MASK ));
+ basebmp::Format::ONE_BIT_MSB_PAL ));
::rtl::OUString aSvg = ::rtl::OUString::createFromAscii(
"m 0 0h5v10h5v-5h-10z" );
@@ -1014,14 +1017,20 @@ void TestWindow::Paint( const Rectangle& rRect )
aCol,
basebmp::DrawMode_PAINT );
- const basegfx::B2IRange aSourceRect(0,0,11,11);
- const basegfx::B2IRange aDestLeftTop(0,0,5,5);
+ const basegfx::B2IRange aSourceRect(0,0,10,10);
+ const basegfx::B2IPoint aOutPos(5,5);
+ const basebmp::Color aCol2(0xF0F0F0F0);
pDevice->clear(basebmp::Color(0));
- pDevice->drawBitmap(
+ pDevice->drawMaskedColor(
+ aCol2,
pBmp,
aSourceRect,
- aDestLeftTop,
- basebmp::DrawMode_PAINT );
+ aOutPos );
+
+ std::ofstream output("32bpp_test.dump");
+ debugDump( pDevice, output );
+ std::ofstream output2("32bpp_bmp.dump");
+ debugDump( pBmp, output2 );
}
enum{ srcBitDepth=1, dstBitDepth=4 };
diff --git a/basebmp/test/bmptest.cxx b/basebmp/test/bmptest.cxx
new file mode 100644
index 000000000000..3f180dd91e0e
--- /dev/null
+++ b/basebmp/test/bmptest.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: bmptest.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:25 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+// autogenerated file with codegen.pl
+
+#include <cppunit/simpleheader.hxx>
+
+#include <basegfx/vector/b2isize.hxx>
+#include <basegfx/range/b2irange.hxx>
+#include <basegfx/point/b2ipoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+#include <basebmp/color.hxx>
+#include <basebmp/scanlineformats.hxx>
+#include <basebmp/bitmapdevice.hxx>
+#include <basebmp/debug.hxx>
+#include "tools.hxx"
+
+#include <iostream>
+#include <fstream>
+
+using namespace ::basebmp;
+
+namespace
+{
+/*
+ std::ofstream output("32bpp_test.dump");
+ debugDump( rDevice, output );
+ std::ofstream output2("32bpp_bmp.dump");
+ debugDump( rBmp, output2 );
+*/
+
+class BmpTest : public CppUnit::TestFixture
+{
+private:
+ BitmapDeviceSharedPtr mpDevice1bpp;
+ BitmapDeviceSharedPtr mpBmp1bpp;
+ BitmapDeviceSharedPtr mpDevice32bpp;
+ BitmapDeviceSharedPtr mpBmp32bpp;
+
+ void implTestBmpBasics(const BitmapDeviceSharedPtr& rDevice,
+ const BitmapDeviceSharedPtr& rBmp)
+ {
+ rDevice->clear(Color(0));
+ const Color aCol(0xFFFFFFFF);
+
+ const basegfx::B2IRange aSourceRect(0,0,10,10);
+ const basegfx::B2IRange aDestLeftTop(0,0,4,4);
+ const basegfx::B2IRange aDestRightTop(6,0,10,4);
+ const basegfx::B2IRange aDestLeftBottom(0,6,4,10);
+ const basegfx::B2IRange aDestRightBottom(6,6,10,10);
+
+ rDevice->drawBitmap(
+ rBmp,
+ aSourceRect,
+ aDestLeftTop,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 8",
+ countPixel( rDevice, aCol ) == 8);
+
+ rDevice->drawBitmap(
+ rBmp,
+ aSourceRect,
+ aDestRightTop,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 16",
+ countPixel( rDevice, aCol ) == 16);
+
+ rDevice->drawBitmap(
+ rBmp,
+ aSourceRect,
+ aDestLeftBottom,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 24",
+ countPixel( rDevice, aCol ) == 24);
+
+ rDevice->drawBitmap(
+ rBmp,
+ aSourceRect,
+ aDestRightBottom,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 32",
+ countPixel( rDevice, aCol ) == 32);
+ }
+
+ void implTestBmpClip(const BitmapDeviceSharedPtr& rDevice,
+ const BitmapDeviceSharedPtr& rBmp)
+ {
+ rDevice->clear(Color(0));
+ const Color aCol(0xFFFFFFFF);
+
+ const basegfx::B2IRange aSourceRect(0,0,10,10);
+ const basegfx::B2IRange aDestLeftTop(-2,-2,2,2);
+ const basegfx::B2IRange aDestRightTop(8,-2,12,2);
+ const basegfx::B2IRange aDestLeftBottom(-2,8,2,12);
+ const basegfx::B2IRange aDestRightBottom(8,8,12,12);
+
+ rDevice->drawBitmap(
+ rBmp,
+ aSourceRect,
+ aDestLeftTop,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 4",
+ countPixel( rDevice, aCol ) == 4);
+
+ rDevice->drawBitmap(
+ rBmp,
+ aSourceRect,
+ aDestLeftBottom,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 4(c)",
+ countPixel( rDevice, aCol ) == 4);
+
+ rDevice->drawBitmap(
+ rBmp,
+ aSourceRect,
+ aDestRightBottom,
+ DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 8",
+ countPixel( rDevice, aCol ) == 8);
+ }
+
+public:
+ void setUp()
+ {
+ const basegfx::B2ISize aSize(10,10);
+ mpDevice1bpp = createBitmapDevice( aSize,
+ true,
+ Format::ONE_BIT_MSB_PAL );
+ mpDevice32bpp = createBitmapDevice( aSize,
+ true,
+ Format::THIRTYTWO_BIT_TC_MASK );
+
+ mpBmp1bpp = createBitmapDevice( aSize,
+ true,
+ Format::ONE_BIT_MSB_PAL );
+ mpBmp32bpp = createBitmapDevice( aSize,
+ true,
+ Format::THIRTYTWO_BIT_TC_MASK );
+
+ ::rtl::OUString aSvg = ::rtl::OUString::createFromAscii(
+ "m 0 0h5v10h5v-5h-10z" );
+
+ basegfx::B2DPolyPolygon aPoly;
+ basegfx::tools::importFromSvgD( aPoly, aSvg );
+ const Color aCol(0xFFFFFFFF);
+ mpBmp1bpp->fillPolyPolygon(
+ aPoly,
+ aCol,
+ DrawMode_PAINT );
+ mpBmp32bpp->fillPolyPolygon(
+ aPoly,
+ aCol,
+ DrawMode_PAINT );
+ }
+
+ void testBmpBasics()
+ {
+ implTestBmpBasics( mpDevice1bpp, mpBmp1bpp );
+ implTestBmpBasics( mpDevice32bpp, mpBmp32bpp );
+ }
+
+ void testBmpClip()
+ {
+ implTestBmpClip( mpDevice1bpp, mpBmp1bpp );
+ implTestBmpClip( mpDevice32bpp, mpBmp32bpp );
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(BmpTest);
+ CPPUNIT_TEST(testBmpBasics);
+ CPPUNIT_TEST(testBmpClip);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BmpTest, "BmpTest");
+}
+
+
+// -----------------------------------------------------------------------------
+
+// this macro creates an empty function, which will called by the RegisterAllFunctions()
+// to let the user the possibility to also register some functions by hand.
+//NOADDITIONAL;
+
diff --git a/basebmp/test/masktest.cxx b/basebmp/test/masktest.cxx
new file mode 100644
index 000000000000..95fdfd16cebe
--- /dev/null
+++ b/basebmp/test/masktest.cxx
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: masktest.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:25 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+// autogenerated file with codegen.pl
+
+#include <cppunit/simpleheader.hxx>
+
+#include <basegfx/vector/b2isize.hxx>
+#include <basegfx/range/b2irange.hxx>
+#include <basegfx/point/b2ipoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+#include <basebmp/color.hxx>
+#include <basebmp/scanlineformats.hxx>
+#include <basebmp/bitmapdevice.hxx>
+#include <basebmp/debug.hxx>
+#include "tools.hxx"
+
+#include <iostream>
+#include <fstream>
+
+using namespace ::basebmp;
+
+namespace
+{
+/*
+ std::ofstream output("32bpp_test.dump");
+ debugDump( rDevice, output );
+ std::ofstream output2("32bpp_bmp.dump");
+ debugDump( rBmp, output2 );
+*/
+
+class MaskTest : public CppUnit::TestFixture
+{
+private:
+ BitmapDeviceSharedPtr mpDevice1bpp;
+ BitmapDeviceSharedPtr mpDevice32bpp;
+ BitmapDeviceSharedPtr mpMask;
+
+ void implTestMaskBasics(const BitmapDeviceSharedPtr& rDevice,
+ const BitmapDeviceSharedPtr& rBmp)
+ {
+ const Color aCol(0);
+ const Color aCol2(0xF0F0F0F0);
+
+ const basegfx::B2IRange aSourceRect(0,0,10,10);
+ const basegfx::B2IPoint aDestLeftTop(0,0);
+ const basegfx::B2IPoint aDestRightTop(5,0);
+ const basegfx::B2IPoint aDestLeftBottom(0,5);
+ const basegfx::B2IPoint aDestRightBottom(5,5);
+
+ rDevice->clear(aCol);
+ rDevice->drawMaskedColor(
+ aCol2,
+ rBmp,
+ aSourceRect,
+ aDestLeftTop );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 50",
+ countPixel( rDevice, aCol ) == 100-50);
+
+ rDevice->clear(aCol);
+ rDevice->drawMaskedColor(
+ aCol2,
+ rBmp,
+ aSourceRect,
+ aDestRightTop );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25",
+ countPixel( rDevice, aCol ) == 100-25);
+
+ rDevice->clear(aCol);
+ rDevice->drawMaskedColor(
+ aCol2,
+ rBmp,
+ aSourceRect,
+ aDestLeftBottom );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25(b)",
+ countPixel( rDevice, aCol ) == 100-25);
+
+ rDevice->clear(aCol);
+ rDevice->drawMaskedColor(
+ aCol2,
+ rBmp,
+ aSourceRect,
+ aDestRightBottom );
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25(c)",
+ countPixel( rDevice, aCol ) == 100-25);
+ }
+
+public:
+ void setUp()
+ {
+ const basegfx::B2ISize aSize(10,10);
+ mpDevice1bpp = createBitmapDevice( aSize,
+ true,
+ Format::ONE_BIT_MSB_PAL );
+ mpDevice32bpp = createBitmapDevice( aSize,
+ true,
+ Format::THIRTYTWO_BIT_TC_MASK );
+
+ mpMask = createBitmapDevice( aSize,
+ true,
+ Format::EIGHT_BIT_GRAY );
+
+ ::rtl::OUString aSvg = ::rtl::OUString::createFromAscii(
+ "m 0 0h5v10h5v-5h-10z" );
+
+ basegfx::B2DPolyPolygon aPoly;
+ basegfx::tools::importFromSvgD( aPoly, aSvg );
+ const Color aCol(0xFF);
+ mpMask->fillPolyPolygon(
+ aPoly,
+ aCol,
+ DrawMode_PAINT );
+ }
+
+ void testMaskBasics()
+ {
+ implTestMaskBasics( mpDevice32bpp, mpMask );
+ implTestMaskBasics( mpDevice1bpp, mpMask );
+ }
+
+ void testMaskClip()
+ {
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(MaskTest);
+ CPPUNIT_TEST(testMaskBasics);
+ CPPUNIT_TEST(testMaskClip);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MaskTest, "MaskTest");
+}
+
+
+// -----------------------------------------------------------------------------
+
+// this macro creates an empty function, which will called by the RegisterAllFunctions()
+// to let the user the possibility to also register some functions by hand.
+//NOADDITIONAL;
+
diff --git a/basebmp/test/tools.cxx b/basebmp/test/tools.cxx
new file mode 100644
index 000000000000..bcaf832bcd60
--- /dev/null
+++ b/basebmp/test/tools.cxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tools.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:26 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+// autogenerated file with codegen.pl
+
+#include <basegfx/vector/b2isize.hxx>
+#include <basegfx/point/b2ipoint.hxx>
+
+#include <basebmp/color.hxx>
+#include <basebmp/bitmapdevice.hxx>
+
+using namespace ::basebmp;
+
+int countPixel( const BitmapDeviceSharedPtr& rDevice,
+ Color checkColor )
+{
+ int count(0);
+ const basegfx::B2ISize& rSize( rDevice->getSize() );
+ for( sal_Int32 y=0; y<rSize.getY(); ++y )
+ for( sal_Int32 x=0; x<rSize.getX(); ++x )
+ if( rDevice->getPixel( basegfx::B2IPoint(x,y) ) == checkColor )
+ ++count;
+
+ return count;
+}
diff --git a/basebmp/test/tools.hxx b/basebmp/test/tools.hxx
new file mode 100644
index 000000000000..2b93852d0002
--- /dev/null
+++ b/basebmp/test/tools.hxx
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tools.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: thb $ $Date: 2006-06-02 13:57:26 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "basebmp/bitmapdevice.hxx"
+
+int countPixel( const basebmp::BitmapDeviceSharedPtr& rDevice,
+ basebmp::Color checkColor );