summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <thb@openoffice.org>2006-06-07 23:01:48 +0000
committerThorsten Behrens <thb@openoffice.org>2006-06-07 23:01:48 +0000
commit76535cd14f67f0c9d2a426d097bae4d965c959e7 (patch)
treeab227e5f10a9a6be76405d4e7ce09b7b19bc7641
parent4999aa5c72de27ffd28944a2f56d68933ce1ee52 (diff)
#i65904# Fixed broken CompositeIterator (was missing a proper copy-const/assignment op); added more tests
-rw-r--r--basebmp/inc/basebmp/bitmapdevice.hxx14
-rwxr-xr-xbasebmp/inc/basebmp/compositeiterator.hxx21
-rw-r--r--basebmp/source/bitmapdevice.cxx42
-rw-r--r--basebmp/test/bmpdemo.cxx57
-rw-r--r--basebmp/test/linetest.cxx6
-rw-r--r--basebmp/test/makefile.mk5
6 files changed, 82 insertions, 63 deletions
diff --git a/basebmp/inc/basebmp/bitmapdevice.hxx b/basebmp/inc/basebmp/bitmapdevice.hxx
index 4e5d106ae3bb..7c8aa84ccef6 100644
--- a/basebmp/inc/basebmp/bitmapdevice.hxx
+++ b/basebmp/inc/basebmp/bitmapdevice.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bitmapdevice.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-08 00:01:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -401,6 +401,16 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
const RawMemorySharedArray& rMem,
const PaletteMemorySharedVector& rPalette );
+
+/** Factory method to clone a BitmapDevice from a given prototype.
+
+ All attributes (like scanline format and top-down state) are
+ copied, only the size can be varied. Note that the prototype's
+ bitmap content is <em>not</em> copied, only a palette (if any).
+ */
+BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize,
+ const BitmapDeviceSharedPtr& rProto );
+
}
#endif /* INCLUDED_BASEBMP_BITMAPDEVICE_HXX */
diff --git a/basebmp/inc/basebmp/compositeiterator.hxx b/basebmp/inc/basebmp/compositeiterator.hxx
index 0c569c569f63..3c64e425dff2 100755
--- a/basebmp/inc/basebmp/compositeiterator.hxx
+++ b/basebmp/inc/basebmp/compositeiterator.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: compositeiterator.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: thb $ $Date: 2006-06-07 14:27:35 $
+ * last change: $Author: thb $ $Date: 2006-06-08 00:01:47 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -344,6 +344,23 @@ public:
y(this->maIter1.y,this->maIter2.y)
{}
+ CompositeIterator2D( const CompositeIterator2D& rOld ) :
+ base_type(rOld),
+ x(this->maIter1.x,this->maIter2.x),
+ y(this->maIter1.y,this->maIter2.y)
+ {}
+
+ CompositeIterator2D& operator=( const CompositeIterator2D& rNew )
+ {
+ this->maIter1 = rNew.maIter1;
+ this->maIter2 = rNew.maIter2;
+
+ x = MoveX(this->maIter1.x,
+ this->maIter2.x);
+ y = MoveY(this->maIter1.y,
+ this->maIter2.y);
+ }
+
row_iterator rowIterator() const
{
return row_iterator(this->maIter1.rowIterator(),
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 01ea9314ce60..2baaa7f1c18f 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: bitmapdevice.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: thb $ $Date: 2006-06-07 14:27:36 $
+ * last change: $Author: thb $ $Date: 2006-06-08 00:01:48 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -866,9 +866,11 @@ void BitmapDevice::drawLine( const basegfx::B2IPoint& rPt1,
basegfx::B2DPoint aPt2( rPt2 );
if( basegfx::tools::liangBarskyClip2D(aPt1,aPt2,mpImpl->maFloatBounds) )
+ {
drawLine_i( aPt1, aPt2,
lineColor,
drawMode );
+ }
}
void BitmapDevice::drawLine( const basegfx::B2IPoint& rPt1,
@@ -877,9 +879,6 @@ void BitmapDevice::drawLine( const basegfx::B2IPoint& rPt1,
DrawMode drawMode,
const BitmapDeviceSharedPtr& rClip )
{
-#if 1
- drawLine( rPt1, rPt2, lineColor, drawMode );
-#else
basegfx::B2DPoint aPt1( rPt1 );
basegfx::B2DPoint aPt2( rPt2 );
@@ -893,7 +892,6 @@ void BitmapDevice::drawLine( const basegfx::B2IPoint& rPt1,
else
OSL_ENSURE( false, "Generic output not yet implemented!" );
}
-#endif
}
void BitmapDevice::drawPolygon( const basegfx::B2DPolygon& rPoly,
@@ -916,9 +914,6 @@ void BitmapDevice::drawPolygon( const basegfx::B2DPolygon& rPoly,
DrawMode drawMode,
const BitmapDeviceSharedPtr& rClip )
{
-#if 1
- drawPolygon( rPoly, lineColor, drawMode );
-#else
basegfx::B2DPolyPolygon aPoly(
basegfx::tools::clipPolygonOnRange( rPoly,
mpImpl->maFloatBounds,
@@ -931,7 +926,6 @@ void BitmapDevice::drawPolygon( const basegfx::B2DPolygon& rPoly,
drawPolygon_i( aPoly.getB2DPolygon(i), lineColor, drawMode, rClip );
else
OSL_ENSURE( false, "Generic output not yet implemented!" );
-#endif
}
void BitmapDevice::fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
@@ -946,14 +940,10 @@ void BitmapDevice::fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
DrawMode drawMode,
const BitmapDeviceSharedPtr& rClip )
{
-#if 1
- fillPolyPolygon( rPoly, fillColor, drawMode );
-#else
if( isCompatibleClipMask( rClip ) )
fillPolyPolygon_i( rPoly, fillColor, drawMode, mpImpl->maBounds, rClip );
else
OSL_ENSURE( false, "Generic output not yet implemented!" );
-#endif
}
@@ -1122,9 +1112,6 @@ void BitmapDevice::drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
DrawMode drawMode,
const BitmapDeviceSharedPtr& rClip )
{
-#if 1
- drawBitmap(rSrcBitmap, rSrcRect, rDstRect, drawMode);
-#else
const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
basegfx::B2IRange aSrcRange( rSrcRect );
@@ -1148,7 +1135,6 @@ void BitmapDevice::drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
OSL_ENSURE( false, "Generic output not yet implemented!" );
}
}
-#endif
}
void BitmapDevice::drawMaskedColor( Color rSrcColor,
@@ -1182,9 +1168,6 @@ void BitmapDevice::drawMaskedColor( Color aSrcColor,
const basegfx::B2IPoint& rDstPoint,
const BitmapDeviceSharedPtr& rClip )
{
-#if 1
- drawMaskedColor(aSrcColor, rAlphaMask, rSrcRect, rDstPoint);
-#else
const basegfx::B2IVector& rSrcSize( rAlphaMask->getSize() );
const basegfx::B2IRange aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
basegfx::B2IRange aSrcRange( rSrcRect );
@@ -1201,14 +1184,13 @@ void BitmapDevice::drawMaskedColor( Color aSrcColor,
if( isCompatibleAlphaMask( rAlphaMask ) &&
isCompatibleClipMask( rClip ) )
{
- drawMaskedColor_i( rSrcColor, rAlphaMask, aSrcRange, aDestPoint, rClip );
+ drawMaskedColor_i( aSrcColor, rAlphaMask, aSrcRange, aDestPoint, rClip );
}
else
{
OSL_ENSURE( false, "Generic output not yet implemented!" );
}
}
-#endif
}
void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
@@ -1217,9 +1199,6 @@ void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
const basegfx::B2IRange& rDstRect,
DrawMode drawMode )
{
-#if 1
- drawMaskedBitmap(rSrcBitmap, rMask, rSrcRect, rDstRect, drawMode);
-#else
OSL_ASSERT( rMask->getSize() == rSrcBitmap->getSize() );
const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
@@ -1245,7 +1224,6 @@ void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
OSL_ENSURE( false, "Generic output not yet implemented!" );
}
}
-#endif
}
void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
@@ -1449,4 +1427,14 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
rPalette );
}
+BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize,
+ const BitmapDeviceSharedPtr& rProto )
+{
+ return createBitmapDeviceImpl( rSize,
+ rProto->isTopDown(),
+ rProto->getScanlineFormat(),
+ boost::shared_array< sal_uInt8 >(),
+ rProto->getPalette() );
+}
+
} // namespace basebmp
diff --git a/basebmp/test/bmpdemo.cxx b/basebmp/test/bmpdemo.cxx
index a35a36201187..dd008ffecb32 100644
--- a/basebmp/test/bmpdemo.cxx
+++ b/basebmp/test/bmpdemo.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: bmpdemo.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: thb $ $Date: 2006-06-07 14:27:36 $
+ * last change: $Author: thb $ $Date: 2006-06-08 00:01:48 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -999,43 +999,46 @@ void TestWindow::Paint( const Rectangle& rRect )
{
{
const basegfx::B2ISize aSize(10,10);
- basebmp::BitmapDeviceSharedPtr pBmp( basebmp::createBitmapDevice( aSize,
- true,
- basebmp::Format::EIGHT_BIT_GRAY ));
basebmp::BitmapDeviceSharedPtr pDevice( basebmp::createBitmapDevice( aSize,
true,
- basebmp::Format::ONE_BIT_MSB_PAL ));
+ basebmp::Format::THIRTYTWO_BIT_TC_MASK ));
+ basebmp::BitmapDeviceSharedPtr pMask( basebmp::createBitmapDevice( aSize,
+ true,
+ basebmp::Format::ONE_BIT_MSB_GRAY ));
::rtl::OUString aSvg = ::rtl::OUString::createFromAscii(
- "m 0 0h5v10h5v-5h-10z" );
-
+ "m 0 0 h5 l5 5 v5 h-5 l-5-5 z" );
basegfx::B2DPolyPolygon aPoly;
basegfx::tools::importFromSvgD( aPoly, aSvg );
- const basebmp::Color aCol(0xFFFFFFFF);
- pBmp->clear(basebmp::Color(0));
-
- const basegfx::B2IPoint aPt(3,3);
- const basebmp::Color aCol4(0x01);
- pBmp->setPixel( aPt, aCol4, basebmp::DrawMode_PAINT );
-
- pBmp->fillPolyPolygon(
- aPoly,
- aCol,
+ pMask->clear(basebmp::Color(0xFFFFFFFF));
+ pMask->drawPolygon(
+ aPoly.getB2DPolygon(0),
+ basebmp::Color(0),
basebmp::DrawMode_PAINT );
- 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->drawMaskedColor(
- aCol2,
- pBmp,
- aSourceRect,
- aOutPos );
+ basebmp::BitmapDeviceSharedPtr pBmp( basebmp::cloneBitmapDevice(
+ basegfx::B2IVector(3,3),
+ pDevice ));
+ basebmp::Color aCol1(0);
+ basebmp::Color aCol2(0xFFFFFFFF);
+ pBmp->clear(aCol1);
+ pBmp->setPixel(basegfx::B2IPoint(0,0),aCol2,basebmp::DrawMode_PAINT);
+ pBmp->setPixel(basegfx::B2IPoint(1,1),aCol2,basebmp::DrawMode_PAINT);
+ pBmp->setPixel(basegfx::B2IPoint(2,2),aCol2,basebmp::DrawMode_PAINT);
+
+ pDevice->clear(aCol1);
+ pDevice->drawBitmap(pBmp,
+ basegfx::B2IRange(0,0,3,3),
+ basegfx::B2IRange(2,2,7,7),
+// basegfx::B2IRange(-1,-1,5,5),
+ basebmp::DrawMode_PAINT,
+ pMask);
std::ofstream output("32bpp_test.dump");
debugDump( pDevice, output );
std::ofstream output2("32bpp_bmp.dump");
debugDump( pBmp, output2 );
+ std::ofstream output3("clipmask.dump");
+ debugDump( pMask, output3 );
}
enum{ srcBitDepth=1, dstBitDepth=4 };
diff --git a/basebmp/test/linetest.cxx b/basebmp/test/linetest.cxx
index 3f4515ebfd72..decb524bc3ba 100644
--- a/basebmp/test/linetest.cxx
+++ b/basebmp/test/linetest.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: linetest.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: thb $ $Date: 2006-06-02 08:36:15 $
+ * last change: $Author: thb $ $Date: 2006-06-08 00:01:48 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -166,7 +166,7 @@ public:
void testBasicVerticalLines()
{
implTestBasicVerticalLines( mpDevice1bpp );
- //implTestBasicVerticalLines( mpDevice32bpp );
+ implTestBasicVerticalLines( mpDevice32bpp );
}
// test pixel rounding (should always tend towards start point of
diff --git a/basebmp/test/makefile.mk b/basebmp/test/makefile.mk
index 1ad61ffd7ede..a87f0ded20ba 100644
--- a/basebmp/test/makefile.mk
+++ b/basebmp/test/makefile.mk
@@ -4,9 +4,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.3 $
+# $Revision: 1.4 $
#
-# last change: $Author: thb $ $Date: 2006-06-02 08:36:15 $
+# last change: $Author: thb $ $Date: 2006-06-08 00:01:48 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
@@ -66,6 +66,7 @@ CFLAGS += -fno-inline
SHL1OBJS= \
$(SLO)$/basictest.obj \
$(SLO)$/bmptest.obj \
+ $(SLO)$/cliptest.obj \
$(SLO)$/filltest.obj \
$(SLO)$/linetest.obj \
$(SLO)$/masktest.obj \