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-2011 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
31 SDL_Surface
*display
= NULL
;
32 GP_Context context
, *bitmap
;
41 while (SDL_WaitEvent(&event
) > 0) {
46 switch (event
.key
.keysym
.sym
) {
54 GP_FILTER_PARAMS(bitmap
->pixel_type
, param
);
55 GP_FilterParamSetIntAll(param
, brightness
);
56 res
= GP_FilterBrightness(bitmap
, NULL
, param
, NULL
);
58 printf("brightness = %i %ux%u\n", brightness
, res
->w
, res
->h
);
60 GP_Blit(res
, 0, 0, res
->w
, res
->h
, &context
, 0, 0);
76 int main(int argc
, char *argv
[])
78 /* Bits per pixel to be set for the display surface. */
82 for (i
= 1; i
< argc
; i
++) {
83 if (strcmp(argv
[i
], "-16") == 0) {
86 else if (strcmp(argv
[i
], "-24") == 0) {
89 else if (strcmp(argv
[i
], "-32") == 0) {
96 if ((bitmap
= GP_LoadImage(argv
[1], NULL
)) == NULL
) {
97 fprintf(stderr
, "Failed to load bitmap: %s\n", strerror(errno
));
102 if (SDL_Init(SDL_INIT_VIDEO
| SDL_INIT_TIMER
) != 0) {
103 fprintf(stderr
, "Could not initialize SDL: %s\n", SDL_GetError());
107 /* Create a window with a software back surface */
108 display
= SDL_SetVideoMode(bitmap
->w
, bitmap
->h
, display_bpp
, SDL_SWSURFACE
);
109 if (display
== NULL
) {
110 fprintf(stderr
, "Could not open display: %s\n", SDL_GetError());
114 GP_SDL_ContextFromSurface(&context
, display
);
116 GP_Blit(bitmap
, 0, 0, bitmap
->w
, bitmap
->h
, &context
, 0, 0);