73e11d9e965b9edbd66e5b67170071bd1681277c
[cascardo/movie.git] / gdk.c
1 /*
2  *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program 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
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along
15  *  with this program; if not, write to the Free Software Foundation, Inc.,
16  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19
20 #include <gdk-pixbuf/gdk-pixbuf.h>
21
22 #define FILENAME "/home/cascardo/fotos/debconf.jpg"
23 #define WIDTH 800
24 #define HEIGHT 600
25
26 int
27 main (int argc, char **argv)
28 {
29   char *filename;
30   GdkPixbuf *picture;
31   GdkPixbuf *screen;
32   GdkColorspace colorspace;
33   gboolean has_alpha;
34   int bits_per_sample;
35   int width, height;
36   g_type_init ();
37   if (argc < 2)
38     filename = FILENAME;
39   else
40     filename = argv[1];
41   picture = gdk_pixbuf_new_from_file (filename, NULL);
42   colorspace = gdk_pixbuf_get_colorspace (picture);
43   has_alpha = gdk_pixbuf_get_has_alpha (picture);
44   bits_per_sample = gdk_pixbuf_get_bits_per_sample (picture);
45   width = WIDTH;
46   height = HEIGHT;
47   screen = gdk_pixbuf_new (colorspace, has_alpha, bits_per_sample,
48                            width, height);
49   gdk_pixbuf_scale (picture, screen, 0, 0, width, height, 0, 0, 2, 2,
50                     GDK_INTERP_BILINEAR);
51   gdk_pixbuf_unref (picture);
52   gdk_pixbuf_unref (screen);
53   return 0;
54 }