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 
20 bool 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");
27  return false;
28  }
29 
30  rBmpEx = aTmpBmpEx;
31  return true;
32 }
33 
34 bool 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<AnimationBitmap>>& 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: */
std::vector< std::unique_ptr< AnimationBitmap > > & GetAnimationFrames()
Definition: Animation.hxx:68
const BitmapEx & GetBitmapEx() const
Definition: Animation.hxx:58
void SetBitmapEx(const BitmapEx &rBmpEx)
Definition: Animation.hxx:59
virtual BitmapEx execute(BitmapEx const &rBitmapEx) const =0
static bool Filter(BitmapEx &rBmpEx, BitmapFilter const &rFilter)
int i
#define SAL_WARN_IF(condition, area, stream)
bool IsInAnimation() const
Definition: Animation.hxx:52
size_t Count() const
Definition: Animation.hxx:69
#define SAL_WARN(area, stream)
virtual ~BitmapFilter()