bump product version to 7.2.5.1
[LibreOffice.git] / vcl / source / bitmap / BitmapShadowFilter.cxx
blob07e1fd6ad53444c0a31577cd04f28bada6a7f8e7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #include <vcl/bitmapex.hxx>
12 #include <vcl/BitmapColor.hxx>
13 #include <vcl/BitmapShadowFilter.hxx>
15 #include <bitmap/BitmapWriteAccess.hxx>
17 BitmapEx BitmapShadowFilter::execute(BitmapEx const& rBitmapEx) const
19 BitmapEx aBitmapEx(rBitmapEx);
20 BitmapScopedWriteAccess pWriteAccess(const_cast<Bitmap&>(aBitmapEx.GetBitmap()));
22 if (!pWriteAccess)
23 return rBitmapEx;
25 for (tools::Long y(0); y < pWriteAccess->Height(); y++)
27 Scanline pScanline = pWriteAccess->GetScanline(y);
29 for (tools::Long x(0); x < pWriteAccess->Width(); x++)
31 const BitmapColor aColor = pWriteAccess->GetColor(y, x);
32 sal_uInt16 nLuminance(static_cast<sal_uInt16>(aColor.GetLuminance()) + 1);
33 const BitmapColor aDestColor(
34 static_cast<sal_uInt8>(
35 (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetRed())) >> 8),
36 static_cast<sal_uInt8>(
37 (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetGreen())) >> 8),
38 static_cast<sal_uInt8>(
39 (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetBlue())) >> 8));
41 pWriteAccess->SetPixelOnData(pScanline, x, aDestColor);
45 return aBitmapEx;
48 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */