2 * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
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.
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.
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.
21 #include <gdk-pixbuf/gdk-pixbuf.h>
33 #define FILENAME "/home/cascardo/fotos/debconf.jpg"
41 ctx = (struct ctx *) data;
42 gtk_widget_queue_draw (GTK_WIDGET (ctx->draw));
48 expose (GtkWidget *widget, GdkEventExpose *event, gpointer data)
53 ctx = (struct ctx *) data;
55 ctx->i = (ctx->i >= ctx->points->len) ? 0 : ctx->i + 1;
56 point = g_array_index (ctx->points, Point, ctx->i);
57 screen = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
58 event->area.width, event->area.height);
59 gdk_pixbuf_scale (ctx->picture, screen, 0, 0,
60 event->area.width, event->area.height,
61 -point.x + event->area.width/2, -point.y + event->area.height/2,
62 1.0, 1.0, GDK_INTERP_HYPER);
63 gdk_draw_pixbuf (widget->window, NULL, screen, 0, 0, 0, 0, -1, -1,
64 GDK_RGB_DITHER_NONE, 0, 0);
65 gdk_pixbuf_unref (screen);
68 g_timeout_add (3000, queue, ctx);
72 g_timeout_add (10, queue, ctx);
79 main (int argc, char **argv)
82 GdkColorspace colorspace;
88 gtk_init (&argc, &argv);
93 ctx.points = ReadPoints ("pro-gnu");
94 ctx.picture = gdk_pixbuf_new_from_file (filename, NULL);
95 ctx.i = ctx.points->len;
96 colorspace = gdk_pixbuf_get_colorspace (ctx.picture);
97 has_alpha = gdk_pixbuf_get_has_alpha (ctx.picture);
98 bits_per_sample = gdk_pixbuf_get_bits_per_sample (ctx.picture);
101 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
102 g_signal_connect (G_OBJECT (window), "destroy",
103 G_CALLBACK (gtk_main_quit), NULL);
104 ctx.draw = gtk_drawing_area_new ();
105 gtk_widget_set_size_request (ctx.draw, width, height);
106 gtk_container_add (GTK_CONTAINER (window), ctx.draw);
107 gtk_widget_show_all (window);
108 g_signal_connect (G_OBJECT (ctx.draw), "expose_event",
109 G_CALLBACK (expose), &ctx);
110 g_timeout_add (10, queue, &ctx);
112 gdk_pixbuf_unref (ctx.picture);