1 /**
2 * SDL_stretch test
3
4 * Copyright (C) 2008 Sylvain Beucler
5
6 * This file is part of GNU FreeDink
7
8 * GNU FreeDink is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 3 of the
11 * License, or (at your option) any later version.
12
13 * GNU FreeDink is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
21 */
22
23 #include <stdio.h>
24 #include "SDL.h"
25 #include "SDL_stretch/SDL_stretch.h"
26
main(void)27 int main(void)
28 {
29 SDL_Init(SDL_INIT_VIDEO);
30 SDL_Surface *screen = SDL_SetVideoMode(640, 480, 8, 0);
31 SDL_Surface *bmp = SDL_LoadBMP("/usr/local/share/dink/dink/Tiles/Ts01.bmp");
32 printf("%p\n", bmp);
33 SDL_Surface *test = SDL_CreateRGBSurface(SDL_SWSURFACE, 9*bmp->w, 9*bmp->h, 8, 0, 0, 0, 0);
34 SDL_SetColors(test, bmp->format->palette->colors, 0, 256);
35 printf("%p - %dx%d\n", test, test->w, test->h);
36 //SDL_Rect src = {250, 50, 100, 100};
37 SDL_Rect src = {0, 0, bmp->w, bmp->h};
38 /* Only operated on surfaces with exactly the same format :/ */
39 SDL_StretchSurfaceRect(bmp, &src, test, NULL);
40 //SDL_BlitSurface(bmp, NULL, test, NULL);
41 SDL_SaveBMP(test, "/tmp/test.bmp");
42 /* We now can check that the scaled image doesn't have the 1-pixel
43 posponement that SDL_gfx has */
44 SDL_Quit();
45 return 0;
46 }
47
48
49 /**
50 * Local Variables:
51 * compile-command: "gcc -O0 sdl_stretch.c -o sdl_stretch `sdl-config --cflags --libs` `pkg-config SDL_stretch --cflags --libs`"
52 * End:
53 */
54