Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / vcl / source / bitmap / bitmapfilter.cxx
blob58a01f1fb00753d5d15633b57009b20d862eb4c7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
11 #include <vcl/BitmapFilter.hxx>
12 #include <vcl/animate/Animation.hxx>
14 #include <sal/log.hxx>
16 BitmapFilter::BitmapFilter() {}
18 BitmapFilter::~BitmapFilter() {}
20 bool BitmapFilter::Filter(BitmapEx& rBmpEx, BitmapFilter const & rFilter)
22 BitmapEx aTmpBmpEx(rFilter.execute(rBmpEx));
24 if (aTmpBmpEx.IsEmpty())
26 SAL_WARN("vcl.gdi", "Bitmap filter failed");
27 return false;
30 rBmpEx = aTmpBmpEx;
31 return true;
34 bool BitmapFilter::Filter(Animation& rAnimation, BitmapFilter const & rFilter)
36 SAL_WARN_IF(rAnimation.IsInAnimation(), "vcl", "Animation modified while it is animated");
38 bool bRet = false;
40 if (!rAnimation.IsInAnimation() && !rAnimation.Count())
42 bRet = true;
44 std::vector<std::unique_ptr<AnimationBitmap>>& aList = rAnimation.GetAnimationFrames();
45 for (size_t i = 0, n = aList.size(); (i < n) && bRet; ++i)
47 bRet = BitmapFilter::Filter(aList[i]->maBitmapEx, rFilter);
50 BitmapEx aBmpEx(rAnimation.GetBitmapEx());
51 BitmapFilter::Filter(aBmpEx, rFilter);
52 rAnimation.SetBitmapEx(aBmpEx);
55 return bRet;
58 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */