static void gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool) { gimp_matrix3_identity (&tr_tool->transform); gimp_transform_matrix_scale (&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[X0], tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]); }
static GimpValueArray * scale_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; 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)); if (success) { gint x, y, width, height; success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) && x0 < x1 && y0 < y1); 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_scale (&matrix, x, y, width, height, x0, y0, x1 - x0, y1 - y0); if (interpolation) interpolation_type = gimp->config->interpolation_type; if (progress) gimp_progress_start (progress, _("Scaling"), 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; }