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-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
25 Simple example that shows X11 window with image.
35 int main(int argc
, char *argv
[])
41 fprintf(stderr
, "Takes image as an argument\n");
46 image
= gp_load_image(argv
[1], NULL
);
49 fprintf(stderr
, "Failed to load bitmap: %s\n", strerror(errno
));
53 /* Initalize backend */
54 backend
= gp_x11_init(NULL
, 0, 0, image
->w
, image
->h
, argv
[1], 0);
57 fprintf(stderr
, "Failed to initalize backend\n");
61 /* Blit image into the window and show it */
62 gp_blit(image
, 0, 0, image
->w
, image
->h
, backend
->pixmap
, 0, 0);
63 gp_backend_flip(backend
);
69 gp_backend_wait_event(backend
, &ev
);
71 if (ev
.type
== GP_EV_KEY
&& ev
.val
.val
== GP_KEY_Q
) {
72 gp_backend_exit(backend
);
76 if (ev
.type
== GP_EV_SYS
&& ev
.code
== GP_EV_SYS_RESIZE
) {
79 gp_backend_resize_ack(backend
);
81 cx
= ((int)backend
->pixmap
->w
- (int)image
->w
) / 2;
82 cy
= ((int)backend
->pixmap
->h
- (int)image
->h
) / 2;
84 gp_fill(backend
->pixmap
, 0);
85 gp_blit_clipped(image
, 0, 0, image
->w
, image
->h
, backend
->pixmap
, cx
, cy
);
86 gp_backend_flip(backend
);