comparison 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
comparison
equal deleted inserted replaced
7:ec2d11d96fb0 8:b0824876d379
164 */ 164 */
165 165
166 166
167 167
168 /* zoom */ 168 /* zoom */
169 void set_zoom() {
170 static GdkPixbuf* pixbuf_new;
171 g_object_unref(pixbuf_new);
172
173 pixbuf_new = gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_HYPER);
174 gtk_image_set_from_pixbuf((GtkImage*) lookup_widget(cropper_window, "image_area"), pixbuf_new);
175 }
176
169 void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) { 177 void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) {
170 printf("zoom in clicked\n");
171 image_width *= 1 + inc; 178 image_width *= 1 + inc;
172 image_height *= 1 + inc; 179 image_height *= 1 + inc;
173 gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 180 set_zoom();
174 gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR));
175 } 181 }
176 182
177 void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) { 183 void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) {
178 printf("zoom out clicked\n");
179 image_width *= 1 - inc; 184 image_width *= 1 - inc;
180 image_height *= 1 - inc; 185 image_height *= 1 - inc;
181 gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 186 set_zoom();
182 gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR));
183 } 187 }
184 188
185 void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) { 189 void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) {
186 printf("zoom 100 clicked\n");
187 image_width = gdk_pixbuf_get_width(image_buffer); 190 image_width = gdk_pixbuf_get_width(image_buffer);
188 image_height = gdk_pixbuf_get_height(image_buffer); 191 image_height = gdk_pixbuf_get_height(image_buffer);
189 gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 192 set_zoom();
190 gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR));
191 } 193 }
192 194
193 void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) { 195 void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) {
194 printf("zoom fit clicked\n"); 196 int w, h;
195 image_width = gdk_pixbuf_get_width(image_buffer) + 200; /* FIXME */ 197 GtkWidget* image_a;
196 image_height = gdk_pixbuf_get_height(image_buffer) + 200; /* FIXME */ 198
197 gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), 199 image_a = (GtkWidget*) lookup_widget(cropper_window, "image_area");
198 gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); 200 gdk_drawable_get_size (image_a->window, &w, &h);
201
202 image_width = w - 200;
203 image_height = h - 150;
204 set_zoom();
199 } 205 }
200 206
201 207
202 208
203 209
206 212
207 void on_crop_clicked(GtkButton* button, gpointer user_data) { 213 void on_crop_clicked(GtkButton* button, gpointer user_data) {
208 char crop_call[256]; 214 char crop_call[256];
209 215
210 sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"", 216 sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"",
211 gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_width_spinbutton")), 217 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_width_spinbutton")),
212 gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_height_spinbutton")), 218 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_height_spinbutton")),
213 gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_x_spinbutton")), 219 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_x_spinbutton")),
214 gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_y_spinbutton")), 220 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_y_spinbutton")),
215 image_filename, 221 image_filename,
216 image_filename 222 image_filename
217 ); 223 );
218 system(crop_call); 224 system(crop_call);
219 gtk_main_quit(); 225 gtk_main_quit();