cropper
diff callbacks.c @ 8:b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
author | meillo@marmaro.de |
---|---|
date | Thu, 20 Mar 2008 19:31:44 +0100 |
parents | ec2d11d96fb0 |
children | 7e1cf00de1df |
line diff
1.1 --- a/callbacks.c Wed Mar 19 23:01:43 2008 +0100 1.2 +++ b/callbacks.c Thu Mar 20 19:31:44 2008 +0100 1.3 @@ -166,36 +166,42 @@ 1.4 1.5 1.6 /* zoom */ 1.7 +void set_zoom() { 1.8 + static GdkPixbuf* pixbuf_new; 1.9 + g_object_unref(pixbuf_new); 1.10 + 1.11 + pixbuf_new = gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_HYPER); 1.12 + gtk_image_set_from_pixbuf((GtkImage*) lookup_widget(cropper_window, "image_area"), pixbuf_new); 1.13 +} 1.14 + 1.15 void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) { 1.16 - printf("zoom in clicked\n"); 1.17 image_width *= 1 + inc; 1.18 image_height *= 1 + inc; 1.19 - gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 1.20 - gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 1.21 + set_zoom(); 1.22 } 1.23 1.24 void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) { 1.25 - printf("zoom out clicked\n"); 1.26 image_width *= 1 - inc; 1.27 image_height *= 1 - inc; 1.28 - gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 1.29 - gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 1.30 + set_zoom(); 1.31 } 1.32 1.33 void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) { 1.34 - printf("zoom 100 clicked\n"); 1.35 image_width = gdk_pixbuf_get_width(image_buffer); 1.36 image_height = gdk_pixbuf_get_height(image_buffer); 1.37 - gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 1.38 - gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 1.39 + set_zoom(); 1.40 } 1.41 1.42 void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) { 1.43 - printf("zoom fit clicked\n"); 1.44 - image_width = gdk_pixbuf_get_width(image_buffer) + 200; /* FIXME */ 1.45 - image_height = gdk_pixbuf_get_height(image_buffer) + 200; /* FIXME */ 1.46 - gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 1.47 - gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 1.48 + int w, h; 1.49 + GtkWidget* image_a; 1.50 + 1.51 + image_a = (GtkWidget*) lookup_widget(cropper_window, "image_area"); 1.52 + gdk_drawable_get_size (image_a->window, &w, &h); 1.53 + 1.54 + image_width = w - 200; 1.55 + image_height = h - 150; 1.56 + set_zoom(); 1.57 } 1.58 1.59 1.60 @@ -208,10 +214,10 @@ 1.61 char crop_call[256]; 1.62 1.63 sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"", 1.64 - gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_width_spinbutton")), 1.65 - gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_height_spinbutton")), 1.66 - gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_x_spinbutton")), 1.67 - gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_y_spinbutton")), 1.68 + gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_width_spinbutton")), 1.69 + gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_height_spinbutton")), 1.70 + gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_x_spinbutton")), 1.71 + gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_y_spinbutton")), 1.72 image_filename, 1.73 image_filename 1.74 );