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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_RESAMPLEKERNEL_HXX
21 #define INCLUDED_VCL_RESAMPLEKERNEL_HXX
23 #include <boost/math/special_functions/sinc.hpp>
35 virtual double GetWidth() const = 0;
36 virtual double Calculate( double x
) const = 0;
39 class Lanczos3Kernel final
: public Kernel
42 Lanczos3Kernel() : Kernel () {}
44 virtual double GetWidth() const override
{ return 3.0; }
45 virtual double Calculate (double x
) const override
47 return (-3.0 <= x
&& x
< 3.0) ? SincFilter(x
) * SincFilter( x
/ 3.0 ) : 0.0;
50 static double SincFilter(double x
)
57 return boost::math::sinc_pi(x
, SincPolicy());
61 typedef boost::math::policies::policy
<
62 boost::math::policies::promote_double
<false> > SincPolicy
;
65 class BicubicKernel final
: public Kernel
68 BicubicKernel() : Kernel () {}
71 virtual double GetWidth() const override
{ return 2.0; }
72 virtual double Calculate (double x
) const override
81 return (1.5 * x
- 2.5) * x
* x
+ 1.0;
85 return ((-0.5 * x
+ 2.5) * x
- 4) * x
+ 2;
91 class BilinearKernel final
: public Kernel
94 BilinearKernel() : Kernel () {}
97 virtual double GetWidth() const override
{ return 1.0; }
98 virtual double Calculate (double x
) const override
114 #endif // INCLUDED_VCL_RESAMPLEKERNEL_HXX
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */