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 diff
1.1 --- a/callbacks.c Fri Dec 07 21:38:25 2007 +0100 1.2 +++ b/callbacks.c Wed Mar 19 23:01:43 2008 +0100 1.3 @@ -1,10 +1,14 @@ 1.4 #include <gtk/gtk.h> 1.5 +#include <gdk-pixbuf/gdk-pixbuf.h> 1.6 1.7 #include "main.h" 1.8 #include "callbacks.h" 1.9 #include "interface.h" 1.10 #include "support.h" 1.11 1.12 +int image_width; 1.13 +int image_height; 1.14 +float inc = 0.1; 1.15 /* 1.16 void update_spin_button_ratio(GtkWidget* spinbutton) { 1.17 g_print("ratio change: %f\n", ratio); 1.18 @@ -161,6 +165,45 @@ 1.19 1.20 1.21 1.22 +/* zoom */ 1.23 +void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) { 1.24 + printf("zoom in clicked\n"); 1.25 + image_width *= 1 + inc; 1.26 + image_height *= 1 + inc; 1.27 + gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 1.28 + gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 1.29 +} 1.30 + 1.31 +void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) { 1.32 + printf("zoom out clicked\n"); 1.33 + image_width *= 1 - inc; 1.34 + image_height *= 1 - inc; 1.35 + gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 1.36 + gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 1.37 +} 1.38 + 1.39 +void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) { 1.40 + printf("zoom 100 clicked\n"); 1.41 + image_width = gdk_pixbuf_get_width(image_buffer); 1.42 + image_height = gdk_pixbuf_get_height(image_buffer); 1.43 + gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 1.44 + gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 1.45 +} 1.46 + 1.47 +void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) { 1.48 + printf("zoom fit clicked\n"); 1.49 + image_width = gdk_pixbuf_get_width(image_buffer) + 200; /* FIXME */ 1.50 + image_height = gdk_pixbuf_get_height(image_buffer) + 200; /* FIXME */ 1.51 + gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 1.52 + gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 1.53 +} 1.54 + 1.55 + 1.56 + 1.57 + 1.58 + 1.59 + 1.60 + 1.61 void on_crop_clicked(GtkButton* button, gpointer user_data) { 1.62 char crop_call[256]; 1.63 1.64 @@ -176,6 +219,10 @@ 1.65 gtk_main_quit(); 1.66 } 1.67 1.68 +void on_cropper_window_create (GtkObject* object, gpointer user_data) { 1.69 + image_width = gdk_pixbuf_get_width(image_buffer); 1.70 + image_height = gdk_pixbuf_get_height(image_buffer); 1.71 +} 1.72 1.73 void on_cropper_window_destroy (GtkObject* object, gpointer user_data) { 1.74 gtk_main_quit();