Forgotten to add filters to .PHONY targets.
[gfxprim.git] / filters / tests / rotate_test.c
blobaacb2359c08f5887501a52b40fb742360e4c3443
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-2010 Jiri "BlueBear" Dluhos *
20 * <jiri.bluebear.dluhos@gmail.com> *
21 * *
22 * Copyright (C) 2009-2010 Cyril Hrubis <metan@ucw.cz> *
23 * *
24 *****************************************************************************/
26 #include <GP.h>
27 #include <GP_PGM.h>
28 #include <GP_Rotate.h>
30 #define W 221
31 #define H 160
33 int main(void)
35 int i;
37 GP_Context *context = GP_ContextAlloc(W, H, GP_PIXEL_G2), *copy;
39 if (context == NULL) {
40 fprintf(stderr, "Couldn't allocate context\n");
41 return 1;
44 for (i = 0; i < 20; i++)
45 GP_HLineXYW(context, 0, i, i, 3);
47 for (i = 0; i < 20; i++)
48 GP_HLineXYW(context, 1, i + 20, i, 2);
50 for (i = 0; i < 20; i++)
51 GP_HLineXYW(context, 2, i + 40, i, 1);
53 for (i = 0; i < 20; i++)
54 GP_HLineXYW(context, 3, i + 60, i, 3);
56 for (i = 0; i < 20; i++)
57 GP_HLineXYW(context, 4, i + 80, i, 2);
59 GP_Line(context, 0, 0, W, H, 3);
60 GP_Line(context, 0, H, W, 0, 3);
62 GP_FillCircle(context, W/2, H/2, 19, 3);
63 GP_FillCircle(context, W/2, H/2, 7, 2);
64 GP_FillCircle(context, W/2, H/2, 5, 1);
65 GP_FillCircle(context, W/2, H/2, 2, 0);
66 GP_Text(context, NULL, 60, 10, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 3);
67 GP_Text(context, NULL, 60, 20, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 2);
68 GP_Text(context, NULL, 60, 30, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 1);
70 if (GP_SavePGM("test.pgm", context)) {
71 fprintf(stderr, "Can't save context\n");
72 return 1;
75 copy = GP_ContextCopy(context, GP_COPY_WITH_PIXELS);
76 GP_MirrorH(copy);
78 if (GP_SavePGM("test-mh.pgm", copy)) {
79 fprintf(stderr, "Can't save context\n");
80 return 1;
83 GP_ContextFree(copy);
84 copy = GP_ContextCopy(context, GP_COPY_WITH_PIXELS);
86 GP_MirrorV(copy);
88 if (GP_SavePGM("test-mv.pgm", copy)) {
89 fprintf(stderr, "Can't save context\n");
90 return 1;
93 GP_ContextFree(copy);
94 copy = GP_ContextCopy(context, GP_COPY_WITH_PIXELS);
96 GP_RotateCW(copy);
98 if (GP_SavePGM("test-cw.pgm", copy)) {
99 fprintf(stderr, "Can't save context\n");
100 return 1;
103 GP_ContextFree(copy);
104 copy = GP_ContextCopy(context, GP_COPY_WITH_PIXELS);
106 GP_RotateCCW(copy);
108 if (GP_SavePGM("test-ccw.pgm", copy)) {
109 fprintf(stderr, "Can't save context\n");
110 return 1;
113 GP_ContextFree(copy);
114 GP_ContextFree(context);
116 return 0;