summaryrefslogtreecommitdiff
path: root/basebmp
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@suse.com>2011-11-04 10:30:56 +0100
committerThorsten Behrens <tbehrens@suse.com>2011-11-04 10:40:08 +0100
commita6a391da8d6e3aa2b9f30c9f8b664014dc2ae02c (patch)
treeaab357789436339cc6f65910822aa2ec7597a206 /basebmp
parent504b384dd1c74838f34d5caa27f3e916bb309a8c (diff)
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.
Diffstat (limited to 'basebmp')
-rw-r--r--basebmp/inc/basebmp/bitmapdevice.hxx10
-rw-r--r--basebmp/source/bitmapdevice.cxx16
-rw-r--r--basebmp/test/basictest.cxx5
3 files changed, 31 insertions, 0 deletions
diff --git a/basebmp/inc/basebmp/bitmapdevice.hxx b/basebmp/inc/basebmp/bitmapdevice.hxx
index 62b459bfc7eb..ca11292aefec 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 958b8755d49e..6f208cf25ca7 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 63292729d419..2f262e5bbb0f 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);