1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
11 #include <basegfx/color/bcolortools.hxx>
13 #include <vcl/BitmapWriteAccess.hxx>
14 #include <bitmap/BitmapLightenFilter.hxx>
16 BitmapEx
BitmapLightenFilter::execute(BitmapEx
const& rBitmapEx
) const
18 const Size
aSize(rBitmapEx
.GetSizePixel());
20 const Bitmap
& aBitmap(rBitmapEx
.GetBitmap());
21 Bitmap
aDarkBitmap(aSize
, vcl::PixelFormat::N24_BPP
);
23 BitmapScopedReadAccess
pRead(aBitmap
);
24 BitmapScopedWriteAccess
pWrite(aDarkBitmap
);
28 for (sal_Int32 nY
= 0; nY
< sal_Int32(aSize
.Height()); ++nY
)
30 Scanline pScanline
= pWrite
->GetScanline(nY
);
31 Scanline pScanlineRead
= pRead
->GetScanline(nY
);
32 for (sal_Int32 nX
= 0; nX
< sal_Int32(aSize
.Width()); ++nX
)
36 ? pRead
->GetPaletteColor(pRead
->GetIndexFromData(pScanlineRead
, nX
))
37 : pRead
->GetPixelFromData(pScanlineRead
, nX
);
39 basegfx::BColor
aBColor(aBmpColor
.getBColor());
40 aBColor
= basegfx::utils::rgb2hsl(aBColor
);
42 double fHue
= aBColor
.getRed();
52 aBColor
= basegfx::utils::hsl2rgb(aBColor
);
53 aBmpColor
.SetRed((aBColor
.getRed() * 255.0) + 0.5);
54 aBmpColor
.SetGreen((aBColor
.getGreen() * 255.0) + 0.5);
55 aBmpColor
.SetBlue((aBColor
.getBlue() * 255.0) + 0.5);
57 pWrite
->SetPixelOnData(pScanline
, nX
, aBmpColor
);
64 return BitmapEx(aDarkBitmap
, rBitmapEx
.GetAlphaMask());
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */