*/
+#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#define FILENAME "/home/cascardo/fotos/debconf.jpg"
#define WIDTH 800
#define HEIGHT 600
+gboolean
+queue (gpointer data)
+{
+ gtk_widget_queue_draw (GTK_WIDGET (data));
+ return TRUE;
+}
+
+gboolean
+expose (GtkWidget *widget, GdkEventExpose *event, gpointer data)
+{
+ GdkPixbuf *picture;
+ GdkPixbuf *screen;
+ picture = (GdkPixbuf *) data;
+ screen = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
+ event->area.width, event->area.height);
+ gdk_pixbuf_scale (picture, screen, 0, 0,
+ event->area.width, event->area.height,
+ -event->area.x, -event->area.y,
+ 4.0, 4.0, GDK_INTERP_HYPER);
+ gdk_draw_pixbuf (widget->window, NULL, screen, 0, 0, 0, 0, -1, -1,
+ GDK_RGB_DITHER_NONE, 0, 0);
+ gdk_pixbuf_unref (screen);
+ return FALSE;
+}
+
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 ();
+ GtkWidget *window;
+ GtkWidget *draw;
+ gtk_init (&argc, &argv);
if (argc < 2)
filename = FILENAME;
else
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);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_signal_connect (G_OBJECT (window), "destroy",
+ G_CALLBACK (gtk_main_quit), NULL);
+ draw = gtk_drawing_area_new ();
+ gtk_widget_set_size_request (draw, width, height);
+ gtk_container_add (GTK_CONTAINER (window), draw);
+ gtk_widget_show_all (window);
+ g_signal_connect (G_OBJECT (draw), "expose_event",
+ G_CALLBACK (expose), picture);
+ g_timeout_add (10, queue, draw);
+ gtk_main ();
gdk_pixbuf_unref (picture);
- gdk_pixbuf_unref (screen);
return 0;
}