Kaydet (Commit) f120005e authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

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 1e79e8da)

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
üst 3476768d
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
#include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <drawinglayer/primitive2d/maskprimitive2d.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
#include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/numeric/ftools.hxx>
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// helper class for animated graphics // helper class for animated graphics
...@@ -324,4 +326,137 @@ namespace drawinglayer ...@@ -324,4 +326,137 @@ namespace drawinglayer
} // end of namespace primitive2d } // end of namespace primitive2d
} // end of namespace drawinglayer } // end of namespace drawinglayer
//////////////////////////////////////////////////////////////////////////////
namespace drawinglayer
{
namespace primitive2d
{
Primitive2DSequence create2DColorModifierEmbeddingsAsNeeded(
const Primitive2DSequence& rChildren,
GraphicDrawMode aGraphicDrawMode,
double fLuminance,
double fContrast,
double fRed,
double fGreen,
double fBlue,
double fGamma,
bool bInvert)
{
Primitive2DSequence aRetval;
if(!rChildren.getLength())
{
// no child content, done
return aRetval;
}
// set child content as retval; that is what will be used as child content in all
// embeddings from here
aRetval = rChildren;
if(GRAPHICDRAWMODE_WATERMARK == aGraphicDrawMode)
{
// this is solved by applying fixed values additionally to luminance
// and contrast, do it here and reset DrawMode to GRAPHICDRAWMODE_STANDARD
// original in svtools uses:
// #define WATERMARK_LUM_OFFSET 50
// #define WATERMARK_CON_OFFSET -70
fLuminance = basegfx::clamp(fLuminance + 0.5, -1.0, 1.0);
fContrast = basegfx::clamp(fContrast - 0.7, -1.0, 1.0);
aGraphicDrawMode = GRAPHICDRAWMODE_STANDARD;
}
// DrawMode (GRAPHICDRAWMODE_WATERMARK already handled)
switch(aGraphicDrawMode)
{
case GRAPHICDRAWMODE_GREYS:
{
// convert to grey
const Primitive2DReference aPrimitiveGrey(
new ModifiedColorPrimitive2D(
aRetval,
basegfx::BColorModifierSharedPtr(
new basegfx::BColorModifier_gray())));
aRetval = Primitive2DSequence(&aPrimitiveGrey, 1);
break;
}
case GRAPHICDRAWMODE_MONO:
{
// convert to mono (black/white with threshold 0.5)
const Primitive2DReference aPrimitiveBlackAndWhite(
new ModifiedColorPrimitive2D(
aRetval,
basegfx::BColorModifierSharedPtr(
new basegfx::BColorModifier_black_and_white(0.5))));
aRetval = Primitive2DSequence(&aPrimitiveBlackAndWhite, 1);
break;
}
case GRAPHICDRAWMODE_WATERMARK:
{
OSL_ENSURE(false, "OOps, GRAPHICDRAWMODE_WATERMARK should already be handled (see above)");
// fallthrough intended
}
default: // case GRAPHICDRAWMODE_STANDARD:
{
// nothing to do
break;
}
}
// mnContPercent, mnLumPercent, mnRPercent, mnGPercent, mnBPercent
// handled in a single call
if(!basegfx::fTools::equalZero(fLuminance)
|| !basegfx::fTools::equalZero(fContrast)
|| !basegfx::fTools::equalZero(fRed)
|| !basegfx::fTools::equalZero(fGreen)
|| !basegfx::fTools::equalZero(fBlue))
{
const Primitive2DReference aPrimitiveRGBLuminannceContrast(
new ModifiedColorPrimitive2D(
aRetval,
basegfx::BColorModifierSharedPtr(
new basegfx::BColorModifier_RGBLuminanceContrast(
fRed,
fGreen,
fBlue,
fLuminance,
fContrast))));
aRetval = Primitive2DSequence(&aPrimitiveRGBLuminannceContrast, 1);
}
// gamma (boolean)
if(!basegfx::fTools::equal(fGamma, 1.0))
{
const Primitive2DReference aPrimitiveGamma(
new ModifiedColorPrimitive2D(
aRetval,
basegfx::BColorModifierSharedPtr(
new basegfx::BColorModifier_gamma(
fGamma))));
aRetval = Primitive2DSequence(&aPrimitiveGamma, 1);
}
// invert (boolean)
if(bInvert)
{
const Primitive2DReference aPrimitiveInvert(
new ModifiedColorPrimitive2D(
aRetval,
basegfx::BColorModifierSharedPtr(
new basegfx::BColorModifier_invert())));
aRetval = Primitive2DSequence(&aPrimitiveInvert, 1);
}
return aRetval;
}
} // end of namespace primitive2d
} // end of namespace drawinglayer
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1057,7 +1057,9 @@ namespace ...@@ -1057,7 +1057,9 @@ namespace
rTargetHolders.Current().append( rTargetHolders.Current().append(
new drawinglayer::primitive2d::ModifiedColorPrimitive2D( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aSubContent, aSubContent,
basegfx::BColorModifier(basegfx::BColor(0.0, 0.0, 0.0)))); basegfx::BColorModifierSharedPtr(
new basegfx::BColorModifier_replace(
basegfx::BColor(0.0, 0.0, 0.0)))));
} }
else // if(rPropertyHolders.Current().isRasterOpInvert()) else // if(rPropertyHolders.Current().isRasterOpInvert())
{ {
......
...@@ -32,7 +32,7 @@ namespace drawinglayer ...@@ -32,7 +32,7 @@ namespace drawinglayer
{ {
ModifiedColorPrimitive2D::ModifiedColorPrimitive2D( ModifiedColorPrimitive2D::ModifiedColorPrimitive2D(
const Primitive2DSequence& rChildren, const Primitive2DSequence& rChildren,
const basegfx::BColorModifier& rColorModifier) const basegfx::BColorModifierSharedPtr& rColorModifier)
: GroupPrimitive2D(rChildren), : GroupPrimitive2D(rChildren),
maColorModifier(rColorModifier) maColorModifier(rColorModifier)
{ {
...@@ -44,7 +44,17 @@ namespace drawinglayer ...@@ -44,7 +44,17 @@ namespace drawinglayer
{ {
const ModifiedColorPrimitive2D& rCompare = (ModifiedColorPrimitive2D&)rPrimitive; const ModifiedColorPrimitive2D& rCompare = (ModifiedColorPrimitive2D&)rPrimitive;
return (getColorModifier() == rCompare.getColorModifier()); if(getColorModifier().get() == rCompare.getColorModifier().get())
{
return true;
}
if(!getColorModifier().get() || !rCompare.getColorModifier().get())
{
return false;
}
return *getColorModifier().get() == *rCompare.getColorModifier().get();
} }
return false; return false;
......
...@@ -73,8 +73,13 @@ namespace drawinglayer ...@@ -73,8 +73,13 @@ namespace drawinglayer
if(getChildren().hasElements()) if(getChildren().hasElements())
{ {
// create a modifiedColorPrimitive containing the shadow color and the content // create a modifiedColorPrimitive containing the shadow color and the content
const basegfx::BColorModifier aBColorModifier(getShadowColor()); const basegfx::BColorModifierSharedPtr aBColorModifier(
const Primitive2DReference xRefA(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier)); new basegfx::BColorModifier_replace(
getShadowColor()));
const Primitive2DReference xRefA(
new ModifiedColorPrimitive2D(
getChildren(),
aBColorModifier));
const Primitive2DSequence aSequenceB(&xRefA, 1L); const Primitive2DSequence aSequenceB(&xRefA, 1L);
// build transformed primitiveVector with shadow offset and add to target // build transformed primitiveVector with shadow offset and add to target
......
...@@ -84,20 +84,44 @@ namespace drawinglayer ...@@ -84,20 +84,44 @@ namespace drawinglayer
if(bDefaultTextColor) if(bDefaultTextColor)
{ {
// emboss/engrave in black, original forced to white // emboss/engrave in black, original forced to white
const basegfx::BColorModifier aBColorModifierToGray(basegfx::BColor(0.0)); const basegfx::BColorModifierSharedPtr aBColorModifierToGray(
const Primitive2DReference xModifiedColor(new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToGray)); new basegfx::BColorModifier_replace(
aRetval[0] = Primitive2DReference(new TransformPrimitive2D(aTransform, Primitive2DSequence(&xModifiedColor, 1))); basegfx::BColor(0.0)));
const Primitive2DReference xModifiedColor(
new ModifiedColorPrimitive2D(
getTextContent(),
aBColorModifierToGray));
aRetval[0] = Primitive2DReference(
new TransformPrimitive2D(
aTransform,
Primitive2DSequence(&xModifiedColor, 1)));
// add original, too // add original, too
const basegfx::BColorModifier aBColorModifierToWhite(basegfx::BColor(1.0)); const basegfx::BColorModifierSharedPtr aBColorModifierToWhite(
aRetval[1] = Primitive2DReference(new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToWhite)); new basegfx::BColorModifier_replace(
basegfx::BColor(1.0)));
aRetval[1] = Primitive2DReference(
new ModifiedColorPrimitive2D(
getTextContent(),
aBColorModifierToWhite));
} }
else else
{ {
// emboss/engrave in gray, keep original's color // emboss/engrave in gray, keep original's color
const basegfx::BColorModifier aBColorModifierToGray(basegfx::BColor(0.75)); // 192 const basegfx::BColorModifierSharedPtr aBColorModifierToGray(
const Primitive2DReference xModifiedColor(new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToGray)); new basegfx::BColorModifier_replace(
aRetval[0] = Primitive2DReference(new TransformPrimitive2D(aTransform, Primitive2DSequence(&xModifiedColor, 1))); basegfx::BColor(0.75))); // 192
const Primitive2DReference xModifiedColor(
new ModifiedColorPrimitive2D(
getTextContent(),
aBColorModifierToGray));
aRetval[0] = Primitive2DReference(
new TransformPrimitive2D(
aTransform,
Primitive2DSequence(&xModifiedColor, 1)));
// add original, too // add original, too
aRetval[1] = Primitive2DReference(new GroupPrimitive2D(getTextContent())); aRetval[1] = Primitive2DReference(new GroupPrimitive2D(getTextContent()));
...@@ -144,8 +168,13 @@ namespace drawinglayer ...@@ -144,8 +168,13 @@ namespace drawinglayer
aRetval[7] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); aRetval[7] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent()));
// at last, place original over it, but force to white // at last, place original over it, but force to white
const basegfx::BColorModifier aBColorModifierToWhite(basegfx::BColor(1.0, 1.0, 1.0)); const basegfx::BColorModifierSharedPtr aBColorModifierToWhite(
aRetval[8] = Primitive2DReference(new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToWhite)); new basegfx::BColorModifier_replace(
basegfx::BColor(1.0, 1.0, 1.0)));
aRetval[8] = Primitive2DReference(
new ModifiedColorPrimitive2D(
getTextContent(),
aBColorModifierToWhite));
break; break;
} }
......
...@@ -32,7 +32,7 @@ namespace drawinglayer ...@@ -32,7 +32,7 @@ namespace drawinglayer
{ {
ModifiedColorPrimitive3D::ModifiedColorPrimitive3D( ModifiedColorPrimitive3D::ModifiedColorPrimitive3D(
const Primitive3DSequence& rChildren, const Primitive3DSequence& rChildren,
const basegfx::BColorModifier& rColorModifier) const basegfx::BColorModifierSharedPtr& rColorModifier)
: GroupPrimitive3D(rChildren), : GroupPrimitive3D(rChildren),
maColorModifier(rColorModifier) maColorModifier(rColorModifier)
{ {
...@@ -44,7 +44,17 @@ namespace drawinglayer ...@@ -44,7 +44,17 @@ namespace drawinglayer
{ {
const ModifiedColorPrimitive3D& rCompare = (ModifiedColorPrimitive3D&)rPrimitive; const ModifiedColorPrimitive3D& rCompare = (ModifiedColorPrimitive3D&)rPrimitive;
return (maColorModifier == rCompare.maColorModifier); if(getColorModifier().get() == rCompare.getColorModifier().get())
{
return true;
}
if(!getColorModifier().get() || !rCompare.getColorModifier().get())
{
return false;
}
return *getColorModifier().get() == *rCompare.getColorModifier().get();
} }
return false; return false;
......
...@@ -247,8 +247,13 @@ namespace drawinglayer ...@@ -247,8 +247,13 @@ namespace drawinglayer
if(::com::sun::star::drawing::TextureKind2_LUMINANCE == aSdr3DObjectAttribute.getTextureKind()) if(::com::sun::star::drawing::TextureKind2_LUMINANCE == aSdr3DObjectAttribute.getTextureKind())
{ {
// use modified color primitive to force textures to gray // use modified color primitive to force textures to gray
const basegfx::BColorModifier aBColorModifier(basegfx::BColor(), 0.0, basegfx::BCOLORMODIFYMODE_GRAY); const basegfx::BColorModifierSharedPtr aBColorModifier(
const Primitive3DReference xRef2(new ModifiedColorPrimitive3D(aRetval, aBColorModifier)); new basegfx::BColorModifier_gray());
const Primitive3DReference xRef2(
new ModifiedColorPrimitive3D(
aRetval,
aBColorModifier));
aRetval = Primitive3DSequence(&xRef2, 1L); aRetval = Primitive3DSequence(&xRef2, 1L);
} }
} }
......
...@@ -688,9 +688,10 @@ namespace drawinglayer ...@@ -688,9 +688,10 @@ namespace drawinglayer
if(nBColorModifierStackCount) if(nBColorModifierStackCount)
{ {
const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1); const basegfx::BColorModifierSharedPtr& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1);
const basegfx::BColorModifier_replace* pReplacer = dynamic_cast< const basegfx::BColorModifier_replace* >(rTopmostModifier.get());
if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode()) if(pReplacer)
{ {
// the bitmap fill is in unified color, so we can replace it with // the bitmap fill is in unified color, so we can replace it with
// a single polygon fill. The form of the fill depends on tiling // a single polygon fill. The form of the fill depends on tiling
...@@ -701,7 +702,7 @@ namespace drawinglayer ...@@ -701,7 +702,7 @@ namespace drawinglayer
aLocalPolyPolygon.transform(maCurrentTransformation); aLocalPolyPolygon.transform(maCurrentTransformation);
mpOutputDevice->SetLineColor(); mpOutputDevice->SetLineColor();
mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor())); mpOutputDevice->SetFillColor(Color(pReplacer->getBColor()));
mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
} }
else else
...@@ -733,7 +734,7 @@ namespace drawinglayer ...@@ -733,7 +734,7 @@ namespace drawinglayer
{ {
aTarget.transform(maCurrentTransformation); aTarget.transform(maCurrentTransformation);
mpOutputDevice->SetLineColor(); mpOutputDevice->SetLineColor();
mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor())); mpOutputDevice->SetFillColor(Color(pReplacer->getBColor()));
mpOutputDevice->DrawPolyPolygon(aTarget); mpOutputDevice->DrawPolyPolygon(aTarget);
} }
} }
......
...@@ -114,14 +114,12 @@ namespace drawinglayer ...@@ -114,14 +114,12 @@ namespace drawinglayer
maContent.Erase(); maContent.Erase();
// embed primitives to paint them black // embed primitives to paint them black
static basegfx::BColorModifyMode aMode = basegfx::BCOLORMODIFYMODE_REPLACE;
const primitive2d::Primitive2DReference xRef( const primitive2d::Primitive2DReference xRef(
new primitive2d::ModifiedColorPrimitive2D( new primitive2d::ModifiedColorPrimitive2D(
aSequence, aSequence,
basegfx::BColorModifier( basegfx::BColorModifierSharedPtr(
basegfx::BColor(0.0, 0.0, 0.0), new basegfx::BColorModifier_replace(
0.5, basegfx::BColor(0.0, 0.0, 0.0)))));
aMode)));
const primitive2d::Primitive2DSequence xSeq(&xRef, 1); const primitive2d::Primitive2DSequence xSeq(&xRef, 1);
// render // render
......
...@@ -190,18 +190,20 @@ namespace basegfx ...@@ -190,18 +190,20 @@ namespace basegfx
} }
// clamp color to [0.0..1.0] values in all three intensity components // clamp color to [0.0..1.0] values in all three intensity components
void clamp() BColor& clamp()
{ {
mfX = basegfx::clamp(mfX, 0.0, 1.0); mfX = basegfx::clamp(mfX, 0.0, 1.0);
mfY = basegfx::clamp(mfY, 0.0, 1.0); mfY = basegfx::clamp(mfY, 0.0, 1.0);
mfZ = basegfx::clamp(mfZ, 0.0, 1.0); mfZ = basegfx::clamp(mfZ, 0.0, 1.0);
return *this;
} }
void invert() BColor& invert()
{ {
mfX = 1.0 - mfX; mfX = 1.0 - mfX;
mfY = 1.0 - mfY; mfY = 1.0 - mfY;
mfZ = 1.0 - mfZ; mfZ = 1.0 - mfZ;
return *this;
} }
static const BColor& getEmptyBColor() static const BColor& getEmptyBColor()
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <drawinglayer/drawinglayerdllapi.h> #include <drawinglayer/drawinglayerdllapi.h>
#include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
#include <svtools/grfmgr.hxx>
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// predefines // predefines
...@@ -44,6 +45,22 @@ namespace drawinglayer ...@@ -44,6 +45,22 @@ namespace drawinglayer
Primitive2DSequence create2DDecompositionOfGraphic( Primitive2DSequence create2DDecompositionOfGraphic(
const Graphic& rGraphic, const Graphic& rGraphic,
const basegfx::B2DHomMatrix& rTransform); const basegfx::B2DHomMatrix& rTransform);
/** Helper to embed given sequence of primitives to evtl. a stack
of ModifiedColorPrimitive2D's to get all the needed modifications
applied.
*/
Primitive2DSequence create2DColorModifierEmbeddingsAsNeeded(
const Primitive2DSequence& rChildren,
GraphicDrawMode aGraphicDrawMode = GRAPHICDRAWMODE_STANDARD,
double fLuminance = 0.0, // [-1.0 .. 1.0]
double fContrast = 0.0, // [-1.0 .. 1.0]
double fRed = 0.0, // [-1.0 .. 1.0]
double fGreen = 0.0, // [-1.0 .. 1.0]
double fBlue = 0.0, // [-1.0 .. 1.0]
double fGamma = 1.0, // ]0.0 .. 10.0]
bool bInvert = false);
} // end of namespace primitive2d } // end of namespace primitive2d
} // end of namespace drawinglayer } // end of namespace drawinglayer
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MODIFIEDCOLORPRIMITIVE2D_HXX #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MODIFIEDCOLORPRIMITIVE2D_HXX
#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MODIFIEDCOLORPRIMITIVE2D_HXX #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_MODIFIEDCOLORPRIMITIVE2D_HXX
...@@ -42,7 +44,7 @@ namespace drawinglayer ...@@ -42,7 +44,7 @@ namespace drawinglayer
For the possibilities of color modifications, please refer For the possibilities of color modifications, please refer
to the basegfx::BColorModifier definitions in basegfx. For to the basegfx::BColorModifier definitions in basegfx. For
processing there is tooling in basegfx to build a stack of processing there is tooling in basegfx to build a stack of
BColorModifiers to always be able to proccess the correct BColorModifierSharedPtrs to always be able to proccess the correct
colors. colors.
If a renderer does not handle this primitive, the content will If a renderer does not handle this primitive, the content will
...@@ -52,16 +54,16 @@ namespace drawinglayer ...@@ -52,16 +54,16 @@ namespace drawinglayer
{ {
private: private:
/// The ColorModifier to use /// The ColorModifier to use
basegfx::BColorModifier maColorModifier; basegfx::BColorModifierSharedPtr maColorModifier;
public: public:
/// constructor /// constructor
ModifiedColorPrimitive2D( ModifiedColorPrimitive2D(
const Primitive2DSequence& rChildren, const Primitive2DSequence& rChildren,
const basegfx::BColorModifier& rColorModifier); const basegfx::BColorModifierSharedPtr& rColorModifier);
/// data read access /// data read access
const basegfx::BColorModifier& getColorModifier() const { return maColorModifier; } const basegfx::BColorModifierSharedPtr& getColorModifier() const { return maColorModifier; }
/// compare operator /// compare operator
virtual bool operator==(const BasePrimitive2D& rPrimitive) const; virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
......
...@@ -42,16 +42,16 @@ namespace drawinglayer ...@@ -42,16 +42,16 @@ namespace drawinglayer
{ {
private: private:
/// The ColorModifier to use /// The ColorModifier to use
basegfx::BColorModifier maColorModifier; basegfx::BColorModifierSharedPtr maColorModifier;
public: public:
/// constructor /// constructor
ModifiedColorPrimitive3D( ModifiedColorPrimitive3D(
const Primitive3DSequence& rChildren, const Primitive3DSequence& rChildren,
const basegfx::BColorModifier& rColorModifier); const basegfx::BColorModifierSharedPtr& rColorModifier);
/// data read access /// data read access
const basegfx::BColorModifier& getColorModifier() const { return maColorModifier; } const basegfx::BColorModifierSharedPtr& getColorModifier() const { return maColorModifier; }
/// compare operator /// compare operator
virtual bool operator==(const BasePrimitive3D& rPrimitive) const; virtual bool operator==(const BasePrimitive3D& rPrimitive) const;
......
...@@ -261,10 +261,8 @@ namespace svgio ...@@ -261,10 +261,8 @@ namespace svgio
const drawinglayer::primitive2d::Primitive2DReference xInverseMask( const drawinglayer::primitive2d::Primitive2DReference xInverseMask(
new drawinglayer::primitive2d::ModifiedColorPrimitive2D( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aMaskTarget, aMaskTarget,
basegfx::BColorModifier( basegfx::BColorModifierSharedPtr(
basegfx::BColor(0.0, 0.0, 0.0), new basegfx::BColorModifier_luminance_to_alpha())));
0.5,
basegfx::BCOLORMODIFYMODE_LUMINANCE_TO_ALPHA)));
aMaskTarget = drawinglayer::primitive2d::Primitive2DSequence(&xInverseMask, 1); aMaskTarget = drawinglayer::primitive2d::Primitive2DSequence(&xInverseMask, 1);
} }
......
...@@ -328,8 +328,15 @@ namespace sdr ...@@ -328,8 +328,15 @@ namespace sdr
if(isPrimitiveGhosted(rDisplayInfo)) if(isPrimitiveGhosted(rDisplayInfo))
{ {
const basegfx::BColor aRGBWhite(1.0, 1.0, 1.0); const basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
const basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, basegfx::BCOLORMODIFYMODE_INTERPOLATE); const basegfx::BColorModifierSharedPtr aBColorModifier(
const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ModifiedColorPrimitive2D(xRetval, aBColorModifier)); new basegfx::BColorModifier_interpolate(
aRGBWhite,
0.5));
const drawinglayer::primitive2d::Primitive2DReference xReference(
new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
xRetval,
aBColorModifier));
xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
} }
} }
......
...@@ -54,8 +54,15 @@ namespace sdr ...@@ -54,8 +54,15 @@ namespace sdr
if(isPrimitiveGhosted(rDisplayInfo)) if(isPrimitiveGhosted(rDisplayInfo))
{ {
const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0); const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
const ::basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, ::basegfx::BCOLORMODIFYMODE_INTERPOLATE); const ::basegfx::BColorModifierSharedPtr aBColorModifier(
const drawinglayer::primitive3d::Primitive3DReference xReference(new drawinglayer::primitive3d::ModifiedColorPrimitive3D(xRetval, aBColorModifier)); new basegfx::BColorModifier_interpolate(
aRGBWhite,
0.5));
const drawinglayer::primitive3d::Primitive3DReference xReference(
new drawinglayer::primitive3d::ModifiedColorPrimitive3D(
xRetval,
aBColorModifier));
xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
} }
......
...@@ -108,8 +108,14 @@ namespace sdr ...@@ -108,8 +108,14 @@ namespace sdr
if(isPrimitiveGhosted(rDisplayInfo)) if(isPrimitiveGhosted(rDisplayInfo))
{ {
const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0); const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
const ::basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, ::basegfx::BCOLORMODIFYMODE_INTERPOLATE); const ::basegfx::BColorModifierSharedPtr aBColorModifier(
const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ModifiedColorPrimitive2D(xRetval, aBColorModifier)); new basegfx::BColorModifier_interpolate(
aRGBWhite,
0.5));
const drawinglayer::primitive2d::Primitive2DReference xReference(
new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
xRetval,
aBColorModifier));
xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
} }
......
...@@ -358,8 +358,12 @@ void SwHeaderFooterWin::Paint( const Rectangle& ) ...@@ -358,8 +358,12 @@ void SwHeaderFooterWin::Paint( const Rectangle& )
// TODO Ghost it all if needed // TODO Ghost it all if needed
drawinglayer::primitive2d::Primitive2DSequence aGhostedSeq( 1 ); drawinglayer::primitive2d::Primitive2DSequence aGhostedSeq( 1 );
double nFadeRate = double( m_nFadeRate ) / 100.0; double nFadeRate = double( m_nFadeRate ) / 100.0;
const basegfx::BColorModifierSharedPtr aBColorModifier(
new basegfx::BColorModifier_interpolate(
Color( COL_WHITE ).getBColor(),
1.0 - nFadeRate));
aGhostedSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D( aGhostedSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aSeq, BColorModifier( Color( COL_WHITE ).getBColor(), 1.0 - nFadeRate, BCOLORMODIFYMODE_INTERPOLATE ) ) ); aSeq, aBColorModifier ) );
pProcessor->process( aGhostedSeq ); pProcessor->process( aGhostedSeq );
delete pProcessor; delete pProcessor;
......
...@@ -188,8 +188,12 @@ void SwPageBreakWin::Paint( const Rectangle& ) ...@@ -188,8 +188,12 @@ void SwPageBreakWin::Paint( const Rectangle& )
Primitive2DSequence aGhostedSeq( 1 ); Primitive2DSequence aGhostedSeq( 1 );
double nFadeRate = double( m_nFadeRate ) / 100.0; double nFadeRate = double( m_nFadeRate ) / 100.0;
const basegfx::BColorModifierSharedPtr aBColorModifier(
new basegfx::BColorModifier_interpolate(
Color( COL_WHITE ).getBColor(),
1.0 - nFadeRate));
aGhostedSeq[0] = Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D( aGhostedSeq[0] = Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aSeq, BColorModifier( Color( COL_WHITE ).getBColor(), 1.0 - nFadeRate, BCOLORMODIFYMODE_INTERPOLATE ) ) ); aSeq, aBColorModifier ) );
// Create the processor and process the primitives // Create the processor and process the primitives
const drawinglayer::geometry::ViewInformation2D aNewViewInfos; const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
......
...@@ -1017,58 +1017,110 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod ...@@ -1017,58 +1017,110 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod
for(sal_uInt32 a(rBColorModifierStack.count()); a && !bDone; ) 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 // clear bitmap with dest color
if(IsTransparent()) if(aChangedBitmap.GetBitCount() <= 8)
{ {
// clear bitmap with dest color // do NOT use erase; for e.g. 8bit Bitmaps, the nearest color to the given
if(aChangedBitmap.GetBitCount() <= 8) // 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
// do NOT use erase; for e.g. 8bit Bitmaps, the nearest color to the given BitmapReadAccess* pReadAccess = aChangedBitmap.AcquireReadAccess();
// erase color is determined and used -> this may be different from what is OSL_ENSURE(pReadAccess, "Got no Bitmap ReadAccess ?!?");
// 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) if(pReadAccess)
{
BitmapPalette aNewPalette(pReadAccess->GetPalette());
aNewPalette[0] = BitmapColor(Color(rModifier.getBColor()));
aChangedBitmap = Bitmap(
aChangedBitmap.GetSizePixel(),
aChangedBitmap.GetBitCount(),
&aNewPalette);
delete pReadAccess;
}
}
else
{ {
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 else
{ {
// erase bitmap, caller will know to paint direct aChangedBitmap.Erase(Color(pReplace->getBColor()));
aChangedBitmap.SetEmpty();
} }
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 y(0L); y < (sal_uInt32)pContent->Height(); y++)
{ {
for(sal_uInt32 x(0L); x < (sal_uInt32)pContent->Width(); x++) for(sal_uInt32 x(0L); x < (sal_uInt32)pContent->Width(); x++)
...@@ -1078,16 +1130,14 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod ...@@ -1078,16 +1130,14 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod
(double)aBMCol.GetRed() * fConvertColor, (double)aBMCol.GetRed() * fConvertColor,
(double)aBMCol.GetGreen() * fConvertColor, (double)aBMCol.GetGreen() * fConvertColor,
(double)aBMCol.GetBlue() * 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))); pContent->SetPixel(y, x, BitmapColor(Color(aBDest)));
} }
} }
delete pContent;
} }
break; delete pContent;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment