GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_resize.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2/*
3 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz>
4 */
5
6/*
7
8 gp_pixmap interpolations.
9
10 Nearest Neighbour
11 ~~~~~~~~~~~~~~~~~
12
13 Fast, but produces pixelated images. Works however well for images with sharp
14 edges mostly consisting of big one color regions (eg doesn't blur the
15 result on upscaling).
16
17 Bilinear
18 ~~~~~~~~
19
20 Faster than Bicubic, but less precise.
21
22 Bilinear LF
23 ~~~~~~~~~~~
24
25 Bilinear with low-pass filter on downscaling, this is the best choice for
26 fast up and downscaling.
27
28 Bicubic
29 ~~~~~~~
30
31 Works well for upscaling as is. To get decent result on downscaling,
32 low-pass filter (for example gaussian blur) must be used on original image
33 before scaling is done.
34
35 */
36
37#ifndef FILTERS_GP_RESIZE_H
38#define FILTERS_GP_RESIZE_H
39
40#include <filters/gp_filter.h>
41
42typedef enum gp_interpolation_type {
43 GP_INTERP_NN, /* Nearest Neighbour */
44 GP_INTERP_LINEAR_INT, /* Bilinear - fixed point arithmetics */
45 GP_INTERP_LINEAR_LF_INT, /* Bilinear + low pass filter on downscaling */
46 GP_INTERP_CUBIC, /* Bicubic */
47 GP_INTERP_CUBIC_INT, /* Bicubic - fixed point arithmetics */
48 GP_INTERP_MAX = GP_INTERP_CUBIC_INT,
49} gp_interpolation_type;
50
51const char *gp_interpolation_type_name(enum gp_interpolation_type interp_type);
52
53/*
54 * Resize src to fit the dst, both src and dst must have the same pixel_type.
55 *
56 * Returns non-zero on error (interrupted from callback), zero on success.
57 */
58int gp_filter_resize(const gp_pixmap *src, gp_pixmap *dst,
59 gp_interpolation_type type,
60 gp_progress_cb *callback);
61
62/*
63 * Resize src to wxh, the result is allocated.
64 *
65 * Returns pointer to newly created pixmap.
66 *
67 * Returns NULL in case of failure and errno is set correspondinlgy.
68 */
69gp_pixmap *gp_filter_resize_alloc(const gp_pixmap *src,
70 gp_size w, gp_size h,
71 gp_interpolation_type type,
72 gp_progress_cb *callback);
73
74#endif /* FILTERS_GP_RESIZE_H */
unsigned int gp_size
Integer type for sizes i.e. w, h, ...
Definition gp_types.h:24
Common filter includes.
A pixmap buffer.
Definition gp_pixmap.h:33
Progress callback.