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 <vcl/bitmapex.hxx>
12 #include <vcl/BitmapAlphaClampFilter.hxx>
14 #include <bitmap/BitmapWriteAccess.hxx>
16 BitmapEx
BitmapAlphaClampFilter::execute(BitmapEx
const& rBitmapEx
) const
18 if (!rBitmapEx
.IsAlpha())
21 AlphaMask
aBitmapAlpha(rBitmapEx
.GetAlpha());
23 AlphaScopedWriteAccess
pWriteAlpha(aBitmapAlpha
);
24 const Size
aSize(rBitmapEx
.GetSizePixel());
26 for (tools::Long nY
= 0; nY
< aSize
.Height(); ++nY
)
28 Scanline pScanAlpha
= pWriteAlpha
->GetScanline(nY
);
30 for (tools::Long nX
= 0; nX
< aSize
.Width(); ++nX
)
32 BitmapColor
aBitmapAlphaValue(pWriteAlpha
->GetPixelFromData(pScanAlpha
, nX
));
33 if (aBitmapAlphaValue
.GetIndex() > mcThreshold
)
35 aBitmapAlphaValue
.SetIndex(255);
36 pWriteAlpha
->SetPixelOnData(pScanAlpha
, nX
, aBitmapAlphaValue
);
42 return BitmapEx(rBitmapEx
.GetBitmap(), aBitmapAlpha
);
45 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */