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/bitmap.hxx>
12 #include <vcl/bitmapex.hxx>
13 #include <vcl/BitmapSolarizeFilter.hxx>
15 #include <bitmapwriteaccess.hxx>
17 BitmapEx
BitmapSolarizeFilter::execute(BitmapEx
const& rBitmapEx
) const
19 Bitmap
aBitmap(rBitmapEx
.GetBitmap());
21 BitmapScopedWriteAccess
pWriteAcc(aBitmap
);
25 if (pWriteAcc
->HasPalette())
27 const BitmapPalette
& rPal
= pWriteAcc
->GetPalette();
29 for (sal_uInt16 i
= 0, nCount
= rPal
.GetEntryCount(); i
< nCount
; i
++)
31 if (rPal
[i
].GetLuminance() >= mcSolarGreyThreshold
)
33 BitmapColor
aCol(rPal
[i
]);
35 pWriteAcc
->SetPaletteColor(i
, aCol
);
42 const long nWidth
= pWriteAcc
->Width();
43 const long nHeight
= pWriteAcc
->Height();
45 for (long nY
= 0; nY
< nHeight
; nY
++)
47 Scanline pScanline
= pWriteAcc
->GetScanline(nY
);
48 for (long nX
= 0; nX
< nWidth
; nX
++)
50 aCol
= pWriteAcc
->GetPixelFromData(pScanline
, nX
);
52 if (aCol
.GetLuminance() >= mcSolarGreyThreshold
)
55 pWriteAcc
->SetPixelOnData(pScanline
, nX
, aCol
);
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */