LibreOffice Module vcl (master)  1
BitmapFilter.hxx
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 #ifndef INCLUDED_VCL_BITMAPFILTER_HXX
12 #define INCLUDED_VCL_BITMAPFILTER_HXX
13 
14 #include <vcl/bitmapex.hxx>
15 #include <functional>
16 
17 class Animation;
18 
19 namespace vcl::bitmap
20 {
21 // Generates strip ranges and run the input function with the start and
22 // end as parameters. The additional parameter bLast denotes if the
23 // iteration is the last one.
24 //
25 // Example:
26 // first = 0, last = 100, STRIP_SIZE = 32
27 // this will generate:
28 // [0, 31, false], [32, 63, false], [64, 95, false], [96, 100, true]
29 template <int STRIP_SIZE>
31  long nFirst, long nLast,
32  std::function<void(long const nStart, long const nEnd, bool const bLast)> aFunction)
33 {
34  long nStart = nFirst;
35  for (; nStart < nLast - STRIP_SIZE; nStart += STRIP_SIZE)
36  {
37  long nEnd = nStart + STRIP_SIZE - 1;
38  aFunction(nStart, nEnd, false);
39  }
40  aFunction(nStart, nLast, true);
41 }
42 
43 } // end vcl::bitmap
44 
46 {
47 public:
48  BitmapFilter();
49  virtual ~BitmapFilter();
50 
51  virtual BitmapEx execute(BitmapEx const& rBitmapEx) const = 0;
52 
53  static bool Filter(BitmapEx& rBmpEx, BitmapFilter const& rFilter);
54  static bool Filter(Animation& rBmpEx, BitmapFilter const& rFilter);
55 };
56 
57 #endif
58 
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void generateStripRanges(long nFirst, long nLast, std::function< void(long const nStart, long const nEnd, bool const bLast)> aFunction)