filters: Add generated Nearest Neighbour filter.
[gfxprim.git] / include / filters / GP_Resize.h
blob1c84f2cf3e04921678bc43c691187f9c367e355b
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
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. *
8 * *
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. *
13 * *
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 *
18 * *
19 * Copyright (C) 2009-2011 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
25 GP_Context interpolations.
27 Nearest Neighbour
28 ~~~~~~~~~~~~~~~~~
30 Fast, but produces pixelated images. Works however well for images with sharp
31 edges mostly consisting of big one color regions (eg doesn't blur the
32 result on upscaling).
34 Bilinear
35 ~~~~~~~~
37 Faster than Bicubic, but less precise.
39 Bilinear LF
40 ~~~~~~~~~~~
42 Bilinear with low-pass filter on downscaling, this is the best choice for
43 fast up and downscaling.
45 Bicubic
46 ~~~~~~~
48 Works well for upscaling as is. To get decent result on downscaling,
49 low-pass filter (for example gaussian blur) must be used on original image
50 before scaling is done.
54 #ifndef FILTERS_GP_RESIZE_H
55 #define FILTERS_GP_RESIZE_H
57 #include "GP_Filter.h"
59 /* Nearest Neighbour */
60 int GP_FilterResizeNN(const GP_Context *src, GP_Context *dst,
61 GP_ProgressCallback *callback);
63 GP_Context *GP_FilterResizeNNAlloc(const GP_Context *src,
64 GP_Size w, GP_Size h,
65 GP_ProgressCallback *callback);
68 typedef enum GP_InterpolationType {
69 GP_INTERP_NN, /* Nearest Neighbour */
70 GP_INTERP_LINEAR_INT, /* Bilinear - fixed point arithmetics */
71 GP_INTERP_LINEAR_LF_INT, /* Bilinear + low pass filter on downscaling */
72 GP_INTERP_CUBIC, /* Bicubic */
73 GP_INTERP_CUBIC_INT, /* Bicubic - fixed point arithmetics */
74 } GP_InterpolationType;
77 * Just interpolate the source context into destination context.
79 int GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst,
80 GP_InterpolationType type,
81 GP_ProgressCallback *callback);
84 * If destination is non NULL, the w and h are used to create subcontext from
85 * destination which is then used to interpolate the image to.
87 * Otherwise if destination is NULL, the context of size w and h is allocated
88 * and returned.
90 * In both cases the pointer to destination or NULL in case of failure is
91 * returned.
93 GP_Context *GP_FilterResize(const GP_Context *src, GP_Context *dst,
94 GP_InterpolationType type,
95 GP_Size w, GP_Size h,
96 GP_ProgressCallback *callback);
98 #endif /* FILTERS_GP_RESIZE_H */