Mercurial > cropper
diff callbacks.c @ 7:ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
author | meillo@marmaro.de |
---|---|
date | Wed, 19 Mar 2008 23:01:43 +0100 |
parents | 2f11ab3e6047 |
children | b0824876d379 |
line wrap: on
line diff
--- a/callbacks.c Fri Dec 07 21:38:25 2007 +0100 +++ b/callbacks.c Wed Mar 19 23:01:43 2008 +0100 @@ -1,10 +1,14 @@ #include <gtk/gtk.h> +#include <gdk-pixbuf/gdk-pixbuf.h> #include "main.h" #include "callbacks.h" #include "interface.h" #include "support.h" +int image_width; +int image_height; +float inc = 0.1; /* void update_spin_button_ratio(GtkWidget* spinbutton) { g_print("ratio change: %f\n", ratio); @@ -161,6 +165,45 @@ +/* zoom */ +void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) { + printf("zoom in clicked\n"); + image_width *= 1 + inc; + image_height *= 1 + inc; + gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), + gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); +} + +void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) { + printf("zoom out clicked\n"); + image_width *= 1 - inc; + image_height *= 1 - inc; + gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), + gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); +} + +void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) { + printf("zoom 100 clicked\n"); + image_width = gdk_pixbuf_get_width(image_buffer); + image_height = gdk_pixbuf_get_height(image_buffer); + gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), + gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); +} + +void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) { + printf("zoom fit clicked\n"); + image_width = gdk_pixbuf_get_width(image_buffer) + 200; /* FIXME */ + image_height = gdk_pixbuf_get_height(image_buffer) + 200; /* FIXME */ + gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), + gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); +} + + + + + + + void on_crop_clicked(GtkButton* button, gpointer user_data) { char crop_call[256]; @@ -176,6 +219,10 @@ gtk_main_quit(); } +void on_cropper_window_create (GtkObject* object, gpointer user_data) { + image_width = gdk_pixbuf_get_width(image_buffer); + image_height = gdk_pixbuf_get_height(image_buffer); +} void on_cropper_window_destroy (GtkObject* object, gpointer user_data) { gtk_main_quit();