From ec2fd3af076bacdfa90185b3e3bc26dd76f964c7 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 13 Apr 2017 00:56:27 +0200 Subject: image laoder --- gtktest.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'gtktest.c') diff --git a/gtktest.c b/gtktest.c index 43cb2dc..4174029 100644 --- a/gtktest.c +++ b/gtktest.c @@ -1,7 +1,11 @@ +#include #include #include #include "render.h" +#include "image.h" + +cairo_surface_t *image; static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, gpointer user_data) @@ -11,9 +15,14 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, width = gtk_widget_get_allocated_width(widget); height = gtk_widget_get_allocated_height(widget); - snprintf(info, sizeof(info), "gtktest: %dx%d", - width, height); - render_test(cr, width, height, info, NULL); + + if (image) { + render_image(cr, width, height, image); + } else { + snprintf(info, sizeof(info), "gtktest: %dx%d", + width, height); + render_test(cr, width, height, info, NULL); + } return FALSE; } @@ -38,6 +47,11 @@ int main(int argc, char *argv[]) gtk_window_set_default_size(GTK_WINDOW(window), 640, 480); gtk_window_set_title(GTK_WINDOW(window), "gtktest"); + if (argv[1]) { + fprintf(stderr, "loading %s ...\n", argv[1]); + image = load_jpeg(argv[1]); + } + gtk_widget_show_all(window); gtk_main(); -- cgit