tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / vcl / source / bitmap / BitmapShadowFilter.cxx
blobfd5c7ea457838ffb5c659349825c4766869928e1
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/bitmap/BitmapShadowFilter.hxx>
12 #include <vcl/BitmapColor.hxx>
13 #include <vcl/BitmapWriteAccess.hxx>
15 BitmapEx BitmapShadowFilter::execute(BitmapEx const& rBitmapEx) const
17 const BitmapEx& aBitmapEx(rBitmapEx);
18 BitmapScopedWriteAccess pWriteAccess(const_cast<Bitmap&>(aBitmapEx.GetBitmap()));
20 if (!pWriteAccess)
21 return rBitmapEx;
23 for (sal_Int32 y(0); y < sal_Int32(pWriteAccess->Height()); y++)
25 Scanline pScanline = pWriteAccess->GetScanline(y);
27 for (sal_Int32 x(0); x < sal_Int32(pWriteAccess->Width()); x++)
29 const BitmapColor aColor = pWriteAccess->GetColor(y, x);
30 sal_uInt16 nLuminance(static_cast<sal_uInt16>(aColor.GetLuminance()) + 1);
31 const BitmapColor aDestColor(
32 static_cast<sal_uInt8>(
33 (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetRed())) >> 8),
34 static_cast<sal_uInt8>(
35 (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetGreen())) >> 8),
36 static_cast<sal_uInt8>(
37 (nLuminance * static_cast<sal_uInt16>(maShadowColor.GetBlue())) >> 8));
39 pWriteAccess->SetPixelOnData(pScanline, x, aDestColor);
43 return aBitmapEx;
46 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */