summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/bitmapex.cxx
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-11-05 16:13:12 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-11-06 11:46:04 +0000
commitf120005ea41d59caf4b7d7f6017f3549d25b4287 (patch)
tree10fffb159ac615a2c3e8cdcd2c356c60cb0d61d3 /vcl/source/gdi/bitmapex.cxx
parent3476768dc52dac9ed10a204ffcf000cd042d8993 (diff)
Resolves: #i123500# redefined ColorModifiers and ColorModifierStack...
redefined GraphicAttr to be expressed as primitives if needed, enhanced render and export quality if graphic is modified using graphic attributes (cherry picked from commit 1e79e8da3f8042f7d7bd94b2c9f03cff7545b05c) Conflicts: basegfx/inc/basegfx/color/bcolor.hxx basegfx/inc/basegfx/color/bcolormodifier.hxx basegfx/source/color/bcolormodifier.cxx drawinglayer/inc/drawinglayer/primitive2d/graphicprimitivehelper2d.hxx drawinglayer/inc/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx drawinglayer/inc/drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx drawinglayer/source/primitive2d/graphicprimitive2d.cxx drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx drawinglayer/source/primitive2d/modifiedcolorprimitive2d.cxx drawinglayer/source/primitive3d/modifiedcolorprimitive3d.cxx Change-Id: Ief2172efc9cc1b9838de48ec7f536c05573c7dc3
Diffstat (limited to 'vcl/source/gdi/bitmapex.cxx')
-rw-r--r--vcl/source/gdi/bitmapex.cxx128
1 files changed, 89 insertions, 39 deletions
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index ec0f052d9b61..6deb1db79208 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -1017,58 +1017,110 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod
for(sal_uInt32 a(rBColorModifierStack.count()); a && !bDone; )
{
- const basegfx::BColorModifier& rModifier = rBColorModifierStack.getBColorModifier(--a);
+ const basegfx::BColorModifierSharedPtr& rModifier = rBColorModifierStack.getBColorModifier(--a);
+ const basegfx::BColorModifier_replace* pReplace = dynamic_cast< const basegfx::BColorModifier_replace* >(rModifier.get());
- switch(rModifier.getMode())
+ if(pReplace)
{
- case basegfx::BCOLORMODIFYMODE_REPLACE :
+ // complete replace
+ if(IsTransparent())
{
- // complete replace
- if(IsTransparent())
+ // clear bitmap with dest color
+ if(aChangedBitmap.GetBitCount() <= 8)
{
- // clear bitmap with dest color
- if(aChangedBitmap.GetBitCount() <= 8)
- {
- // do NOT use erase; for e.g. 8bit Bitmaps, the nearest color to the given
- // erase color is determined and used -> this may be different from what is
- // wanted here. Better create a new bitmap with the needed color explicitely
- BitmapReadAccess* pReadAccess = aChangedBitmap.AcquireReadAccess();
- OSL_ENSURE(pReadAccess, "Got no Bitmap ReadAccess ?!?");
+ // do NOT use erase; for e.g. 8bit Bitmaps, the nearest color to the given
+ // erase color is determined and used -> this may be different from what is
+ // wanted here. Better create a new bitmap with the needed color explicitely
+ BitmapReadAccess* pReadAccess = aChangedBitmap.AcquireReadAccess();
+ OSL_ENSURE(pReadAccess, "Got no Bitmap ReadAccess ?!?");
- if(pReadAccess)
- {
- BitmapPalette aNewPalette(pReadAccess->GetPalette());
- aNewPalette[0] = BitmapColor(Color(rModifier.getBColor()));
- aChangedBitmap = Bitmap(
- aChangedBitmap.GetSizePixel(),
- aChangedBitmap.GetBitCount(),
- &aNewPalette);
- delete pReadAccess;
- }
- }
- else
+ if(pReadAccess)
{
- aChangedBitmap.Erase(Color(rModifier.getBColor()));
+ BitmapPalette aNewPalette(pReadAccess->GetPalette());
+ aNewPalette[0] = BitmapColor(Color(pReplace->getBColor()));
+ aChangedBitmap = Bitmap(
+ aChangedBitmap.GetSizePixel(),
+ aChangedBitmap.GetBitCount(),
+ &aNewPalette);
+ delete pReadAccess;
}
}
else
{
- // erase bitmap, caller will know to paint direct
- aChangedBitmap.SetEmpty();
+ aChangedBitmap.Erase(Color(pReplace->getBColor()));
}
-
- bDone = true;
- break;
}
+ else
+ {
+ // erase bitmap, caller will know to paint direct
+ aChangedBitmap.SetEmpty();
+ }
+
+ bDone = true;
+ }
+ else
+ {
+ BitmapWriteAccess* pContent = aChangedBitmap.AcquireWriteAccess();
- default : // BCOLORMODIFYMODE_INTERPOLATE, BCOLORMODIFYMODE_GRAY, BCOLORMODIFYMODE_BLACKANDWHITE
+ if(pContent)
{
- BitmapWriteAccess* pContent = aChangedBitmap.AcquireWriteAccess();
+ const double fConvertColor(1.0 / 255.0);
+
+ if(pContent->HasPalette())
+ {
+ const sal_uInt16 nCount(pContent->GetPaletteEntryCount());
+
+ for(sal_uInt16 b(0); b < nCount; b++)
+ {
+ const BitmapColor& rCol = pContent->GetPaletteColor(b);
+ const basegfx::BColor aBSource(
+ rCol.GetRed() * fConvertColor,
+ rCol.GetGreen() * fConvertColor,
+ rCol.GetBlue() * fConvertColor);
+ const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource));
+ pContent->SetPaletteColor(b, BitmapColor(Color(aBDest)));
+ }
+ }
+ else if(BMP_FORMAT_24BIT_TC_BGR == pContent->GetScanlineFormat())
+ {
+ for(sal_uInt32 y(0L); y < (sal_uInt32)pContent->Height(); y++)
+ {
+ Scanline pScan = pContent->GetScanline(y);
- if(pContent)
+ for(sal_uInt32 x(0L); x < (sal_uInt32)pContent->Width(); x++)
+ {
+ const basegfx::BColor aBSource(
+ *(pScan + 2)* fConvertColor,
+ *(pScan + 1) * fConvertColor,
+ *pScan * fConvertColor);
+ const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource));
+ *pScan++ = static_cast< sal_uInt8 >(aBDest.getBlue() * 255.0);
+ *pScan++ = static_cast< sal_uInt8 >(aBDest.getGreen() * 255.0);
+ *pScan++ = static_cast< sal_uInt8 >(aBDest.getRed() * 255.0);
+ }
+ }
+ }
+ else if(BMP_FORMAT_24BIT_TC_RGB == pContent->GetScanlineFormat())
{
- const double fConvertColor(1.0 / 255.0);
+ for(sal_uInt32 y(0L); y < (sal_uInt32)pContent->Height(); y++)
+ {
+ Scanline pScan = pContent->GetScanline(y);
+ for(sal_uInt32 x(0L); x < (sal_uInt32)pContent->Width(); x++)
+ {
+ const basegfx::BColor aBSource(
+ *pScan * fConvertColor,
+ *(pScan + 1) * fConvertColor,
+ *(pScan + 2) * fConvertColor);
+ const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource));
+ *pScan++ = static_cast< sal_uInt8 >(aBDest.getRed() * 255.0);
+ *pScan++ = static_cast< sal_uInt8 >(aBDest.getGreen() * 255.0);
+ *pScan++ = static_cast< sal_uInt8 >(aBDest.getBlue() * 255.0);
+ }
+ }
+ }
+ else
+ {
for(sal_uInt32 y(0L); y < (sal_uInt32)pContent->Height(); y++)
{
for(sal_uInt32 x(0L); x < (sal_uInt32)pContent->Width(); x++)
@@ -1078,16 +1130,14 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod
(double)aBMCol.GetRed() * fConvertColor,
(double)aBMCol.GetGreen() * fConvertColor,
(double)aBMCol.GetBlue() * fConvertColor);
- const basegfx::BColor aBDest(rModifier.getModifiedColor(aBSource));
+ const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource));
pContent->SetPixel(y, x, BitmapColor(Color(aBDest)));
}
}
-
- delete pContent;
}
- break;
+ delete pContent;
}
}
}