update dev300-m58
[ooovba.git] / basegfx / source / color / bcolormodifier.cxx
blob94551dd0a57ac2d048c7d623eb9e79bf683b8e01
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bcolormodifier.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_basegfx.hxx"
35 #include <basegfx/color/bcolormodifier.hxx>
37 //////////////////////////////////////////////////////////////////////////////
39 namespace basegfx
41 ::basegfx::BColor BColorModifier::getModifiedColor(const ::basegfx::BColor& aSourceColor) const
43 switch(meMode)
45 case BCOLORMODIFYMODE_INTERPOLATE :
47 return interpolate(maBColor, aSourceColor, mfValue);
49 case BCOLORMODIFYMODE_GRAY :
51 const double fLuminance(aSourceColor.luminance());
52 return ::basegfx::BColor(fLuminance, fLuminance, fLuminance);
54 case BCOLORMODIFYMODE_BLACKANDWHITE :
56 const double fLuminance(aSourceColor.luminance());
58 if(fLuminance < mfValue)
60 return ::basegfx::BColor::getEmptyBColor();
62 else
64 return ::basegfx::BColor(1.0, 1.0, 1.0);
67 default : // BCOLORMODIFYMODE_REPLACE
69 return maBColor;
73 } // end of namespace basegfx
75 //////////////////////////////////////////////////////////////////////////////
76 // eof