void apply_wind (wind_dialog_struct *wds) { gint t1; hf_wrapper_struct *hfw; hfw = (hf_wrapper_struct *) * (hf_wrapper_struct **) wds->parent_data; if (!hfw->hf_struct->tmp_buf) hf_backup(hfw->hf_struct); t1 = clock(); set_watch_cursor(hfw); switch (wds->process) { case RIPPLES: hf_ripples (hfw->hf_struct, hfw->hf_options->img->ripples, hfw->hf_options->dist_matrix, hfw->hf_options->gauss_list); begin_pending_record(hfw,"Ripples",accept_fn,reset_fn); gtk_widget_set_sensitive(GTK_WIDGET(wds->accept) ,TRUE); break; case DUNES: default: hf_dunes (hfw->hf_struct, hfw->hf_options->img->dunes, hfw->hf_options->dist_matrix, hfw->hf_options->gauss_list); begin_pending_record(hfw,"Dunes",accept_fn,reset_fn); gtk_widget_set_sensitive(GTK_WIDGET(wds->accept) ,TRUE); } // printf("TEMPS D'ÉROSION PAR LE VENT: %d\n",clock() - t1); (*hfw->if_modified) = TRUE; hfw->if_calculated = TRUE; unset_watch_cursor(hfw); }
void draw_tools_callb(GtkWidget *wdg, gpointer data) { hf_wrapper_struct *hfw; hfw = (hf_wrapper_struct *) * (hf_wrapper_struct **) data; if (!hfw) return; // printf("ENTERING DRAW TOOLS\n"); if (wdg) if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wdg))) { // We are leaving the "draw" context, commit the changes // printf("LEAVING DRAW TOOLS\n"); hfw->hf_options->need_tmp_buf = FALSE; hf_commit_or_reset (hfw->hf_options); return; } commit_pending_record(hfw); hfw->hf_options->current_cursor = hfw->hf_options->pencil_cursor; gdk_window_set_cursor(hfw->area->window, hfw->hf_options->current_cursor); if (hfw->hf_options->current_tools) gtk_widget_hide(hfw->hf_options->current_tools); if (hfw->hf_options->draw) { if (hfw->hf_options->draw->draw_tools_dialog) { hfw->hf_options->current_tools = hfw->hf_options->draw->draw_tools_dialog; gtk_widget_show(hfw->hf_options->current_tools); } else return; } hf_backup(hfw->hf_struct); hfw->hf_options->need_tmp_buf = TRUE; hfw->hf_options->context = DRAW_TOOLS_CONTEXT; }
void apply_rotate (hf_wrapper_struct *hfw) { // Apply anti-aliased rotation, without redrawing the HF gint t1; gboolean tiling; if (hfw->tiling_ptr) { tiling = *hfw->tiling_ptr; // printf("HFW->tiling_ptr in apply_rotate: %p->%p\n",hfw,hfw->tiling_ptr); } else tiling = TRUE; if (!hfw->hf_struct->tmp_buf) hf_backup(hfw->hf_struct); if (hfw->if_calculated) return; t1 = clock(); hf_rotate(hfw->hf_struct->tmp_buf, hfw->hf_struct->hf_buf, hfw->hf_struct->max_x, hfw->hf_options->img->angle, tiling, tiling ? hfw->hf_options->img->rotate_overflow_tiling : hfw->hf_options->img->rotate_overflow_notiling); // printf("TEMPS DE ROTATION: %d; angle: %d\n",clock() - t1, hfw->hf_options->img->angle); begin_pending_record(hfw,"Rotate",accept_rotate_fn,reset_fn); gtk_widget_set_sensitive(GTK_WIDGET(hfw->hf_options->img->rotate_accept),TRUE); (*hfw->if_modified) = TRUE; hfw->if_calculated = TRUE; }
void mirror_vertical_callb(GtkWidget *wdg, gpointer data) { hf_wrapper_struct *hfw; hfw = (hf_wrapper_struct *) * (hf_wrapper_struct **) data; if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wdg))) { hf_commit_or_reset (hfw->hf_options); return; } if (!hfw->hf_options->img->mirror_vertical_dialog) { hfw->hf_options->img->mirror_vertical_dialog = mirror_vertical_dialog_new(data); gtk_container_add(GTK_CONTAINER(hfw->hf_options->img->img_dialog), hfw->hf_options->img->mirror_vertical_dialog ); } if (hfw->hf_options->img->current_subdialog) gtk_widget_hide(hfw->hf_options->img->current_subdialog); hfw->hf_options->img->current_subdialog = hfw->hf_options->img->mirror_vertical_dialog; gtk_widget_show(hfw->hf_options->img->current_subdialog); hf_backup(hfw->hf_struct); // We need to copy the result in the tmp_buf if we want to allow // the user to revert the operation by clicking repeatedly on the mirror button hf_vertical_mirror(hfw->hf_struct); begin_pending_record(hfw,"Vertical mirror",accept_fn,reset_fn); (*hfw->if_modified) = TRUE; hfw->if_calculated = TRUE; draw_hf(hfw); }
void apply_voronoi (hf_wrapper_struct *hfw) { // gint t1; if (!hfw->hf_struct->tmp_buf) hf_backup(hfw->hf_struct); if (!hfw->hf_struct->result_buf) hfw->hf_struct->result_buf = (hf_type *) x_malloc(sizeof(hf_type) * hfw->hf_struct->max_x * hfw->hf_struct->max_y, "hf_type (result_buf in apply_voronoi)"); if (!hfw->hf_struct->tmp2_buf) hfw->hf_struct->tmp2_buf = (hf_type *) x_malloc(sizeof(hf_type) * hfw->hf_struct->max_x * hfw->hf_struct->max_y, "hf_type (tmp2_buf in apply_voronoi)"); // t1 = clock(); // Convention: // 1. tmp_buf: original HF // 2. tmp2_buf: distance HF // 3. result_buf: crackled HF (base level + black lines == cracks) // 4. hf_buf: output = crackled HF + distance HF (for lifting edges) set_watch_cursor(hfw); hf_voronoi(hfw->hf_struct, hfw->hf_options->img->voronoi); voronoi_adjust_edges (hfw->hf_struct->result_buf, hfw->hf_struct->hf_buf, hfw->hf_struct->tmp2_buf, hfw->hf_options->img->voronoi->edges_level, hfw->hf_struct->max_x, hfw->hf_struct->max_y); unset_watch_cursor(hfw); // printf("TEMPS DE CRAQU�LEMENT: %d\n",clock() - t1); }
void fourier_post_processing (hf_wrapper_struct *hfw) { begin_pending_record (hfw, _("Fourier transform"), accept_fn, reset_fn); commit_pending_record (hfw); hf_backup(hfw->hf_struct); hf_wrapper_display(hfw); *(hfw->if_modified) = TRUE; hfw->if_calculated = TRUE; // printf("Fourier Post Processing\n"); }
void repeat_wind_callb (GtkWidget *wdg, gpointer data) { wind_dialog_struct *wds; hf_wrapper_struct *hfw; wds = (wind_dialog_struct *) data; hfw = (hf_wrapper_struct *) * (hf_wrapper_struct **) wds->parent_data; hf_backup(hfw->hf_struct); hfw->if_calculated = FALSE; apply_wind(wds); draw_hf(hfw); }
void hf_specific_commit_or_reset (stack_struct *stack) { hf_wrapper_struct *hfw; // printf("HF_SPECIFIC_COMMIT_OR_RESET 1 on %p\n", stack->commit_data); if (stack->commit_data) { hfw = (hf_wrapper_struct *) stack->commit_data; // printf("HF_SPECIFIC_COMMIT_OR_RESET 2 on %p: hf_buf= %p\n",hfw,hfw->hf_struct->hf_buf); if (hfw->hf_options->img && hfw->hf_options->img->set_fn) (*hfw->hf_options->img->set_fn) (hfw->hf_options->img); set_render_buffer (hfw->hf_options->render_str, hfw->hf_struct->hf_buf, hfw->hf_struct->max_x,hfw->hf_struct->max_y); hf_backup (hfw->hf_struct); } }
void rotate_angle_upd (GtkWidget *wdg, gpointer data) { hf_wrapper_struct *hfw; hfw = (hf_wrapper_struct *) * (hf_wrapper_struct **) data; if (hfw->hf_options->img->angle == (gint) GTK_ADJUSTMENT(wdg)->value) return; hfw->hf_options->img->angle = (gint) GTK_ADJUSTMENT(wdg)->value; hfw->if_calculated = FALSE; if (!hfw->hf_struct->tmp_buf) hf_backup(hfw->hf_struct); // Replace with hf_fast_rotate, if too slow // NB: hf_fast_rotate creates inconsistencies in the commitment sequence // ... sometimes part of the process is not applied when the change is committed ?? if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hfw->hf_options->img->auto_rotate))) { apply_rotate(hfw); draw_hf(hfw); } }
void fourier_callb(GtkWidget *wdg, gpointer data) { hf_wrapper_struct *hfw; hfw = (hf_wrapper_struct *) * (hf_wrapper_struct **) data; if (!hfw) return; // This is a modal dialog, so we don't change the original context // printf("ENTERING FOURIER\n"); commit_pending_record(hfw); hf_backup(hfw->hf_struct); // printf("HFW->HF_STRUCT->HF_BUF: %d\n",hfw->hf_struct->hf_buf); init_render_struct(hfw->hf_options->fourier->render_str, hfw->dirname, hfw->filename, &flag_true, &flag_true, NULL, NULL,0,0); // 4 last values are initialized in a fourier_dialog callback activate_fourier_dialog(hfw->hf_options->fourier, hfw->hf_struct->tmp_buf, hfw->hf_struct->hf_buf, hfw->hf_struct->max_x, hfw->hf_struct->max_y,HF_TYPE_ID, (gpointer) fourier_post_processing, (gpointer) hfw); }
void accept_rotate_fn (hf_wrapper_struct *hfw) { // Special accept callback, could be used for committing the rotation // with a high quality anti-aliased but slow rotate function, // when the preview is done with a fast rotate function // See the difference between hf_fast_rotate and hf_rotate in hf_c // 2002-06-16: finally we do the preview with the normal rotate function, // this is not so bad with a 512x512 HF at 1 ghz speed! // Execute the anti-aliased rotation if not yet calculated if (!hfw) return; if (!hfw->if_calculated) { apply_rotate(hfw); } commit_pending_record(hfw); hf_backup(hfw->hf_struct); if (hfw->hf_options->img->set_fn) (*hfw->hf_options->img->set_fn) ((gpointer)hfw->hf_options->img); rotate_remove_tiling (hfw); gtk_widget_set_sensitive(GTK_WIDGET(hfw->hf_options->img->accept_wdg),FALSE); }
void select_for_fill (fill_struct *pen, hf_struct_type *hf, gint x, gint y) { // Select an area in the "magic wand" style, // Then fill it given the "paint bucket" parameters (fill _struct *) hf_type filling_value, height; if (!hf->tmp_buf) hf_backup(hf); // We use "select_buf" for storing the selection mask if (!hf->select_buf) hf->select_buf = (hf_type *) x_calloc(sizeof(hf_type) * hf->max_x * hf->max_y, 1, "hf_type (hf->select_buf)"); switch (pen->select_mode) { case SELECT_ADD: height = filling_value = pen->height; break; case SELECT_SUBTRACT: filling_value = MIN_FILLING_VALUE; height = pen->height + 1; // pen->height is bounded by MAX_HF_VALUE-1 break; case SELECT_REPLACE: default: height = filling_value = pen->height; hf_reset_buffer(hf->select_buf, hf->max_x, hf->max_y); } // Height must be >= 1 and <= MAX_HF_VALUE-1 height = MIN(MAX_HF_VALUE-1,MAX(1,height)); fill_area_with_mode (hf->tmp_buf, hf->select_buf, hf->max_x, hf->max_y, filling_value, height, x, y, FILL_MAX, pen->select_mode); // Uncomment the next line for testing // memcpy (hf->hf_buf, hf->select_buf, hf->max_x*hf->max_y*sizeof(hf_type)); }