Added a simple GDK example program, that loads and scales an image
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 15 Aug 2008 22:48:25 +0000 (19:48 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 15 Aug 2008 22:48:25 +0000 (19:48 -0300)
gdk.c [new file with mode: 0644]

diff --git a/gdk.c b/gdk.c
new file mode 100644 (file)
index 0000000..73e11d9
--- /dev/null
+++ b/gdk.c
@@ -0,0 +1,54 @@
+/*
+ *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#define FILENAME "/home/cascardo/fotos/debconf.jpg"
+#define WIDTH 800
+#define HEIGHT 600
+
+int
+main (int argc, char **argv)
+{
+  char *filename;
+  GdkPixbuf *picture;
+  GdkPixbuf *screen;
+  GdkColorspace colorspace;
+  gboolean has_alpha;
+  int bits_per_sample;
+  int width, height;
+  g_type_init ();
+  if (argc < 2)
+    filename = FILENAME;
+  else
+    filename = argv[1];
+  picture = gdk_pixbuf_new_from_file (filename, NULL);
+  colorspace = gdk_pixbuf_get_colorspace (picture);
+  has_alpha = gdk_pixbuf_get_has_alpha (picture);
+  bits_per_sample = gdk_pixbuf_get_bits_per_sample (picture);
+  width = WIDTH;
+  height = HEIGHT;
+  screen = gdk_pixbuf_new (colorspace, has_alpha, bits_per_sample,
+                           width, height);
+  gdk_pixbuf_scale (picture, screen, 0, 0, width, height, 0, 0, 2, 2,
+                    GDK_INTERP_BILINEAR);
+  gdk_pixbuf_unref (picture);
+  gdk_pixbuf_unref (screen);
+  return 0;
+}