static GimpBezierDesc * gimp_brush_transform_boundary_exact (GimpBrush *brush, gdouble scale, gdouble aspect_ratio, gdouble angle, gdouble hardness) { const GimpTempBuf *mask; mask = gimp_brush_transform_mask (brush, NULL, scale, aspect_ratio, angle, hardness); if (mask) { GeglBuffer *buffer; GimpBoundSeg *bound_segs; gint n_bound_segs; buffer = gimp_temp_buf_create_buffer ((GimpTempBuf *) mask); bound_segs = gimp_boundary_find (buffer, NULL, babl_format ("Y float"), GIMP_BOUNDARY_WITHIN_BOUNDS, 0, 0, gegl_buffer_get_width (buffer), gegl_buffer_get_height (buffer), 0.0, &n_bound_segs); g_object_unref (buffer); if (bound_segs) { GimpBoundSeg *stroke_segs; gint n_stroke_groups; stroke_segs = gimp_boundary_sort (bound_segs, n_bound_segs, &n_stroke_groups); g_free (bound_segs); if (stroke_segs) { GimpBezierDesc *path; path = gimp_bezier_desc_new_from_bound_segs (stroke_segs, n_bound_segs, n_stroke_groups); g_free (stroke_segs); return path; } } } return NULL; }
const GimpBoundSeg * floating_sel_boundary (GimpLayer *layer, gint *n_segs) { g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL); g_return_val_if_fail (gimp_layer_is_floating_sel (layer), NULL); g_return_val_if_fail (n_segs != NULL, NULL); if (layer->fs.boundary_known == FALSE) { gint width, height; gint off_x, off_y; width = gimp_item_get_width (GIMP_ITEM (layer)); height = gimp_item_get_height (GIMP_ITEM (layer)); gimp_item_get_offset (GIMP_ITEM (layer), &off_x, &off_y); if (layer->fs.segs) g_free (layer->fs.segs); if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))) { GeglBuffer *buffer; gint i; /* find the segments */ buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer)); layer->fs.segs = gimp_boundary_find (buffer, NULL, babl_format ("A float"), GIMP_BOUNDARY_WITHIN_BOUNDS, 0, 0, width, height, GIMP_BOUNDARY_HALF_WAY, &layer->fs.num_segs); /* offset the segments */ for (i = 0; i < layer->fs.num_segs; i++) { layer->fs.segs[i].x1 += off_x; layer->fs.segs[i].y1 += off_y; layer->fs.segs[i].x2 += off_x; layer->fs.segs[i].y2 += off_y; } } else { layer->fs.num_segs = 4; layer->fs.segs = g_new0 (GimpBoundSeg, 4); /* top */ layer->fs.segs[0].x1 = off_x; layer->fs.segs[0].y1 = off_y; layer->fs.segs[0].x2 = off_x + width; layer->fs.segs[0].y2 = off_y; /* left */ layer->fs.segs[1].x1 = off_x; layer->fs.segs[1].y1 = off_y; layer->fs.segs[1].x2 = off_x; layer->fs.segs[1].y2 = off_y + height; /* right */ layer->fs.segs[2].x1 = off_x + width; layer->fs.segs[2].y1 = off_y; layer->fs.segs[2].x2 = off_x + width; layer->fs.segs[2].y2 = off_y + height; /* bottom */ layer->fs.segs[3].x1 = off_x; layer->fs.segs[3].y1 = off_y + height; layer->fs.segs[3].x2 = off_x + width; layer->fs.segs[3].y2 = off_y + height; } layer->fs.boundary_known = TRUE; } *n_segs = layer->fs.num_segs; return layer->fs.segs; }