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 
14 #include <bitmapwriteaccess.hxx>
15 
17 {
18  if (!rBitmapEx.IsTransparent())
19  return rBitmapEx;
20 
21  AlphaMask aBitmapAlpha(rBitmapEx.GetAlpha());
22  {
23  AlphaScopedWriteAccess pWriteAlpha(aBitmapAlpha);
24  const Size aSize(rBitmapEx.GetSizePixel());
25 
26  for (long nY = 0; nY < aSize.Height(); ++nY)
27  {
28  Scanline pScanAlpha = pWriteAlpha->GetScanline(nY);
29 
30  for (long nX = 0; nX < aSize.Width(); ++nX)
31  {
32  BitmapColor aBitmapAlphaValue(pWriteAlpha->GetPixelFromData(pScanAlpha, nX));
33  if (aBitmapAlphaValue.GetIndex() > mcThreshold)
34  {
35  aBitmapAlphaValue.SetIndex(255);
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: */
Scanline GetScanline(long nY) const
void SetPixelOnData(sal_uInt8 *pData, long nX, const BitmapColor &rBitmapColor)
Bitmap GetBitmap(const Color *pTransReplaceColor=nullptr) const
Definition: bitmapex.cxx:236
sal_uInt8 * Scanline
Definition: Scanline.hxx:25
bool IsTransparent() const
Definition: bitmapex.cxx:221
void SetIndex(sal_uInt8 cIndex)
Definition: BitmapColor.hxx:66
AlphaMask GetAlpha() const
Definition: bitmapex.cxx:268
BitmapColor GetPixelFromData(const sal_uInt8 *pData, long nX) const
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const override
const Size & GetSizePixel() const
Definition: bitmapex.hxx:83