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 Symmetry filter example.
36 static void usage_and_exit(int ret
)
39 printf("filter_symmetry [-d debug_level] -s {");
41 for (i
= 0; GP_FilterSymmetryNames
[i
+1] != NULL
; i
++)
42 printf("%s, ", GP_FilterSymmetryNames
[i
]);
44 printf("%s} image_in image_out\n", GP_FilterSymmetryNames
[i
]);
49 int main(int argc
, char *argv
[])
52 const char *symmetry
= NULL
;
53 int opt
, sym
, debug
= 0;
55 /* Parse program options */
56 while ((opt
= getopt(argc
, argv
, "d:hs:")) != -1) {
72 /* Turn on debug messages */
73 GP_SetDebugLevel(debug
);
75 if (symmetry
== NULL
) {
76 printf("Symmetry not specified\n");
80 if (argc
- optind
!= 2) {
81 printf("Input and output image not specified\n");
85 sym
= GP_FilterSymmetryByName(symmetry
);
88 printf("Invalid symmetry name '%s'\n", symmetry
);
93 src
= GP_LoadImage(argv
[optind
], NULL
);
96 fprintf(stderr
, "Failed to load image '%s': %s\n",
97 argv
[optind
], strerror(errno
));
101 /* Apply a symmetry filter */
102 res
= GP_FilterSymmetryAlloc(src
, sym
, NULL
);
105 if (GP_SaveImage(res
, argv
[optind
+1], NULL
)) {
106 fprintf(stderr
, "Failed to save image '%s': %s\n",
107 argv
[optind
+1], strerror(errno
));