summaryrefslogtreecommitdiff
path: root/basebmp
diff options
context:
space:
mode:
authorThorsten Behrens <thb@openoffice.org>2006-07-12 21:47:21 +0000
committerThorsten Behrens <thb@openoffice.org>2006-07-12 21:47:21 +0000
commit053fdb6c0d6862bb0110917edc5d31ff764fdea8 (patch)
treedb2254c2b97af75974ce067cad981cdf4bdf1772 /basebmp
parent41aac5e01a735244839680528ae6245f1520ceee (diff)
#i65904# Fixed operator+=/-= on PackedPixelRowIterator (wrong overflow handling & forgot to handle negated cases); fixed typo for paletteformats (ignoring bit gravity); made drawMaskedBitmap() work for more cases; improved tests
Diffstat (limited to 'basebmp')
-rw-r--r--basebmp/inc/basebmp/packedpixeliterator.hxx26
-rw-r--r--basebmp/inc/basebmp/paletteformats.hxx6
-rw-r--r--basebmp/source/bitmapdevice.cxx26
-rw-r--r--basebmp/test/basictest.cxx34
-rw-r--r--basebmp/test/bmpdemo.cxx13
-rw-r--r--basebmp/test/cliptest.cxx11
-rw-r--r--basebmp/test/linetest.cxx36
7 files changed, 98 insertions, 54 deletions
diff --git a/basebmp/inc/basebmp/packedpixeliterator.hxx b/basebmp/inc/basebmp/packedpixeliterator.hxx
index 9f6cb1ccfd38..91a048d97ac2 100644
--- a/basebmp/inc/basebmp/packedpixeliterator.hxx
+++ b/basebmp/inc/basebmp/packedpixeliterator.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: packedpixeliterator.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: thb $ $Date: 2006-07-12 15:09:44 $
+ * last change: $Author: thb $ $Date: 2006-07-12 22:47:20 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -355,17 +355,6 @@ public:
PackedPixelRowIterator& operator+=( difference_type d )
{
const difference_type newValue( remainder_ + d );
-
- data_ += newValue / num_intraword_positions;
- remainder_ = newValue % num_intraword_positions;
- update_mask();
-
- return *this;
- }
-
- PackedPixelRowIterator& operator-=( difference_type d )
- {
- const difference_type newValue( remainder_ - d );
const bool isNegative( is_negative(newValue) );
const difference_type newRemainder( newValue % num_intraword_positions );
@@ -373,16 +362,23 @@ public:
// remainder_ = newRemainder;
// for newValue >= 0, and
// data_ += newValue / num_intraword_positions - 1;
- // remainder_ = num_intraword_positions - newRemainder;
+ // remainder_ = newRemainder + num_intraword_positions;
// (to force remainder_ to be positive).
// This is branch-free, if is_negative() is branch-free
data_ += newValue / num_intraword_positions - isNegative;
- remainder_ = newRemainder + isNegative*(num_intraword_positions - 2*newRemainder);
+ remainder_ = newRemainder + isNegative*num_intraword_positions;
update_mask();
return *this;
}
+ PackedPixelRowIterator& operator-=( difference_type d )
+ {
+ // forward to operator+= - which has to cope with negative
+ // values, anyway.
+ return *this += -d;
+ }
+
PackedPixelRowIterator operator+( difference_type d )
{
PackedPixelRowIterator res(*this);
diff --git a/basebmp/inc/basebmp/paletteformats.hxx b/basebmp/inc/basebmp/paletteformats.hxx
index 41ab730f1ed0..c60b365cf6ed 100644
--- a/basebmp/inc/basebmp/paletteformats.hxx
+++ b/basebmp/inc/basebmp/paletteformats.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: paletteformats.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: thb $ $Date: 2006-07-11 11:39:41 $
+ * last change: $Author: thb $ $Date: 2006-07-12 22:47:20 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -127,7 +127,7 @@ template< int BitsPerPixel,
public PixelFormatTraitsTemplate_Palette<
PackedPixelIterator< sal_uInt8,
BitsPerPixel,
- true >,
+ MsbFirst >,
NonStandardAccessor< sal_uInt8 > >
{};
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 8d293b06d74e..64975d9ca5de 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: bitmapdevice.cxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: thb $ $Date: 2006-07-12 15:09:44 $
+ * last change: $Author: thb $ $Date: 2006-07-12 22:47:21 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -1019,7 +1019,7 @@ namespace
const BitmapDeviceSharedPtr& rClip )
{
// xxx TODO
- if( isCompatibleClipMask(rClip) &&
+ if( isCompatibleClipMask(rMask) &&
isCompatibleBitmap(rSrcBitmap) )
{
if( drawMode == DrawMode_XOR )
@@ -1559,7 +1559,7 @@ void BitmapDevice::drawMaskedColor( Color rSrcColor,
if( isCompatibleClipMask( rAlphaMask ) || isCompatibleAlphaMask( rAlphaMask ) )
drawMaskedColor_i( rSrcColor, rAlphaMask, aSrcRange, aDestPoint );
else
- OSL_ENSURE(false, "Generic output not yet implemented!");
+ OSL_ENSURE( false, "drawMaskedColor(): Generic output not yet implemented #1!" );
}
#endif
}
@@ -1611,7 +1611,7 @@ void BitmapDevice::drawMaskedColor( Color aSrcColor,
}
else
{
- OSL_ENSURE(false, "Generic output not yet implemented!");
+ OSL_ENSURE(false, "drawMaskedColor(): Generic output not yet implemented #2!");
}
#endif
}
@@ -1650,15 +1650,7 @@ void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
rSrcRect, rDstRect, drawMode );
}
#else
- if( isCompatibleBitmap( rSrcBitmap ) &&
- isCompatibleClipMask( rMask ) )
- {
- drawMaskedBitmap_i( rSrcBitmap, rMask, aSrcRange, aDestRange, drawMode );
- }
- else
- {
- OSL_ENSURE(false, "Generic output not yet implemented!");
- }
+ drawMaskedBitmap_i( rSrcBitmap, rMask, aSrcRange, aDestRange, drawMode );
#endif
}
}
@@ -1704,15 +1696,13 @@ void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
rDstRect, drawMode, rClip );
}
#else
- if( isCompatibleBitmap( rSrcBitmap ) &&
- isCompatibleClipMask( rMask ) &&
- isCompatibleClipMask( rClip ) )
+ if( isCompatibleClipMask( rClip ) )
{
drawMaskedBitmap_i( rSrcBitmap, rMask, aSrcRange, aDestRange, drawMode, rClip );
}
else
{
- OSL_ENSURE(false, "Generic output not yet implemented!");
+ OSL_ENSURE(false, "drawMaskedBitmap(): Generic output not yet implemented #2!");
}
#endif
}
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx
index 46776ce061ee..20a3e09df063 100644
--- a/basebmp/test/basictest.cxx
+++ b/basebmp/test/basictest.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: basictest.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: thb $ $Date: 2006-07-12 15:09:45 $
+ * last change: $Author: thb $ $Date: 2006-07-12 22:47:21 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -163,6 +163,34 @@ public:
CPPUNIT_ASSERT_MESSAGE("setPixel clipping",
countPixel(pDevice, aCol2) == nPixel);
+ CPPUNIT_ASSERT_MESSAGE("raw pixel value #1",
+ pDevice->getBuffer()[0] == 0x80);
+
+ // 1bit LSB
+ {
+ pDevice = createBitmapDevice( aSize,
+ true,
+ Format::ONE_BIT_LSB_PAL );
+
+ pDevice->setPixel( aPt2, aCol, DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #4",
+ pDevice->getPixel(aPt2) == aCol);
+
+ const basegfx::B2IPoint aPt222(1,1);
+ pDevice->setPixel( aPt222, aCol, DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #5",
+ pDevice->getPixel(aPt222) == aCol);
+
+ pDevice->setPixel( aPt3, aCol, DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #6",
+ pDevice->getPixel(aPt3) == aCol);
+
+ CPPUNIT_ASSERT_MESSAGE("raw pixel value #2",
+ pDevice->getBuffer()[0] == 0x01);
+ CPPUNIT_ASSERT_MESSAGE("raw pixel value #3",
+ pDevice->getBuffer()[8] == 0x02);
+ }
+
// 8bit alpha
{
pDevice = createBitmapDevice( aSize,
@@ -195,13 +223,11 @@ public:
const Color aCol4(0x00101010);
pDevice->setPixel( aPt, aCol4, DrawMode_PAINT );
- std::ofstream output("16bpp_test.dump");
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #7",
pDevice->getPixel(aPt) == aCol4);
const Color aCol5(0x00F0F0F0);
pDevice->setPixel( aPt2, aCol5, DrawMode_PAINT );
- debugDump( pDevice, output );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #8",
pDevice->getPixel(aPt2) != aCol7);
diff --git a/basebmp/test/bmpdemo.cxx b/basebmp/test/bmpdemo.cxx
index fc5c7752fe06..b8cb431a2321 100644
--- a/basebmp/test/bmpdemo.cxx
+++ b/basebmp/test/bmpdemo.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: bmpdemo.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: thb $ $Date: 2006-07-11 11:38:56 $
+ * last change: $Author: thb $ $Date: 2006-07-12 22:47:21 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -1086,6 +1086,12 @@ void TestWindow::Paint( const Rectangle& rRect )
false,
basebmp::Format::ONE_BIT_MSB_GREY ));
+ const basegfx::B2IPoint aPt111(10,10);
+ const basegfx::B2IPoint aPt222(0,10);
+ const basebmp::Color aCol333(0xFFFFFFFF);
+ pMask->drawLine( aPt111, aPt222, aCol333, basebmp::DrawMode_PAINT );
+
+
::rtl::OUString aSvg = ::rtl::OUString::createFromAscii(
"m 0 0 h5 l5 5 v5 h-5 l-5-5 z" );
basegfx::B2DPolyPolygon aPoly;
@@ -1173,9 +1179,6 @@ void TestWindow::Paint( const Rectangle& rRect )
aPoint.setY( (int)((((double)aP2.getY())*cosd + ((double)aP2.getX())*sind)*factor) );
aP2 = aPoint;
}
-
- std::ofstream output4("svptest.dump");
- debugDump( pDevice, output4 );
}
Bitmap aBitmap( Size(aTestSize.getX(),
diff --git a/basebmp/test/cliptest.cxx b/basebmp/test/cliptest.cxx
index cdf3fdf2b32f..38e6797c13c1 100644
--- a/basebmp/test/cliptest.cxx
+++ b/basebmp/test/cliptest.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: cliptest.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: thb $ $Date: 2006-07-11 11:38:56 $
+ * last change: $Author: thb $ $Date: 2006-07-12 22:47:21 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -128,8 +128,8 @@ private:
DrawMode_PAINT,
mpClipMask );
const basegfx::B2IPoint aPt(0,10);
- CPPUNIT_ASSERT_MESSAGE("number of clipped pixel is not 28",
- countPixel( rDevice, rDevice->getPixel(aPt) ) == 121-28);
+ CPPUNIT_ASSERT_MESSAGE("number of clipped pixel is not 30",
+ countPixel( rDevice, rDevice->getPixel(aPt) ) == 121-30);
}
void implTestBmpClip(const BitmapDeviceSharedPtr& rDevice)
@@ -213,9 +213,6 @@ public:
aPoly.getB2DPolygon(0),
Color(0),
DrawMode_PAINT );
-
- std::ofstream output("clipmask.dump");
- debugDump( mpClipMask, output );
}
void testPixelClip()
diff --git a/basebmp/test/linetest.cxx b/basebmp/test/linetest.cxx
index decb524bc3ba..aaf4206cf9f7 100644
--- a/basebmp/test/linetest.cxx
+++ b/basebmp/test/linetest.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: linetest.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: thb $ $Date: 2006-06-08 00:01:48 $
+ * last change: $Author: thb $ $Date: 2006-07-12 22:47:21 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -93,6 +93,31 @@ private:
countPixel( rDevice, aCol ) == 9);
}
+ void implTestBasicHorizontalLines(const BitmapDeviceSharedPtr& rDevice)
+ {
+ rDevice->clear(Color(0));
+
+ const basegfx::B2IPoint aPt1(10,10);
+ const basegfx::B2IPoint aPt2(0,10);
+ const Color aCol(0xFFFFFFFF);
+ rDevice->drawLine( aPt1, aPt2, aCol, DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("first pixel set",
+ rDevice->getPixel(aPt1) == aCol);
+ CPPUNIT_ASSERT_MESSAGE("last pixel set",
+ rDevice->getPixel(aPt2) == aCol);
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 11",
+ countPixel( rDevice, aCol ) == 11);
+
+ rDevice->clear(Color(0));
+ rDevice->drawLine( aPt2, aPt1, aCol, DrawMode_PAINT );
+ CPPUNIT_ASSERT_MESSAGE("first pixel set",
+ rDevice->getPixel(aPt1) == aCol);
+ CPPUNIT_ASSERT_MESSAGE("last pixel set",
+ rDevice->getPixel(aPt2) == aCol);
+ CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 11",
+ countPixel( rDevice, aCol ) == 11);
+ }
+
void implTestBasicVerticalLines(const BitmapDeviceSharedPtr& rDevice)
{
rDevice->clear(Color(0));
@@ -163,6 +188,12 @@ public:
implTestBasicDiagonalLines( mpDevice32bpp );
}
+ void testBasicHorizontalLines()
+ {
+ implTestBasicHorizontalLines( mpDevice1bpp );
+ implTestBasicHorizontalLines( mpDevice32bpp );
+ }
+
void testBasicVerticalLines()
{
implTestBasicVerticalLines( mpDevice1bpp );
@@ -183,6 +214,7 @@ public:
CPPUNIT_TEST_SUITE(LineTest);
CPPUNIT_TEST(testBasicDiagonalLines);
+ CPPUNIT_TEST(testBasicHorizontalLines);
CPPUNIT_TEST(testBasicVerticalLines);
CPPUNIT_TEST(testTieBreaking);
CPPUNIT_TEST_SUITE_END();