LibreOffice Module vcl (master) 1
BitmapAlphaClampFilter.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>
13
15
17{
18 if (!rBitmapEx.IsAlpha())
19 return rBitmapEx;
20
21 AlphaMask aBitmapAlpha(rBitmapEx.GetAlphaMask());
22 {
23 AlphaScopedWriteAccess pWriteAlpha(aBitmapAlpha);
24 const Size aSize(rBitmapEx.GetSizePixel());
25
26 for (sal_Int32 nY = 0; nY < sal_Int32(aSize.Height()); ++nY)
27 {
28 Scanline pScanAlpha = pWriteAlpha->GetScanline(nY);
29
30 for (sal_Int32 nX = 0; nX < sal_Int32(aSize.Width()); ++nX)
31 {
32 BitmapColor aBitmapAlphaValue(pWriteAlpha->GetPixelFromData(pScanAlpha, nX));
33 if ((255 - aBitmapAlphaValue.GetIndex()) > mcThreshold)
34 {
35 aBitmapAlphaValue.SetIndex(0);
36 pWriteAlpha->SetPixelOnData(pScanAlpha, nX, aBitmapAlphaValue);
37 }
38 }
39 }
40 }
41
42 return BitmapEx(rBitmapEx.GetBitmap(), aBitmapAlpha);
43}
44
45/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 * Scanline
Definition: Scanline.hxx:26
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const override
sal_uInt8 GetIndex() const
Definition: BitmapColor.hxx:70
void SetIndex(sal_uInt8 cIndex)
Definition: BitmapColor.hxx:75
const AlphaMask & GetAlphaMask() const
Definition: bitmapex.hxx:71
bool IsAlpha() const
Definition: BitmapEx.cxx:207
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: BitmapEx.cxx:217
const Size & GetSizePixel() const
Definition: bitmapex.hxx:73
constexpr tools::Long Height() const
constexpr tools::Long Width() const
This template handles BitmapAccess the RAII way.