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_LoadImage(argv
[1], NULL
);
49 fprintf(stderr
, "Failed to load bitmap: %s\n", strerror(errno
));
53 /* Initalize backend */
54 backend
= GP_BackendX11Init(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_BackendFlip(backend
);
69 GP_BackendWaitEvent(backend
, &ev
);
71 if (ev
.type
== GP_EV_KEY
&& ev
.val
.val
== GP_KEY_Q
) {
72 GP_BackendExit(backend
);
76 if (ev
.type
== GP_EV_SYS
&& ev
.code
== GP_EV_SYS_RESIZE
) {
79 GP_BackendResizeAck(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_BackendFlip(backend
);