LibreOffice Module vcl (master) 1
bitmapfilter.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/BitmapFilter.hxx>
13
14#include <sal/log.hxx>
15
17
19
20bool BitmapFilter::Filter(BitmapEx& rBmpEx, BitmapFilter const& rFilter)
21{
22 BitmapEx aTmpBmpEx(rFilter.execute(rBmpEx));
23
24 if (aTmpBmpEx.IsEmpty())
25 {
26 SAL_WARN("vcl.gdi", "Bitmap filter failed " << typeid(rFilter).name());
27 return false;
28 }
29
30 rBmpEx = aTmpBmpEx;
31 return true;
32}
33
34bool BitmapFilter::Filter(Animation& rAnimation, BitmapFilter const& rFilter)
35{
36 SAL_WARN_IF(rAnimation.IsInAnimation(), "vcl", "Animation modified while it is animated");
37
38 bool bRet = false;
39
40 if (!rAnimation.IsInAnimation() && !rAnimation.Count())
41 {
42 bRet = true;
43
44 std::vector<std::unique_ptr<AnimationFrame>>& aList = rAnimation.GetAnimationFrames();
45 for (size_t i = 0, n = aList.size(); (i < n) && bRet; ++i)
46 {
47 bRet = BitmapFilter::Filter(aList[i]->maBitmapEx, rFilter);
48 }
49
50 BitmapEx aBmpEx(rAnimation.GetBitmapEx());
51 BitmapFilter::Filter(aBmpEx, rFilter);
52 rAnimation.SetBitmapEx(aBmpEx);
53 }
54
55 return bRet;
56}
57
58/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const BitmapEx & GetBitmapEx() const
Definition: Animation.hxx:60
size_t Count() const
Definition: Animation.hxx:71
void SetBitmapEx(const BitmapEx &rBmpEx)
Definition: Animation.hxx:61
std::vector< std::unique_ptr< AnimationFrame > > & GetAnimationFrames()
Definition: Animation.hxx:70
bool IsInAnimation() const
Definition: Animation.hxx:54
bool IsEmpty() const
Definition: BitmapEx.cxx:186
virtual ~BitmapFilter()
static bool Filter(BitmapEx &rBmpEx, BitmapFilter const &rFilter)
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const =0
const char * name
sal_Int64 n
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
int i