LibreOffice Module vcl (master) 1
BitmapShadowFilter.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
11#include <vcl/bitmapex.hxx>
12#include <vcl/BitmapColor.hxx>
14
16
18{
19 BitmapEx aBitmapEx(rBitmapEx);
20 BitmapScopedWriteAccess pWriteAccess(const_cast<Bitmap&>(aBitmapEx.GetBitmap()));
21
22 if (!pWriteAccess)
23 return rBitmapEx;
24
25 for (sal_Int32 y(0); y < sal_Int32(pWriteAccess->Height()); y++)
26 {
27 Scanline pScanline = pWriteAccess->GetScanline(y);
28
29 for (sal_Int32 x(0); x < sal_Int32(pWriteAccess->Width()); x++)
30 {
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));
40
41 pWriteAccess->SetPixelOnData(pScanline, x, aDestColor);
42 }
43 }
44
45 return aBitmapEx;
46}
47
48/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 * Scanline
Definition: Scanline.hxx:26
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: BitmapEx.cxx:217
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const override
sal_uInt8 GetLuminance() const
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
This template handles BitmapAccess the RAII way.
float y
float x
unsigned char sal_uInt8