void dummybrushdmenuselect (GtkWidget *w, gpointer data) { ppm_kill (&brushppm); ppm_new (&brushppm, 10,10); brush_from_file = 0; update_brush_preview (NULL); }
static void brushdmenuselect (GtkWidget *widget, gpointer data) { GimpPixelRgn src_rgn; guchar *src_row; guchar *src; gint id; gint bpp; gint x, y; ppm_t *p; gint x1, y1, x2, y2; gint row; GimpDrawable *drawable; gint rowstride; gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &id); if (id == -1) return; if (brush_from_file == 2) return; /* Not finished GUI-building yet */ if (brush_from_file) { #if 0 unselectall (brush_list); #endif preset_save_button_set_sensitive (FALSE); } gtk_adjustment_set_value (brush_gamma_adjust, 1.0); gtk_adjustment_set_value (brush_aspect_adjust, 0.0); drawable = gimp_drawable_get (id); gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2); bpp = gimp_drawable_bpp (drawable->drawable_id); ppm_kill (&brushppm); ppm_new (&brushppm, x2 - x1, y2 - y1); p = &brushppm; rowstride = p->width * 3; src_row = g_new (guchar, (x2 - x1) * bpp); gimp_pixel_rgn_init (&src_rgn, drawable, 0, 0, x2 - x1, y2 - y1, FALSE, FALSE); if (bpp == 3) { /* RGB */ int bpr = (x2 - x1) * 3; for (row = 0, y = y1; y < y2; row++, y++) { gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1)); memcpy (p->col + row*rowstride, src_row, bpr); } } else { /* RGBA (bpp > 3) GrayA (bpp == 2) or Gray */ gboolean is_gray = ((bpp > 3) ? TRUE : FALSE); for (row = 0, y = y1; y < y2; row++, y++) { guchar *tmprow = p->col + row * rowstride; guchar *tmprow_ptr; gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1)); src = src_row; tmprow_ptr = tmprow; /* Possible micro-optimization here: * src_end = src + src_rgn.bpp * (x2-x1); * for ( ; src < src_end ; src += src_rgn.bpp) */ for (x = x1; x < x2; x++) { *(tmprow_ptr++) = src[0]; *(tmprow_ptr++) = src[is_gray ? 1 : 0]; *(tmprow_ptr++) = src[is_gray ? 2 : 0]; src += src_rgn.bpp; } } } g_free (src_row); if (bpp >= 3) pcvals.color_brushes = 1; else pcvals.color_brushes = 0; brush_from_file = 0; update_brush_preview (NULL); }
static void brush_asepct_adjust_cb (GtkWidget *w, gpointer data) { gimp_double_adjustment_update (GTK_ADJUSTMENT (w), data); update_brush_preview (pcvals.selected_brush); }
/* * "force" implies here to change the brush even if it was the same. * It is used for the initialization of the preview. * */ static void brush_select (GtkTreeSelection *selection, gboolean force) { GtkTreeIter iter; GtkTreeModel *model; gchar *fname = NULL; gchar *brush = NULL; if (brush_dont_update) goto cleanup; if (brush_from_file == 0) { update_brush_preview (NULL); goto cleanup; } if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, 0, &brush, -1); /* Check if the same brush was selected twice, and if so * break. Otherwise, the brush gamma and stuff would have been * reset. * */ if (last_selected_brush == NULL) { last_selected_brush = g_strdup (brush); } else { if (!strcmp (last_selected_brush, brush)) { if (!force) { goto cleanup; } } else { g_free (last_selected_brush); last_selected_brush = g_strdup (brush); } } brush_dont_update = TRUE; gtk_adjustment_set_value (brush_gamma_adjust, 1.0); gtk_adjustment_set_value (brush_aspect_adjust, 0.0); brush_dont_update = FALSE; if (brush) { fname = g_build_filename ("Brushes", brush, NULL); g_strlcpy (pcvals.selected_brush, fname, sizeof (pcvals.selected_brush)); update_brush_preview (fname); } } cleanup: g_free (fname); g_free (brush); }
static void brush_asepct_adjust_cb (GtkAdjustment *a, gpointer data) { gimp_double_adjustment_update (a, data); update_brush_preview (pcvals.selected_brush); }