Rename GP_Context -> GP_Pixmap
[gfxprim.git] / include / filters / GP_Resize.h
blob975eddb947df4606c50f63f47d6de669dab5536c
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-2013 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
25 GP_Pixmap 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 typedef enum GP_InterpolationType {
60 GP_INTERP_NN, /* Nearest Neighbour */
61 GP_INTERP_LINEAR_INT, /* Bilinear - fixed point arithmetics */
62 GP_INTERP_LINEAR_LF_INT, /* Bilinear + low pass filter on downscaling */
63 GP_INTERP_CUBIC, /* Bicubic */
64 GP_INTERP_CUBIC_INT, /* Bicubic - fixed point arithmetics */
65 GP_INTERP_MAX = GP_INTERP_CUBIC_INT,
66 } GP_InterpolationType;
68 const char *GP_InterpolationTypeName(enum GP_InterpolationType interp_type);
71 * Resize src to fit the dst, both src and dst must have the same pixel_type.
73 * Returns non-zero on error (interrupted from callback), zero on success.
75 int GP_FilterResize(const GP_Pixmap *src, GP_Pixmap *dst,
76 GP_InterpolationType type,
77 GP_ProgressCallback *callback);
80 * Resize src to wxh, the result is allocated.
82 * Returns pointer to newly created pixmap.
84 * Returns NULL in case of failure and errno is set correspondinlgy.
86 GP_Pixmap *GP_FilterResizeAlloc(const GP_Pixmap *src,
87 GP_Size w, GP_Size h,
88 GP_InterpolationType type,
89 GP_ProgressCallback *callback);
91 #endif /* FILTERS_GP_RESIZE_H */