diff options
author | Armin Le Grand <alg@apache.org> | 2013-04-16 08:41:07 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-05-20 11:33:13 +0100 |
commit | 35aa48d80b4b800d408d26bd72fbdfd711abbb6f (patch) | |
tree | 2756d4aa78cd67be7d1597b4222f0da0657c770d /vcl | |
parent | 05038d1bd0a7bc9ecb6676ba1309576ac74f849f (diff) |
Resolves: #i122041# Unified and centralized control for Color ValueSets
(cherry picked from commit 68e707bbc6fe23881b822e6efab8a2933343dc1a)
Conflicts:
cui/source/inc/backgrnd.hxx
cui/source/inc/cuitabarea.hxx
cui/source/tabpages/backgrnd.cxx
cui/source/tabpages/tpcolor.cxx
sd/source/ui/view/drviews6.cxx
svx/Package_inc.mk
svx/inc/svx/colrctrl.hxx
svx/source/sidebar/tools/ColorControl.cxx
svx/source/tbxctrls/colorwindow.hxx
svx/source/tbxctrls/colrctrl.cxx
svx/source/tbxctrls/tbcontrl.cxx
Change-Id: Ie06fe355846b737ec8aae9aade4d408232c83193
Related: #i122041# Add a11y values for defining behaviour of ColorValueSets
(cherry picked from commit 401e8f2db607081e62eaaa1f08a8cd8971a3f637)
Conflicts:
cui/source/tabpages/backgrnd.cxx
officecfg/registry/schema/org/openoffice/Office/Common.xcs
sc/source/ui/miscdlgs/tabbgcolordlg.cxx
svtools/inc/svtools/accessibilityoptions.hxx
svtools/source/inc/configitems/accessibilityoptions_const.hxx
vcl/inc/vcl/bitmap.hxx
vcl/source/gdi/bitmap4.cxx
Change-Id: If9d0db5f22974cad1ac886eca3719ca92ca7f240
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/bitmap4.cxx | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx index b0afd67b2ed0..efe8209129e2 100644 --- a/vcl/source/gdi/bitmap4.cxx +++ b/vcl/source/gdi/bitmap4.cxx @@ -1165,4 +1165,196 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) { } +void impMixPixel(BitmapWriteAccess& rAcc, long y, long x, const Color& rColor, sal_uInt8 nAlpha) +{ + const BitmapColor aBitmapColor(rColor); + + if(nAlpha) + { + if(255 != nAlpha) + { + BitmapColor aTarget(rAcc.GetColor(y, x)); + + aTarget.Merge(aBitmapColor, nAlpha); + rAcc.SetPixel(y, x, aTarget); + } + } + else + { + rAcc.SetPixel(y, x, aBitmapColor); + } +} + +inline bool impVisibleX(long x, const Size& rSizePixel) +{ + return x >= 0 && x < rSizePixel.Width(); +} + +inline bool impVisibleY(long y, const Size& rSizePixel) +{ + return y >= 0 && y < rSizePixel.Width(); +} + +inline bool impVisibleXY(long y, long x, const Size& rSizePixel) +{ + return impVisibleX(x, rSizePixel) && impVisibleY(y, rSizePixel); +} + +void Bitmap::DrawBlendFrame( + const Point& rTopLeft, + const Size& rSize, + sal_uInt8 nAlpha, + Color aColorTopLeft, + Color aColorTopRight, + Color aColorBottomRight, + Color aColorBottomLeft) +{ + if(!IsEmpty()) + { + const Size aSizePixel(GetSizePixel()); + + if(aSizePixel.Width() && aSizePixel.Height()) + { + const long nW(rSize.Width()); + const long nH(rSize.Height()); + + if(nW || nH) + { + BitmapWriteAccess* pAcc = AcquireWriteAccess(); + const long nStartX(rTopLeft.X()); + const long nStartY(rTopLeft.X()); + const long nEndX(rTopLeft.X() + nW); + const long nEndY(rTopLeft.X() + nH); + long x(nStartX); + long y(nStartY); + + if(pAcc) + { + if(impVisibleXY(y, x, aSizePixel)) + { + // x == nStartX, y == nStartY + impMixPixel(*pAcc, y, x, aColorTopLeft, nAlpha); + } + + if(impVisibleY(y, aSizePixel)) + { + for(x = 1; x < nEndX - 1; x++) // y == nStartY + { + if(impVisibleX(x, aSizePixel)) + { + Color aMix(aColorTopLeft); + aMix.Merge(aColorTopRight, 255 - sal_uInt8(((x - nStartX) * 255) / nW)); + impMixPixel(*pAcc, y, x, aMix, nAlpha); + } + } + } + else + { + x = nEndX - 1; + } + + if(impVisibleXY(y, x, aSizePixel)) + { + // x == nEndX - 1, y == nStartY + impMixPixel(*pAcc, y, x, aColorTopRight, nAlpha); + } + + const bool bLeftVisible(impVisibleX(nStartX, aSizePixel)); + const bool bRightVisible(impVisibleX(x, aSizePixel)); + + if(bLeftVisible || bRightVisible) + { + if(bLeftVisible) + { + for(y = 1; y < nEndY - 1; y++) // x == nStartX and nEndX-1 + { + if(impVisibleY(y, aSizePixel)) + { + Color aMix(aColorTopLeft); + aMix.Merge(aColorBottomLeft, 255 - sal_uInt8(((y - nStartY) * 255) / nH)); + impMixPixel(*pAcc, y, nStartX, aMix, nAlpha); + } + } + } + + if(bRightVisible) + { + for(y = 1; y < nEndY - 1; y++) // x == nStartX and nEndX-1 + { + if(impVisibleY(y, aSizePixel)) + { + Color aMix(aColorTopRight); + aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((y -nStartY) * 255) / nH)); + impMixPixel(*pAcc, y, x, aMix, nAlpha); + } + } + } + } + else + { + y = nEndY - 1; + } + + if(impVisibleXY(y, x, aSizePixel)) + { + x = nStartX; // x == nStartX, y == nEndY-1 + impMixPixel(*pAcc, y, x, aColorBottomLeft, nAlpha); + } + + if(impVisibleY(y, aSizePixel)) + { + for(x = 1; x < nEndX - 1; x++) // y == nEndY-1 + { + if(impVisibleX(x, aSizePixel)) + { + Color aMix(aColorBottomLeft); + aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((x - nStartX)* 255) / nW)); + impMixPixel(*pAcc, y, x, aMix, nAlpha); + } + } + } + else + { + x = nEndX - 1; + } + + if(impVisibleXY(y, x, aSizePixel)) + { + // x == nEndX - 1, y == nEndY - 1 + impMixPixel(*pAcc, y, x, aColorBottomRight, nAlpha); + } + + ReleaseAccess(pAcc); + } + } + } + } +} + +void Bitmap::DrawBlendFrame( + sal_uInt8 nAlpha, + Color aColorTopLeft, + Color aColorBottomRight) +{ + if(!IsEmpty()) + { + const Point aTopLeft(0, 0); + const Size aSize(GetSizePixel()); + const sal_uInt32 nW(aSize.Width()); + const sal_uInt32 nH(aSize.Height()); + + if(nW || nH) + { + Color aColTopRight(aColorTopLeft); + Color aColBottomLeft(aColorTopLeft); + const sal_uInt32 nDE(nW + nH); + + aColTopRight.Merge(aColorBottomRight, 255 - sal_uInt8((nW * 255) / nDE)); + aColBottomLeft.Merge(aColorBottomRight, 255 - sal_uInt8((nH * 255) / nDE)); + + DrawBlendFrame(aTopLeft, aSize, nAlpha, aColorTopLeft, aColTopRight, aColorBottomRight, aColBottomLeft); + } + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |