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/bitmapaccess.hxx>
15 #include <bitmapwriteaccess.hxx>
16 #include <BitmapLightenFilter.hxx>
18 BitmapEx
BitmapLightenFilter::execute(BitmapEx
const& rBitmapEx
) const
20 const Size
aSize(rBitmapEx
.GetSizePixel());
22 Bitmap
aBitmap(rBitmapEx
.GetBitmap());
23 Bitmap
aDarkBitmap(aSize
, 24);
25 Bitmap::ScopedReadAccess
pRead(aBitmap
);
26 BitmapScopedWriteAccess
pWrite(aDarkBitmap
);
30 for (tools::Long nY
= 0; nY
< aSize
.Height(); ++nY
)
32 Scanline pScanline
= pWrite
->GetScanline(nY
);
33 Scanline pScanlineRead
= pRead
->GetScanline(nY
);
34 for (tools::Long nX
= 0; nX
< aSize
.Width(); ++nX
)
38 ? pRead
->GetPaletteColor(pRead
->GetIndexFromData(pScanlineRead
, nX
))
39 : pRead
->GetPixelFromData(pScanlineRead
, nX
);
41 basegfx::BColor
aBColor(aBmpColor
.getBColor());
42 aBColor
= basegfx::utils::rgb2hsl(aBColor
);
44 double fHue
= aBColor
.getRed();
54 aBColor
= basegfx::utils::hsl2rgb(aBColor
);
55 aBmpColor
.SetRed((aBColor
.getRed() * 255.0) + 0.5);
56 aBmpColor
.SetGreen((aBColor
.getGreen() * 255.0) + 0.5);
57 aBmpColor
.SetBlue((aBColor
.getBlue() * 255.0) + 0.5);
59 pWrite
->SetPixelOnData(pScanline
, nX
, aBmpColor
);
66 return BitmapEx(aDarkBitmap
, rBitmapEx
.GetAlpha());
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */