changed all transform utilities to modify the passed transform matrix

2005-03-21  Sven Neumann  <sven@gimp.org>

	* app/core/gimp-transform-utils.[ch]: changed all transform
	utilities to modify the passed transform matrix instead of
	creating a new one.

	* app/text/gimptextlayer-transform.c
	* app/tools/gimpperspectivetool.c
	* app/tools/gimprotatetool.c
	* app/tools/gimpscaletool.c
	* app/tools/gimpsheartool.c
	* app/vectors/gimpvectors.c
	* tools/pdbgen/pdb/drawable_transform.pdb
	* tools/pdbgen/pdb/transform_tools.pdb: changed accordingly.

	* app/pdb/drawable_transform_cmds.c
	* app/pdb/transform_tools_cmds.c: regenerated.
This commit is contained in:
Sven Neumann 2005-03-21 19:10:11 +00:00 committed by Sven Neumann
parent 32d063d917
commit 5d7931db74
13 changed files with 277 additions and 236 deletions

View file

@ -1,3 +1,21 @@
2005-03-21 Sven Neumann <sven@gimp.org>
* app/core/gimp-transform-utils.[ch]: changed all transform
utilities to modify the passed transform matrix instead of
creating a new one.
* app/text/gimptextlayer-transform.c
* app/tools/gimpperspectivetool.c
* app/tools/gimprotatetool.c
* app/tools/gimpscaletool.c
* app/tools/gimpsheartool.c
* app/vectors/gimpvectors.c
* tools/pdbgen/pdb/drawable_transform.pdb
* tools/pdbgen/pdb/transform_tools.pdb: changed accordingly.
* app/pdb/drawable_transform_cmds.c
* app/pdb/transform_tools_cmds.c: regenerated.
2005-03-21 Sven Neumann <sven@gimp.org>
* plug-ins/winicon/icosave.c (ico_create_palette): fixed parameter

View file

@ -28,26 +28,24 @@
void
gimp_transform_matrix_flip (GimpOrientationType flip_type,
gdouble axis,
GimpMatrix3 *result)
gimp_transform_matrix_flip (GimpMatrix3 *matrix,
GimpOrientationType flip_type,
gdouble axis)
{
g_return_if_fail (result != NULL);
gimp_matrix3_identity (result);
g_return_if_fail (matrix != NULL);
switch (flip_type)
{
case GIMP_ORIENTATION_HORIZONTAL:
gimp_matrix3_translate (result, - axis, 0.0);
gimp_matrix3_scale (result, -1.0, 1.0);
gimp_matrix3_translate (result, axis, 0.0);
gimp_matrix3_translate (matrix, - axis, 0.0);
gimp_matrix3_scale (matrix, -1.0, 1.0);
gimp_matrix3_translate (matrix, axis, 0.0);
break;
case GIMP_ORIENTATION_VERTICAL:
gimp_matrix3_translate (result, 0.0, - axis);
gimp_matrix3_scale (result, 1.0, -1.0);
gimp_matrix3_translate (result, 0.0, axis);
gimp_matrix3_translate (matrix, 0.0, - axis);
gimp_matrix3_scale (matrix, 1.0, -1.0);
gimp_matrix3_translate (matrix, 0.0, axis);
break;
case GIMP_ORIENTATION_UNKNOWN:
@ -56,81 +54,103 @@ gimp_transform_matrix_flip (GimpOrientationType flip_type,
}
void
gimp_transform_matrix_flip_free (gint x,
gimp_transform_matrix_flip_free (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
GimpMatrix3 *result)
gdouble y2)
{
gdouble angle;
g_return_if_fail (result != NULL);
g_return_if_fail (matrix != NULL);
angle = atan2 (y2 - y1, x2 - x1);
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -x1, -y1);
gimp_matrix3_rotate (result, -angle);
gimp_matrix3_scale (result, 1.0, -1.0);
gimp_matrix3_rotate (result, angle);
gimp_matrix3_translate (result, x1, y1);
gimp_matrix3_identity (matrix);
gimp_matrix3_translate (matrix, -x1, -y1);
gimp_matrix3_rotate (matrix, -angle);
gimp_matrix3_scale (matrix, 1.0, -1.0);
gimp_matrix3_rotate (matrix, angle);
gimp_matrix3_translate (matrix, x1, y1);
}
void
gimp_transform_matrix_rotate (gint x,
gint y,
gint width,
gint height,
gdouble angle,
GimpMatrix3 *result)
gimp_transform_matrix_rotate (GimpMatrix3 *matrix,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y)
{
gdouble angle = 0;
switch (rotate_type)
{
case GIMP_ROTATE_90:
angle = G_PI_2;
break;
case GIMP_ROTATE_180:
angle = G_PI;
break;
case GIMP_ROTATE_270:
angle = - G_PI_2;
break;
}
gimp_transform_matrix_rotate_center (matrix, center_x, center_y, angle);
}
void
gimp_transform_matrix_rotate_rect (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
gdouble angle)
{
gdouble center_x;
gdouble center_y;
g_return_if_fail (result != NULL);
g_return_if_fail (matrix != NULL);
center_x = (gdouble) x + (gdouble) width / 2.0;
center_y = (gdouble) y + (gdouble) height / 2.0;
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -center_x, -center_y);
gimp_matrix3_rotate (result, angle);
gimp_matrix3_translate (result, +center_x, +center_y);
gimp_matrix3_translate (matrix, -center_x, -center_y);
gimp_matrix3_rotate (matrix, angle);
gimp_matrix3_translate (matrix, +center_x, +center_y);
}
void
gimp_transform_matrix_rotate_center (gdouble center_x,
gimp_transform_matrix_rotate_center (GimpMatrix3 *matrix,
gdouble center_x,
gdouble center_y,
gdouble angle,
GimpMatrix3 *result)
gdouble angle)
{
g_return_if_fail (result != NULL);
g_return_if_fail (matrix != NULL);
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -center_x, -center_y);
gimp_matrix3_rotate (result, angle);
gimp_matrix3_translate (result, +center_x, +center_y);
gimp_matrix3_translate (matrix, -center_x, -center_y);
gimp_matrix3_rotate (matrix, angle);
gimp_matrix3_translate (matrix, +center_x, +center_y);
}
void
gimp_transform_matrix_scale (gint x,
gimp_transform_matrix_scale (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
gdouble t_x,
gdouble t_y,
gdouble t_width,
gdouble t_height,
GimpMatrix3 *result)
gdouble t_height)
{
gdouble scale_x = 1.0;
gdouble scale_y = 1.0;
g_return_if_fail (result != NULL);
g_return_if_fail (matrix != NULL);
if (width > 0)
scale_x = t_width / (gdouble) width;
@ -138,25 +158,25 @@ gimp_transform_matrix_scale (gint x,
if (height > 0)
scale_y = t_height / (gdouble) height;
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -x, -y);
gimp_matrix3_scale (result, scale_x, scale_y);
gimp_matrix3_translate (result, t_x, t_y);
gimp_matrix3_identity (matrix);
gimp_matrix3_translate (matrix, -x, -y);
gimp_matrix3_scale (matrix, scale_x, scale_y);
gimp_matrix3_translate (matrix, t_x, t_y);
}
void
gimp_transform_matrix_shear (gint x,
gimp_transform_matrix_shear (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
GimpOrientationType orientation,
gdouble amount,
GimpMatrix3 *result)
gdouble amount)
{
gdouble center_x;
gdouble center_y;
g_return_if_fail (result != NULL);
g_return_if_fail (matrix != NULL);
if (width == 0)
width = 1;
@ -167,19 +187,20 @@ gimp_transform_matrix_shear (gint x,
center_x = (gdouble) x + (gdouble) width / 2.0;
center_y = (gdouble) y + (gdouble) height / 2.0;
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -center_x, -center_y);
gimp_matrix3_identity (matrix);
gimp_matrix3_translate (matrix, -center_x, -center_y);
if (orientation == GIMP_ORIENTATION_HORIZONTAL)
gimp_matrix3_xshear (result, amount / height);
gimp_matrix3_xshear (matrix, amount / height);
else
gimp_matrix3_yshear (result, amount / width);
gimp_matrix3_yshear (matrix, amount / width);
gimp_matrix3_translate (result, +center_x, +center_y);
gimp_matrix3_translate (matrix, +center_x, +center_y);
}
void
gimp_transform_matrix_perspective (gint x,
gimp_transform_matrix_perspective (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
@ -190,14 +211,13 @@ gimp_transform_matrix_perspective (gint x,
gdouble t_x3,
gdouble t_y3,
gdouble t_x4,
gdouble t_y4,
GimpMatrix3 *result)
gdouble t_y4)
{
GimpMatrix3 matrix;
GimpMatrix3 trafo;
gdouble scalex;
gdouble scaley;
g_return_if_fail (result != NULL);
g_return_if_fail (matrix != NULL);
scalex = scaley = 1.0;
@ -207,6 +227,9 @@ gimp_transform_matrix_perspective (gint x,
if (height > 0)
scaley = 1.0 / (gdouble) height;
gimp_matrix3_translate (matrix, -x, -y);
gimp_matrix3_scale (matrix, scalex, scaley);
/* Determine the perspective transform that maps from
* the unit cube to the transformed coordinates
*/
@ -224,43 +247,40 @@ gimp_transform_matrix_perspective (gint x,
/* Is the mapping affine? */
if ((dx3 == 0.0) && (dy3 == 0.0))
{
matrix.coeff[0][0] = t_x2 - t_x1;
matrix.coeff[0][1] = t_x4 - t_x2;
matrix.coeff[0][2] = t_x1;
matrix.coeff[1][0] = t_y2 - t_y1;
matrix.coeff[1][1] = t_y4 - t_y2;
matrix.coeff[1][2] = t_y1;
matrix.coeff[2][0] = 0.0;
matrix.coeff[2][1] = 0.0;
matrix.coeff[2][2] = 1.0;
trafo.coeff[0][0] = t_x2 - t_x1;
trafo.coeff[0][1] = t_x4 - t_x2;
trafo.coeff[0][2] = t_x1;
trafo.coeff[1][0] = t_y2 - t_y1;
trafo.coeff[1][1] = t_y4 - t_y2;
trafo.coeff[1][2] = t_y1;
trafo.coeff[2][0] = 0.0;
trafo.coeff[2][1] = 0.0;
trafo.coeff[2][2] = 1.0;
}
else
{
gdouble det1, det2;
matrix.coeff[0][0] = t_x2 - t_x1 + matrix.coeff[2][0] * t_x2;
matrix.coeff[0][1] = t_x3 - t_x1 + matrix.coeff[2][1] * t_x3;
matrix.coeff[0][2] = t_x1;
trafo.coeff[0][0] = t_x2 - t_x1 + trafo.coeff[2][0] * t_x2;
trafo.coeff[0][1] = t_x3 - t_x1 + trafo.coeff[2][1] * t_x3;
trafo.coeff[0][2] = t_x1;
matrix.coeff[1][0] = t_y2 - t_y1 + matrix.coeff[2][0] * t_y2;
matrix.coeff[1][1] = t_y3 - t_y1 + matrix.coeff[2][1] * t_y3;
matrix.coeff[1][2] = t_y1;
trafo.coeff[1][0] = t_y2 - t_y1 + trafo.coeff[2][0] * t_y2;
trafo.coeff[1][1] = t_y3 - t_y1 + trafo.coeff[2][1] * t_y3;
trafo.coeff[1][2] = t_y1;
det1 = dx3 * dy2 - dy3 * dx2;
det2 = dx1 * dy2 - dy1 * dx2;
matrix.coeff[2][0] = (det2 == 0.0) ? 1.0 : det1 / det2;
trafo.coeff[2][0] = (det2 == 0.0) ? 1.0 : det1 / det2;
det1 = dx1 * dy3 - dy1 * dx3;
matrix.coeff[2][1] = (det2 == 0.0) ? 1.0 : det1 / det2;
trafo.coeff[2][1] = (det2 == 0.0) ? 1.0 : det1 / det2;
matrix.coeff[2][2] = 1.0;
trafo.coeff[2][2] = 1.0;
}
}
gimp_matrix3_identity (result);
gimp_matrix3_translate (result, -x, -y);
gimp_matrix3_scale (result, scalex, scaley);
gimp_matrix3_mult (&matrix, result);
gimp_matrix3_mult (&trafo, matrix);
}

View file

@ -20,45 +20,50 @@
#define __GIMP_TRANSFORM_UTILS_H__
void gimp_transform_matrix_flip (GimpOrientationType flip_type,
gdouble axis,
GimpMatrix3 *result);
void gimp_transform_matrix_flip_free (gint x,
void gimp_transform_matrix_flip (GimpMatrix3 *matrix,
GimpOrientationType flip_type,
gdouble axis);
void gimp_transform_matrix_flip_free (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
GimpMatrix3 *result);
void gimp_transform_matrix_rotate (gint x,
gdouble y2);
void gimp_transform_matrix_rotate (GimpMatrix3 *matrix,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y);
void gimp_transform_matrix_rotate_rect (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
gdouble angle,
GimpMatrix3 *result);
void gimp_transform_matrix_rotate_center (gdouble center_x,
gdouble angle);
void gimp_transform_matrix_rotate_center (GimpMatrix3 *matrix,
gdouble center_x,
gdouble center_y,
gdouble angle,
GimpMatrix3 *result);
void gimp_transform_matrix_scale (gint x,
gdouble angle);
void gimp_transform_matrix_scale (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
gdouble t_x,
gdouble t_y,
gdouble t_width,
gdouble t_height,
GimpMatrix3 *result);
void gimp_transform_matrix_shear (gint x,
gdouble t_height);
void gimp_transform_matrix_shear (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
GimpOrientationType orientation,
gdouble amount,
GimpMatrix3 *result);
void gimp_transform_matrix_perspective (gint x,
gdouble amount);
void gimp_transform_matrix_perspective (GimpMatrix3 *matrix,
gint x,
gint y,
gint width,
gint height,
@ -69,8 +74,7 @@ void gimp_transform_matrix_perspective (gint x,
gdouble t_x3,
gdouble t_y3,
gdouble t_x4,
gdouble t_y4,
GimpMatrix3 *result);
gdouble t_y4);
#endif /* __GIMP_TRANSFORM_UTILS_H__ */

View file

@ -241,9 +241,9 @@ drawable_transform_flip_invoker (Gimp *gimp,
GimpMatrix3 matrix;
/* Assemble the transformation matrix */
gimp_transform_matrix_flip_free (x, y, width, height,
x0, y0, x1, y1,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_flip_free (&matrix,
x, y, width, height, x0, y0, x1, y1);
if (progress)
gimp_progress_start (progress, _("Flip..."), FALSE);
@ -393,9 +393,9 @@ drawable_transform_flip_default_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_flip_free (x, y, width, height,
x0, y0, x1, y1,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_flip_free (&matrix,
x, y, width, height, x0, y0, x1, y1);
if (interpolate)
interpolation_type = gimp->config->interpolation_type;
@ -552,12 +552,13 @@ drawable_transform_perspective_invoker (Gimp *gimp,
GimpMatrix3 matrix;
/* Assemble the transformation matrix */
gimp_transform_matrix_perspective (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_perspective (&matrix,
x, y, width, height,
trans_info[X0], trans_info[Y0],
trans_info[X1], trans_info[Y1],
trans_info[X2], trans_info[Y2],
trans_info[X3], trans_info[Y3],
&matrix);
trans_info[X3], trans_info[Y3]);
if (progress)
gimp_progress_start (progress, _("Perspective..."), FALSE);
@ -732,12 +733,13 @@ drawable_transform_perspective_default_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_perspective (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_perspective (&matrix,
x, y, width, height,
trans_info[X0], trans_info[Y0],
trans_info[X1], trans_info[Y1],
trans_info[X2], trans_info[Y2],
trans_info[X3], trans_info[Y3],
&matrix);
trans_info[X3], trans_info[Y3]);
if (interpolate)
interpolation_type = gimp->config->interpolation_type;
@ -1024,12 +1026,12 @@ drawable_transform_rotate_invoker (Gimp *gimp,
GimpMatrix3 matrix;
/* Assemble the transformation matrix */
gimp_matrix3_identity (&matrix);
if (auto_center)
gimp_transform_matrix_rotate (x, y, width, height, angle,
&matrix);
gimp_transform_matrix_rotate_rect (&matrix, x, y, width, height, angle);
else
gimp_transform_matrix_rotate_center (center_x, center_y, angle,
&matrix);
gimp_transform_matrix_rotate_center (&matrix,
center_x, center_y, angle);
if (progress)
gimp_progress_start (progress, _("Rotating..."), FALSE);
@ -1179,12 +1181,12 @@ drawable_transform_rotate_default_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_matrix3_identity (&matrix);
if (auto_center)
gimp_transform_matrix_rotate (x, y, width, height, angle,
&matrix);
gimp_transform_matrix_rotate_rect (&matrix, x, y, width, height, angle);
else
gimp_transform_matrix_rotate_center (center_x, center_y, angle,
&matrix);
gimp_transform_matrix_rotate_center (&matrix,
center_x, center_y, angle);
if (interpolate)
interpolation_type = gimp->config->interpolation_type;
@ -1335,12 +1337,13 @@ drawable_transform_scale_invoker (Gimp *gimp,
GimpMatrix3 matrix;
/* Assemble the transformation matrix */
gimp_transform_matrix_scale (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_scale (&matrix,
x, y, width, height,
trans_info[X0],
trans_info[Y0],
trans_info[X1] - trans_info[X0],
trans_info[Y1] - trans_info[Y0],
&matrix);
trans_info[Y1] - trans_info[Y0]);
if (progress)
gimp_progress_start (progress, _("Scaling..."), FALSE);
@ -1489,12 +1492,13 @@ drawable_transform_scale_default_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_scale (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_scale (&matrix,
x, y, width, height,
trans_info[X0],
trans_info[Y0],
trans_info[X1] - trans_info[X0],
trans_info[Y1] - trans_info[Y0],
&matrix);
trans_info[Y1] - trans_info[Y0]);
if (interpolate)
interpolation_type = gimp->config->interpolation_type;
@ -1642,9 +1646,10 @@ drawable_transform_shear_invoker (Gimp *gimp,
GimpMatrix3 matrix;
/* Assemble the transformation matrix */
gimp_transform_matrix_shear (x, y, width, height,
shear_type, magnitude,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_shear (&matrix,
x, y, width, height,
shear_type, magnitude);
if (progress)
gimp_progress_start (progress, _("Shearing..."), FALSE);
@ -1780,9 +1785,10 @@ drawable_transform_shear_default_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_shear (x, y, width, height,
shear_type, magnitude,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_shear (&matrix,
x, y, width, height,
shear_type, magnitude);
if (interpolate)
interpolation_type = gimp->config->interpolation_type;

View file

@ -183,12 +183,13 @@ perspective_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_perspective (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_perspective (&matrix,
x, y, width, height,
trans_info[X0], trans_info[Y0],
trans_info[X1], trans_info[Y1],
trans_info[X2], trans_info[Y2],
trans_info[X3], trans_info[Y3],
&matrix);
trans_info[X3], trans_info[Y3]);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;
@ -329,8 +330,9 @@ rotate_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_rotate (x, y, width, height,
angle, &matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_rotate_rect (&matrix,
x, y, width, height, angle);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;
@ -444,12 +446,13 @@ scale_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_scale (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_scale (&matrix,
x, y, width, height,
trans_info[X0],
trans_info[Y0],
trans_info[X1] - trans_info[X0],
trans_info[Y1] - trans_info[Y0],
&matrix);
trans_info[Y1] - trans_info[Y0]);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;
@ -575,9 +578,10 @@ shear_invoker (Gimp *gimp,
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_shear (x, y, width, height,
shear_type, magnitude,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_shear (&matrix,
x, y, width, height,
shear_type, magnitude);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;

View file

@ -63,7 +63,7 @@ gimp_text_layer_transform_flip (GimpTextLayer *layer,
if (! gimp_text_layer_get_transformation (layer, &matrix))
return FALSE;
gimp_transform_matrix_flip (flip_type, axis, &matrix);
gimp_transform_matrix_flip (&matrix, flip_type, axis);
return gimp_text_layer_set_transformation (layer, &matrix);
}
@ -99,25 +99,11 @@ gimp_text_layer_transform_rotate (GimpTextLayer *layer,
gdouble center_y)
{
GimpMatrix3 matrix;
gdouble angle = 0.0;
if (! gimp_text_layer_get_transformation (layer, &matrix))
return FALSE;
switch (rotate_type)
{
case GIMP_ROTATE_90:
angle = G_PI_2;
break;
case GIMP_ROTATE_180:
angle = G_PI;
break;
case GIMP_ROTATE_270:
angle = - G_PI_2;
break;
}
gimp_transform_matrix_rotate_center (center_x, center_y, angle, &matrix);
gimp_transform_matrix_rotate (&matrix, rotate_type, center_x, center_y);
return gimp_text_layer_set_transformation (layer, &matrix);
}

View file

@ -237,7 +237,9 @@ static void
gimp_perspective_tool_recalc (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
gimp_transform_matrix_perspective (tr_tool->x1,
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,
@ -248,6 +250,5 @@ gimp_perspective_tool_recalc (GimpTransformTool *tr_tool,
tr_tool->trans_info[X2],
tr_tool->trans_info[Y2],
tr_tool->trans_info[X3],
tr_tool->trans_info[Y3],
&tr_tool->transform);
tr_tool->trans_info[Y3]);
}

View file

@ -339,10 +339,11 @@ gimp_rotate_tool_recalc (GimpTransformTool *tr_tool,
tr_tool->cx = tr_tool->trans_info[CENTER_X];
tr_tool->cy = tr_tool->trans_info[CENTER_Y];
gimp_transform_matrix_rotate_center (tr_tool->cx,
gimp_matrix3_identity (&tr_tool->transform);
gimp_transform_matrix_rotate_center (&tr_tool->transform,
tr_tool->cx,
tr_tool->cy,
tr_tool->trans_info[ANGLE],
&tr_tool->transform);
tr_tool->trans_info[ANGLE]);
}
static void

View file

@ -475,15 +475,16 @@ static void
gimp_scale_tool_recalc (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
gimp_transform_matrix_scale (tr_tool->x1,
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],
&tr_tool->transform);
tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
}
static void

View file

@ -292,13 +292,14 @@ gimp_shear_tool_recalc (GimpTransformTool *tr_tool,
else
amount = tr_tool->trans_info[YSHEAR];
gimp_transform_matrix_shear (tr_tool->x1,
gimp_matrix3_identity (&tr_tool->transform);
gimp_transform_matrix_shear (&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[HORZ_OR_VERT],
amount,
&tr_tool->transform);
amount);
}
static void

View file

@ -24,6 +24,7 @@
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "vectors-types.h"
@ -442,7 +443,8 @@ gimp_vectors_flip (GimpItem *item,
GList *list;
GimpMatrix3 matrix;
gimp_transform_matrix_flip (flip_type, axis, &matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_flip (&matrix, flip_type, axis);
gimp_vectors_freeze (vectors);
@ -471,22 +473,9 @@ gimp_vectors_rotate (GimpItem *item,
GimpVectors *vectors = GIMP_VECTORS (item);
GList *list;
GimpMatrix3 matrix;
gdouble angle = 0.0;
switch (rotate_type)
{
case GIMP_ROTATE_90:
angle = G_PI_2;
break;
case GIMP_ROTATE_180:
angle = G_PI;
break;
case GIMP_ROTATE_270:
angle = - G_PI_2;
break;
}
gimp_transform_matrix_rotate_center (center_x, center_y, angle, &matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_rotate (&matrix, rotate_type, center_x, center_y);
gimp_vectors_freeze (vectors);

View file

@ -245,9 +245,9 @@ HELP
@outargs = ( &drawable_out_arg('flipped') );
transform_invoke ("Flip...", <<CODE);
gimp_transform_matrix_flip_free (x, y, width, height,
x0, y0, x1, y1,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_flip_free (&matrix,
x, y, width, height, x0, y0, x1, y1);
CODE
}
@ -281,9 +281,9 @@ HELP
@outargs = ( &drawable_out_arg('flipped') );
transform_default_invoke ("Flip...", <<CODE);
gimp_transform_matrix_flip_free (x, y, width, height,
x0, y0, x1, y1,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_flip_free (&matrix,
x, y, width, height, x0, y0, x1, y1);
CODE
}
@ -335,12 +335,13 @@ HELP
@outargs = ( &drawable_out_arg('newly mapped') );
transform_invoke ("Perspective...", <<CODE, [ 'gdouble trans_info[8]' ]);
gimp_transform_matrix_perspective (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_perspective (&matrix,
x, y, width, height,
trans_info[X0], trans_info[Y0],
trans_info[X1], trans_info[Y1],
trans_info[X2], trans_info[Y2],
trans_info[X3], trans_info[Y3],
&matrix);
trans_info[X3], trans_info[Y3]);
CODE
}
@ -380,12 +381,13 @@ HELP
@outargs = ( &drawable_out_arg('newly mapped') );
transform_default_invoke ("Perspective...", <<CODE, [ 'gdouble trans_info[8]' ]);
gimp_transform_matrix_perspective (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_perspective (&matrix,
x, y, width, height,
trans_info[X0], trans_info[Y0],
trans_info[X1], trans_info[Y1],
trans_info[X2], trans_info[Y2],
trans_info[X3], trans_info[Y3],
&matrix);
trans_info[X3], trans_info[Y3]);
CODE
}
@ -476,12 +478,12 @@ HELP
@outargs = ( &drawable_out_arg('rotated') );
transform_invoke ("Rotating...", <<CODE);
gimp_matrix3_identity (&matrix);
if (auto_center)
gimp_transform_matrix_rotate (x, y, width, height, angle,
&matrix);
gimp_transform_matrix_rotate_rect (&matrix, x, y, width, height, angle);
else
gimp_transform_matrix_rotate_center (center_x, center_y, angle,
&matrix);
gimp_transform_matrix_rotate_center (&matrix,
center_x, center_y, angle);
CODE
}
@ -515,12 +517,12 @@ HELP
@outargs = ( &drawable_out_arg('rotated') );
transform_default_invoke ("Rotating...", <<CODE);
gimp_matrix3_identity (&matrix);
if (auto_center)
gimp_transform_matrix_rotate (x, y, width, height, angle,
&matrix);
gimp_transform_matrix_rotate_rect (&matrix, x, y, width, height, angle);
else
gimp_transform_matrix_rotate_center (center_x, center_y, angle,
&matrix);
gimp_transform_matrix_rotate_center (&matrix,
center_x, center_y, angle);
CODE
}
@ -563,12 +565,13 @@ HELP
@outargs = ( &drawable_out_arg('scaled') );
transform_invoke ("Scaling...", <<CODE, [ 'gdouble trans_info[4]' ], <<CODE2);
gimp_transform_matrix_scale (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_scale (&matrix,
x, y, width, height,
trans_info[X0],
trans_info[Y0],
trans_info[X1] - trans_info[X0],
trans_info[Y1] - trans_info[Y0],
&matrix);
trans_info[Y1] - trans_info[Y0]);
CODE
trans_info[X0] < trans_info[X1] &&
trans_info[Y0] < trans_info[Y1]);
@ -610,12 +613,13 @@ HELP
@outargs = ( &drawable_out_arg('scaled') );
transform_default_invoke ("Scaling...", <<CODE, [ 'gdouble trans_info[4]' ], <<CODE2);
gimp_transform_matrix_scale (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_scale (&matrix,
x, y, width, height,
trans_info[X0],
trans_info[Y0],
trans_info[X1] - trans_info[X0],
trans_info[Y1] - trans_info[Y0],
&matrix);
trans_info[Y1] - trans_info[Y0]);
CODE
trans_info[X0] < trans_info[X1] &&
trans_info[Y0] < trans_info[Y1]);
@ -655,9 +659,10 @@ HELP
@outargs = ( &drawable_out_arg('sheared') );
transform_invoke ("Shearing...", <<CODE);
gimp_transform_matrix_shear (x, y, width, height,
shear_type, magnitude,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_shear (&matrix,
x, y, width, height,
shear_type, magnitude);
CODE
}
@ -687,9 +692,10 @@ HELP
@outargs = ( &drawable_out_arg('sheared') );
transform_default_invoke ("Shearing...", <<CODE);
gimp_transform_matrix_shear (x, y, width, height,
shear_type, magnitude,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_shear (&matrix,
x, y, width, height,
shear_type, magnitude);
CODE
}

View file

@ -105,12 +105,13 @@ sub perspective {
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_perspective (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_perspective (&matrix,
x, y, width, height,
trans_info[X0], trans_info[Y0],
trans_info[X1], trans_info[Y1],
trans_info[X2], trans_info[Y2],
trans_info[X3], trans_info[Y3],
&matrix);
trans_info[X3], trans_info[Y3]);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;
@ -160,8 +161,9 @@ sub rotate {
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_rotate (x, y, width, height,
angle, &matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_rotate_rect (&matrix,
x, y, width, height, angle);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;
@ -224,12 +226,13 @@ sub scale {
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_scale (x, y, width, height,
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_scale (&matrix,
x, y, width, height,
trans_info[X0],
trans_info[Y0],
trans_info[X1] - trans_info[X0],
trans_info[Y1] - trans_info[Y0],
&matrix);
trans_info[Y1] - trans_info[Y0]);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;
@ -281,9 +284,10 @@ sub shear {
GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
/* Assemble the transformation matrix */
gimp_transform_matrix_shear (x, y, width, height,
shear_type, magnitude,
&matrix);
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_shear (&matrix,
x, y, width, height,
shear_type, magnitude);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;