diff options
Diffstat (limited to 'image.c')
-rw-r--r-- | image.c | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -1,4 +1,5 @@ #include <glib.h> +#include <gtk/gtk.h> #include "image.h" complex_image_t * @@ -157,3 +158,60 @@ pixbuf_from_complex_image (complex_image_t *image, convert_type_t convert) return pixbuf; } +static gboolean +on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data) +{ + GdkPixbuf *pixbuf = data; + int i, j; + int pwidth = gdk_pixbuf_get_width (pixbuf); + int pheight = gdk_pixbuf_get_height (pixbuf); + int dwidth, dheight; + + gdk_drawable_get_size (widget->window, &dwidth, &dheight); + + for (i = 0; i < dheight; i += pheight) + { + for (j = 0; j < dwidth; j += pwidth) + { + gdk_draw_pixbuf (widget->window, NULL, + pixbuf, 0, 0, j, i, pwidth, pheight, + GDK_RGB_DITHER_NONE, + 0, 0); + } + } + return TRUE; +} + +void +complex_image_show (const char *title, + complex_image_t *image, + convert_type_t convert) +{ + GtkWidget *window, *da; + GdkPixbuf *pixbuf; + int argc; + char **argv; + char *arg0 = g_strdup (title); + + argc = 1; + argv = (char **)&arg0; + + gtk_init (&argc, &argv); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + da = gtk_drawing_area_new (); + + gtk_container_add (GTK_CONTAINER (window), da); + + gtk_window_set_default_size (GTK_WINDOW (window), image->width * 2, image->height * 2); + + pixbuf = pixbuf_from_complex_image (image, convert); + + g_signal_connect (da, "expose_event", G_CALLBACK (on_expose), pixbuf); + g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL); + + gtk_widget_show_all (window); + + gtk_main (); +} |