[Libreoffice-commits] .: basebmp/inc basebmp/source basebmp/test
Thorsten Behrens
thorsten at kemper.freedesktop.org
Fri Nov 4 02:41:47 PDT 2011
basebmp/inc/basebmp/bitmapdevice.hxx | 10 ++++++++++
basebmp/source/bitmapdevice.cxx | 16 ++++++++++++++++
basebmp/test/basictest.cxx | 5 +++++
3 files changed, 31 insertions(+)
New commits:
commit a6a391da8d6e3aa2b9f30c9f8b664014dc2ae02c
Author: Thorsten Behrens <tbehrens at suse.com>
Date: Fri Nov 4 10:30:56 2011 +0100
Put BitmapDevice::getPixelData() back.
Slight tweak of d0d62edf3f398e9ddb2fd0f1f5fbe1dd0393ff47 - getPixel()
and getPixelData() are complementary functions, similar in spirit
to const and non-const getters. Added unit test for it to avoid
flagging it for removal again.
diff --git a/basebmp/inc/basebmp/bitmapdevice.hxx b/basebmp/inc/basebmp/bitmapdevice.hxx
index 62b459b..ca11292 100644
--- a/basebmp/inc/basebmp/bitmapdevice.hxx
+++ b/basebmp/inc/basebmp/bitmapdevice.hxx
@@ -186,6 +186,14 @@ public:
*/
Color getPixel( const basegfx::B2IPoint& rPt );
+ /** Get underlying pixel data value at given position
+
+ This method returns the raw pixel data. In the case of
+ paletted bitmaps, this is the palette index, not the final
+ color value.
+ */
+ sal_uInt32 getPixelData( const basegfx::B2IPoint& rPt );
+
/** Draw a line
@param rPt1
@@ -570,6 +578,8 @@ private:
virtual Color getPixel_i( const basegfx::B2IPoint& rPt ) = 0;
+ virtual sal_uInt32 getPixelData_i( const basegfx::B2IPoint& rPt ) = 0;
+
virtual void drawLine_i( const basegfx::B2IPoint& rPt1,
const basegfx::B2IPoint& rPt2,
const basegfx::B2IBox& rBounds,
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 958b875..6f208cf 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -452,6 +452,14 @@ namespace
return maAccessor(pixel);
}
+ virtual sal_uInt32 getPixelData_i( const basegfx::B2IPoint& rPt )
+ {
+ const DestIterator pixel( maBegin +
+ vigra::Diff2D(rPt.getX(),
+ rPt.getY()) );
+ return maToUInt32Converter(maRawAccessor(pixel));
+ }
+
template< typename Iterator, typename Col, typename RawAcc >
void implRenderLine2( const basegfx::B2IPoint& rPt1,
const basegfx::B2IPoint& rPt2,
@@ -1176,6 +1184,14 @@ Color BitmapDevice::getPixel( const basegfx::B2IPoint& rPt )
return Color();
}
+sal_uInt32 BitmapDevice::getPixelData( const basegfx::B2IPoint& rPt )
+{
+ if( mpImpl->maBounds.isInside(rPt) )
+ return getPixelData_i(rPt);
+
+ return 0;
+}
+
void BitmapDevice::drawLine( const basegfx::B2IPoint& rPt1,
const basegfx::B2IPoint& rPt2,
Color lineColor,
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx
index 6329272..2f262e5 100644
--- a/basebmp/test/basictest.cxx
+++ b/basebmp/test/basictest.cxx
@@ -140,10 +140,15 @@ public:
Format::ONE_BIT_MSB_PAL ));
const basegfx::B2IPoint aPt(3,3);
+ CPPUNIT_ASSERT_MESSAGE("getPixelData for virgin device",
+ pDevice->getPixelData(aPt) == 0);
+
const Color aCol(0xFFFFFFFF);
pDevice->setPixel( aPt, aCol, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #1",
pDevice->getPixel(aPt) == aCol);
+ CPPUNIT_ASSERT_MESSAGE("getPixelData for white pixel",
+ pDevice->getPixelData(aPt) == 1);
const basegfx::B2IPoint aPt2(0,0);
const Color aCol2(0xFFFFFFFF);
More information about the Libreoffice-commits
mailing list