1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
25 Linear Convolution _Raw filters.
29 #ifndef FILTERS_GP_LINEAR_H
30 #define FILTERS_GP_LINEAR_H
32 #include "GP_Filter.h"
37 * The sigma parameters defines the blur radii in horizontal and vertical
40 * Internaly this is implemented as separable linear filter (calls vertical and
41 * horizontal convolution with generated gaussian kernel).
43 * This variant could work in-place so it's perectly okay to call
45 * GP_FilterGaussianBlur_Raw(context, context, ...);
47 int GP_FilterGaussianBlur_Raw(const GP_Context
*src
, GP_Context
*dst
,
48 float sigma_x
, float sigma_y
,
49 GP_ProgressCallback
*callback
);
53 * If dst is NULL, new bitmap is allocated.
55 * This variant could work in-place.
57 * Returns pointer to destination bitmap or NULL if allocation failed.
59 GP_Context
*GP_FilterGaussianBlur(const GP_Context
*src
, GP_Context
*dst
,
60 float sigma_x
, float sigma_y
,
61 GP_ProgressCallback
*callback
);
66 * The kernel is array of kw * kh floats and is indexed as two directional
69 * The src coordinates and size defines rectangle in the source on which the
72 * The dst coodinates defines start pixel of in the destination context.
74 * To define 3x3 average filter
86 * This function works also in-place.
88 int GP_FilterLinearConvolution_Raw(const GP_Context
*src
,
89 GP_Coord x_src
, GP_Coord y_src
,
90 GP_Size w_src
, GP_Size h_src
,
92 GP_Coord x_dst
, GP_Coord y_dst
,
93 float kernel
[], uint32_t kw
, uint32_t kh
,
94 float kern_div
, GP_ProgressCallback
*callback
);
97 * Special cases for convolution only in horizontal/vertical direction.
99 * These are about 10-30% faster than the generic implementation (depending on
100 * the kernel size, bigger kernel == more savings).
102 * These are two are a base for bilinear filters.
104 * Both works also in-place.
106 int GP_FilterHLinearConvolution_Raw(const GP_Context
*src
,
107 GP_Coord x_src
, GP_Coord y_src
,
108 GP_Size w_src
, GP_Size h_src
,
110 GP_Coord x_dst
, GP_Coord y_dst
,
111 float kernel
[], uint32_t kw
, float kern_div
,
112 GP_ProgressCallback
*callback
);
114 int GP_FilterVLinearConvolution_Raw(const GP_Context
*src
,
115 GP_Coord x_src
, GP_Coord y_src
,
116 GP_Size w_src
, GP_Size h_src
,
118 GP_Coord x_dst
, GP_Coord y_dst
,
119 float kernel
[], uint32_t kh
, float kern_div
,
120 GP_ProgressCallback
*callback
);
123 * Applies both horizontal and vertical convolution and takes care of the
124 * correct progress callback (both horizontal and vertical kernels are expected
125 * to be similar in size).
127 int GP_FilterVHLinearConvolution_Raw(const GP_Context
*src
,
128 GP_Coord x_src
, GP_Coord y_src
,
129 GP_Size w_src
, GP_Size h_src
,
131 GP_Coord x_dst
, GP_Coord y_dst
,
132 float hkernel
[], uint32_t kw
, float hkern_div
,
133 float vkernel
[], uint32_t kh
, float vkern_div
,
134 GP_ProgressCallback
*callback
);
137 * Prints a kernel into the stdout.
139 void GP_FilterKernelPrint_Raw(float kernel
[], int kw
, int kh
, float kern_div
);
141 #endif /* FILTERS_GP_LINEAR_H */