GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_rotate.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 rotations and mirroring.
9
10 */
11
12#ifndef FILTERS_GP_ROTATE_H
13#define FILTERS_GP_ROTATE_H
14
15#include <core/gp_types.h>
16#include <filters/gp_filter.h>
17
18/*
19 * Mirrors bitmap horizontally.
20 *
21 * The dst must be at least as big as source.
22 *
23 * The filter works 'in-place' which means that src and dst
24 * may be very same pixmap. Note that when aborting in-place operation
25 * the image buffer gets into an inconsistent state.
26 *
27 * Returns zero on success, non-zero if operation was aborted.
28 */
29int gp_filter_mirror_h(const gp_pixmap *src, gp_pixmap *dst,
30 gp_progress_cb *callback);
31
32/*
33 * Mirrors bitmap horizontally.
34 *
35 * Returns pointer to newly allocated pixmap, or NULL if malloc() has failed
36 * or operation was aborted from withing a callback.
37 */
38gp_pixmap *gp_filter_mirror_h_alloc(const gp_pixmap *src,
39 gp_progress_cb *callback);
40
41/*
42 * Mirrors bitmap vertically.
43 *
44 * The dst must be at least as big as source.
45 *
46 * The filter works 'in-place' which means that src and dst
47 * may be very same pixmap. Note that when aborting in-place operation
48 * the image buffer gets into an inconsistent state.
49 *
50 * Returns zero on success, non-zero if operation was aborted.
51 */
52int gp_filter_mirror_v(const gp_pixmap *src, gp_pixmap *dst,
53 gp_progress_cb *callback);
54
55/*
56 * Mirrors bitmap vertically.
57 *
58 * Returns pointer to newly allocated pixmap, or NULL if malloc() has failed
59 * or operation was aborted from withing a callback.
60 */
61gp_pixmap *gp_filter_mirror_v_alloc(const gp_pixmap *src,
62 gp_progress_cb *callback);
63
64/*
65 * Rotate the pixmap by 90, 180, 270.
66 *
67 * Returns pointer to destination bitmap or NULL if allocation failed.
68 */
69int gp_filter_rotate_90(const gp_pixmap *src, gp_pixmap *dst,
70 gp_progress_cb *callback);
71
72gp_pixmap *gp_filter_rotate_90_alloc(const gp_pixmap *src,
73 gp_progress_cb *callback);
74
75int gp_filter_rotate_180(const gp_pixmap *src, gp_pixmap *dst,
76 gp_progress_cb *callback);
77
78gp_pixmap *gp_filter_rotate_180_alloc(const gp_pixmap *src,
79 gp_progress_cb *callback);
80
81int gp_filter_rotate_270(const gp_pixmap *src, gp_pixmap *dst,
82 gp_progress_cb *callback);
83
84gp_pixmap *gp_filter_rotate_270_alloc(const gp_pixmap *src,
85 gp_progress_cb *callback);
86
87/*
88 * Calls a symmetry filter on bitmap.
89 *
90 * If dst is NULL, new bitmap is allocated.
91 *
92 * Returns pointer to destination bitmap or NULL if allocation failed.
93 */
94typedef enum gp_filter_symmetries {
95 GP_ROTATE_90 = 0,
96 GP_ROTATE_CW = GP_ROTATE_90,
97 GP_ROTATE_180,
98 GP_ROTATE_270,
99 GP_ROTATE_CCW = GP_ROTATE_270,
100 GP_MIRROR_H,
101 GP_MIRROR_V,
102} gp_filter_symmetries;
103
104/*
105 * NULL-terminated array of symmetry names (C strings).
106 */
107extern const char **gp_filter_symmetry_names;
108
109/*
110 * Symmetry by name (as defined in gp_filer_symmetry_names).
111 *
112 * Returns either one of the gp_filter_symmetries enums or -1 in case of
113 * failure.
114 */
115int gp_filter_symmetry_by_name(const char *symmetry);
116
117int gp_filter_symmetry(const gp_pixmap *src, gp_pixmap *dst,
118 gp_filter_symmetries symmetry,
119 gp_progress_cb *callback);
120
121gp_pixmap *gp_filter_symmetry_alloc(const gp_pixmap *src,
122 gp_filter_symmetries symmetry,
123 gp_progress_cb *callback);
124
125#endif /* FILTERS_GP_ROTATE_H */
A common types.
Common filter includes.
A pixmap buffer.
Definition gp_pixmap.h:33
Progress callback.