static void gimp_perspective_clone_tool_recalc_matrix (GimpPerspectiveCloneTool *clone_tool, GimpToolWidget *widget) { gimp_matrix3_identity (&clone_tool->transform); gimp_transform_matrix_perspective (&clone_tool->transform, clone_tool->x1, clone_tool->y1, clone_tool->x2 - clone_tool->x1, clone_tool->y2 - clone_tool->y1, clone_tool->trans_info[X0], clone_tool->trans_info[Y0], clone_tool->trans_info[X1], clone_tool->trans_info[Y1], clone_tool->trans_info[X2], clone_tool->trans_info[Y2], clone_tool->trans_info[X3], clone_tool->trans_info[Y3]); if (widget) g_object_set (widget, "transform", &clone_tool->transform, "x1", (gdouble) clone_tool->x1, "y1", (gdouble) clone_tool->y1, "x2", (gdouble) clone_tool->x2, "y2", (gdouble) clone_tool->y2, "pivot-x", clone_tool->trans_info[PIVOT_X], "pivot-y", clone_tool->trans_info[PIVOT_Y], NULL); }
static void gimp_perspective_tool_recalc_matrix (GimpTransformTool *tr_tool) { gimp_matrix3_identity (&tr_tool->transform); gimp_transform_matrix_perspective (&tr_tool->transform, tr_tool->x1, tr_tool->y1, tr_tool->x2 - tr_tool->x1, tr_tool->y2 - tr_tool->y1, tr_tool->trans_info[X0], tr_tool->trans_info[Y0], tr_tool->trans_info[X1], tr_tool->trans_info[Y1], tr_tool->trans_info[X2], tr_tool->trans_info[Y2], tr_tool->trans_info[X3], tr_tool->trans_info[Y3]); }
static void gimp_perspective_clone_tool_recalc_matrix (GimpPerspectiveCloneTool *clone_tool) { gimp_matrix3_identity (&clone_tool->transform); gimp_transform_matrix_perspective (&clone_tool->transform, clone_tool->x1, clone_tool->y1, clone_tool->x2 - clone_tool->x1, clone_tool->y2 - clone_tool->y1, clone_tool->trans_info[X0], clone_tool->trans_info[Y0], clone_tool->trans_info[X1], clone_tool->trans_info[Y1], clone_tool->trans_info[X2], clone_tool->trans_info[Y2], clone_tool->trans_info[X3], clone_tool->trans_info[Y3]); gimp_perspective_clone_tool_transform_bounding_box (clone_tool); }
static GimpValueArray * perspective_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpValueArray *return_vals; GimpDrawable *drawable; gboolean interpolation; gdouble x0; gdouble y0; gdouble x1; gdouble y1; gdouble x2; gdouble y2; gdouble x3; gdouble y3; drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp); interpolation = g_value_get_boolean (gimp_value_array_index (args, 1)); x0 = g_value_get_double (gimp_value_array_index (args, 2)); y0 = g_value_get_double (gimp_value_array_index (args, 3)); x1 = g_value_get_double (gimp_value_array_index (args, 4)); y1 = g_value_get_double (gimp_value_array_index (args, 5)); x2 = g_value_get_double (gimp_value_array_index (args, 6)); y2 = g_value_get_double (gimp_value_array_index (args, 7)); x3 = g_value_get_double (gimp_value_array_index (args, 8)); y3 = g_value_get_double (gimp_value_array_index (args, 9)); if (success) { gint x, y, width, height; success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error); if (success && gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height)) { GimpMatrix3 matrix; GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE; gint off_x, off_y; gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); x += off_x; y += off_y; /* Assemble the transformation matrix */ gimp_matrix3_identity (&matrix); gimp_transform_matrix_perspective (&matrix, x, y, width, height, x0, y0, x1, y1, x2, y2, x3, y3); if (interpolation) interpolation_type = gimp->config->interpolation_type; if (progress) gimp_progress_start (progress, _("Perspective"), FALSE); if (! gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) && ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (GIMP_ITEM (drawable))))) { if (! gimp_drawable_transform_affine (drawable, context, &matrix, GIMP_TRANSFORM_FORWARD, interpolation_type, 3, FALSE, progress)) { success = FALSE; } } else { gimp_item_transform (GIMP_ITEM (drawable), context, &matrix, GIMP_TRANSFORM_FORWARD, interpolation, 3, FALSE, progress); } if (progress) gimp_progress_end (progress); } } return_vals = gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); if (success) gimp_value_set_drawable (gimp_value_array_index (return_vals, 1), drawable); return return_vals; }