mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
libgimpmath/gimpmathtypes.h moved struct declarations.
2003-07-07 Sven Neumann <sven@gimp.org> * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.h: moved struct declarations. * libgimpmath/gimpmatrix.[ch]: made GimpMatrix3 and GimpMatrix4 structs instead of typedefs for arrays. Pass them by reference, not by value. Added lots of const qualifiers. * app/core/gimpchannel.c * app/core/gimpdrawable-transform-utils.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpdrawable.c * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimplayer.c * app/pdb/transform_tools_cmds.c * app/tools/gimpperspectivetool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptransformtool.c * app/vectors/gimpvectors.c * tools/pdbgen/pdb/transform_tools.pdb: changed accordingly.
This commit is contained in:
parent
6b99ae0405
commit
5c4020edf2
31 changed files with 536 additions and 523 deletions
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
||||||
|
2003-07-07 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* libgimpmath/gimpmathtypes.h
|
||||||
|
* libgimpmath/gimpvector.h: moved struct declarations.
|
||||||
|
|
||||||
|
* libgimpmath/gimpmatrix.[ch]: made GimpMatrix3 and GimpMatrix4
|
||||||
|
structs instead of typedefs for arrays. Pass them by reference,
|
||||||
|
not by value. Added lots of const qualifiers.
|
||||||
|
|
||||||
|
* app/core/gimpchannel.c
|
||||||
|
* app/core/gimpdrawable-transform-utils.[ch]
|
||||||
|
* app/core/gimpdrawable-transform.[ch]
|
||||||
|
* app/core/gimpdrawable.c
|
||||||
|
* app/core/gimpitem-linked.[ch]
|
||||||
|
* app/core/gimpitem.[ch]
|
||||||
|
* app/core/gimplayer.c
|
||||||
|
* app/pdb/transform_tools_cmds.c
|
||||||
|
* app/tools/gimpperspectivetool.c
|
||||||
|
* app/tools/gimprotatetool.c
|
||||||
|
* app/tools/gimpscaletool.c
|
||||||
|
* app/tools/gimpsheartool.c
|
||||||
|
* app/tools/gimptransformtool.c
|
||||||
|
* app/vectors/gimpvectors.c
|
||||||
|
* tools/pdbgen/pdb/transform_tools.pdb: changed accordingly.
|
||||||
|
|
||||||
2003-07-07 Sven Neumann <sven@gimp.org>
|
2003-07-07 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/common/mng.c: applied a patch from S. Mukund that fixes
|
* plug-ins/common/mng.c: applied a patch from S. Mukund that fixes
|
||||||
|
|
|
@ -100,7 +100,7 @@ sample_linear(PixelSurround *surround,
|
||||||
TileManager *
|
TileManager *
|
||||||
gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
TileManager *orig_tiles,
|
TileManager *orig_tiles,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
@ -110,8 +110,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
PixelRegion destPR;
|
PixelRegion destPR;
|
||||||
TileManager *new_tiles;
|
TileManager *new_tiles;
|
||||||
GimpMatrix3 m;
|
GimpMatrix3 m = *matrix;
|
||||||
GimpMatrix3 im;
|
GimpMatrix3 inv = *matrix;
|
||||||
PixelSurround surround;
|
PixelSurround surround;
|
||||||
|
|
||||||
gint x1, y1, x2, y2; /* target bounding box */
|
gint x1, y1, x2, y2; /* target bounding box */
|
||||||
|
@ -191,14 +191,12 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
/* keep the original matrix here, so we dont need to recalculate
|
/* keep the original matrix here, so we dont need to recalculate
|
||||||
* the inverse later
|
* the inverse later
|
||||||
*/
|
*/
|
||||||
gimp_matrix3_duplicate (matrix, m);
|
gimp_matrix3_invert (&inv);
|
||||||
gimp_matrix3_invert (matrix, im);
|
|
||||||
matrix = im;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Find the inverse of the transformation matrix */
|
/* Find the inverse of the transformation matrix */
|
||||||
gimp_matrix3_invert (matrix, m);
|
gimp_matrix3_invert (&m);
|
||||||
}
|
}
|
||||||
|
|
||||||
tile_manager_get_offsets (orig_tiles, &u1, &v1);
|
tile_manager_get_offsets (orig_tiles, &u1, &v1);
|
||||||
|
@ -224,10 +222,10 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
gdouble dx3, dy3;
|
gdouble dx3, dy3;
|
||||||
gdouble dx4, dy4;
|
gdouble dx4, dy4;
|
||||||
|
|
||||||
gimp_matrix3_transform_point (matrix, u1, v1, &dx1, &dy1);
|
gimp_matrix3_transform_point (&inv, u1, v1, &dx1, &dy1);
|
||||||
gimp_matrix3_transform_point (matrix, u2, v1, &dx2, &dy2);
|
gimp_matrix3_transform_point (&inv, u2, v1, &dx2, &dy2);
|
||||||
gimp_matrix3_transform_point (matrix, u1, v2, &dx3, &dy3);
|
gimp_matrix3_transform_point (&inv, u1, v2, &dx3, &dy3);
|
||||||
gimp_matrix3_transform_point (matrix, u2, v2, &dx4, &dy4);
|
gimp_matrix3_transform_point (&inv, u2, v2, &dx4, &dy4);
|
||||||
|
|
||||||
x1 = ROUND (MIN4 (dx1, dx2, dx3, dx4));
|
x1 = ROUND (MIN4 (dx1, dx2, dx3, dx4));
|
||||||
y1 = ROUND (MIN4 (dy1, dy2, dy3, dy4));
|
y1 = ROUND (MIN4 (dy1, dy2, dy3, dy4));
|
||||||
|
@ -261,9 +259,9 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
|
|
||||||
dest = g_new (guchar, tile_manager_width (new_tiles) * bytes);
|
dest = g_new (guchar, tile_manager_width (new_tiles) * bytes);
|
||||||
|
|
||||||
uinc = m[0][0];
|
uinc = m.coeff[0][0];
|
||||||
vinc = m[1][0];
|
vinc = m.coeff[1][0];
|
||||||
winc = m[2][0];
|
winc = m.coeff[2][0];
|
||||||
|
|
||||||
coords = (interpolation_type != GIMP_INTERPOLATION_NONE) ? 5 : 1;
|
coords = (interpolation_type != GIMP_INTERPOLATION_NONE) ? 5 : 1;
|
||||||
|
|
||||||
|
@ -277,30 +275,30 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
(* progress_callback) (y1, y2, y, progress_data);
|
(* progress_callback) (y1, y2, y, progress_data);
|
||||||
|
|
||||||
/* set up inverse transform steps */
|
/* set up inverse transform steps */
|
||||||
tu[0] = uinc * (x1 + 0.5) + m[0][1] * (y + 0.5) + m[0][2] - 0.5;
|
tu[0] = uinc * (x1 + 0.5) + m.coeff[0][1] * (y + 0.5) + m.coeff[0][2] - 0.5;
|
||||||
tv[0] = vinc * (x1 + 0.5) + m[1][1] * (y + 0.5) + m[1][2] - 0.5;
|
tv[0] = vinc * (x1 + 0.5) + m.coeff[1][1] * (y + 0.5) + m.coeff[1][2] - 0.5;
|
||||||
tw[0] = winc * (x1 + 0.5) + m[2][1] * (y + 0.5) + m[2][2];
|
tw[0] = winc * (x1 + 0.5) + m.coeff[2][1] * (y + 0.5) + m.coeff[2][2];
|
||||||
|
|
||||||
if (interpolation_type != GIMP_INTERPOLATION_NONE)
|
if (interpolation_type != GIMP_INTERPOLATION_NONE)
|
||||||
{
|
{
|
||||||
gdouble xx = x1 + 0.5;
|
gdouble xx = x1 + 0.5;
|
||||||
gdouble yy = y + 0.5;
|
gdouble yy = y + 0.5;
|
||||||
|
|
||||||
tu[1] = uinc * (xx - 1) + m[0][1] * (yy ) + m[0][2] - 0.5;
|
tu[1] = uinc * (xx - 1) + m.coeff[0][1] * (yy ) + m.coeff[0][2] - 0.5;
|
||||||
tv[1] = vinc * (xx - 1) + m[1][1] * (yy ) + m[1][2] - 0.5;
|
tv[1] = vinc * (xx - 1) + m.coeff[1][1] * (yy ) + m.coeff[1][2] - 0.5;
|
||||||
tw[1] = winc * (xx - 1) + m[2][1] * (yy ) + m[2][2];
|
tw[1] = winc * (xx - 1) + m.coeff[2][1] * (yy ) + m.coeff[2][2];
|
||||||
|
|
||||||
tu[2] = uinc * (xx ) + m[0][1] * (yy - 1) + m[0][2] - 0.5;
|
tu[2] = uinc * (xx ) + m.coeff[0][1] * (yy - 1) + m.coeff[0][2] - 0.5;
|
||||||
tv[2] = vinc * (xx ) + m[1][1] * (yy - 1) + m[1][2] - 0.5;
|
tv[2] = vinc * (xx ) + m.coeff[1][1] * (yy - 1) + m.coeff[1][2] - 0.5;
|
||||||
tw[2] = winc * (xx ) + m[2][1] * (yy - 1) + m[2][2];
|
tw[2] = winc * (xx ) + m.coeff[2][1] * (yy - 1) + m.coeff[2][2];
|
||||||
|
|
||||||
tu[3] = uinc * (xx + 1) + m[0][1] * (yy ) + m[0][2] - 0.5;
|
tu[3] = uinc * (xx + 1) + m.coeff[0][1] * (yy ) + m.coeff[0][2] - 0.5;
|
||||||
tv[3] = vinc * (xx + 1) + m[1][1] * (yy ) + m[1][2] - 0.5;
|
tv[3] = vinc * (xx + 1) + m.coeff[1][1] * (yy ) + m.coeff[1][2] - 0.5;
|
||||||
tw[3] = winc * (xx + 1) + m[2][1] * (yy ) + m[2][2];
|
tw[3] = winc * (xx + 1) + m.coeff[2][1] * (yy ) + m.coeff[2][2];
|
||||||
|
|
||||||
tu[4] = uinc * (xx ) + m[0][1] * (yy + 1) + m[0][2] - 0.5;
|
tu[4] = uinc * (xx ) + m.coeff[0][1] * (yy + 1) + m.coeff[0][2] - 0.5;
|
||||||
tv[4] = vinc * (xx ) + m[1][1] * (yy + 1) + m[1][2] - 0.5;
|
tv[4] = vinc * (xx ) + m.coeff[1][1] * (yy + 1) + m.coeff[1][2] - 0.5;
|
||||||
tw[4] = winc * (xx ) + m[2][1] * (yy + 1) + m[2][2];
|
tw[4] = winc * (xx ) + m.coeff[2][1] * (yy + 1) + m.coeff[2][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
d = dest;
|
d = dest;
|
||||||
|
@ -805,7 +803,7 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gimp_drawable_transform_affine (GimpDrawable *drawable,
|
gimp_drawable_transform_affine (GimpDrawable *drawable,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result)
|
gboolean clip_result)
|
||||||
|
|
|
@ -28,12 +28,12 @@
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_drawable_transform_matrix_rotate (gint x1,
|
gimp_drawable_transform_matrix_rotate (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
gdouble cx;
|
gdouble cx;
|
||||||
gdouble cy;
|
gdouble cy;
|
||||||
|
@ -48,10 +48,10 @@ gimp_drawable_transform_matrix_rotate (gint x1,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
||||||
gdouble cy,
|
gdouble cy,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
gimp_matrix3_identity (result);
|
gimp_matrix3_identity (result);
|
||||||
gimp_matrix3_translate (result, -cx, -cy);
|
gimp_matrix3_translate (result, -cx, -cy);
|
||||||
|
@ -60,15 +60,15 @@ gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_drawable_transform_matrix_scale (gint x1,
|
gimp_drawable_transform_matrix_scale (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
gdouble tx1,
|
gdouble tx1,
|
||||||
gdouble ty1,
|
gdouble ty1,
|
||||||
gdouble tx2,
|
gdouble tx2,
|
||||||
gdouble ty2,
|
gdouble ty2,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
gdouble scalex;
|
gdouble scalex;
|
||||||
gdouble scaley;
|
gdouble scaley;
|
||||||
|
@ -94,7 +94,7 @@ gimp_drawable_transform_matrix_shear (gint x1,
|
||||||
gint y2,
|
gint y2,
|
||||||
GimpOrientationType orientation,
|
GimpOrientationType orientation,
|
||||||
gdouble amount,
|
gdouble amount,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
|
@ -124,19 +124,19 @@ gimp_drawable_transform_matrix_shear (gint x1,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_drawable_transform_matrix_perspective (gint x1,
|
gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
gdouble tx1,
|
gdouble tx1,
|
||||||
gdouble ty1,
|
gdouble ty1,
|
||||||
gdouble tx2,
|
gdouble tx2,
|
||||||
gdouble ty2,
|
gdouble ty2,
|
||||||
gdouble tx3,
|
gdouble tx3,
|
||||||
gdouble ty3,
|
gdouble ty3,
|
||||||
gdouble tx4,
|
gdouble tx4,
|
||||||
gdouble ty4,
|
gdouble ty4,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
GimpMatrix3 matrix;
|
GimpMatrix3 matrix;
|
||||||
gdouble scalex;
|
gdouble scalex;
|
||||||
|
@ -167,14 +167,14 @@ gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
/* Is the mapping affine? */
|
/* Is the mapping affine? */
|
||||||
if ((dx3 == 0.0) && (dy3 == 0.0))
|
if ((dx3 == 0.0) && (dy3 == 0.0))
|
||||||
{
|
{
|
||||||
matrix[0][0] = tx2 - tx1;
|
matrix.coeff[0][0] = tx2 - tx1;
|
||||||
matrix[0][1] = tx4 - tx2;
|
matrix.coeff[0][1] = tx4 - tx2;
|
||||||
matrix[0][2] = tx1;
|
matrix.coeff[0][2] = tx1;
|
||||||
matrix[1][0] = ty2 - ty1;
|
matrix.coeff[1][0] = ty2 - ty1;
|
||||||
matrix[1][1] = ty4 - ty2;
|
matrix.coeff[1][1] = ty4 - ty2;
|
||||||
matrix[1][2] = ty1;
|
matrix.coeff[1][2] = ty1;
|
||||||
matrix[2][0] = 0.0;
|
matrix.coeff[2][0] = 0.0;
|
||||||
matrix[2][1] = 0.0;
|
matrix.coeff[2][1] = 0.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -182,24 +182,24 @@ gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
|
|
||||||
det1 = dx3 * dy2 - dy3 * dx2;
|
det1 = dx3 * dy2 - dy3 * dx2;
|
||||||
det2 = dx1 * dy2 - dy1 * dx2;
|
det2 = dx1 * dy2 - dy1 * dx2;
|
||||||
matrix[2][0] = det1 / det2;
|
matrix.coeff[2][0] = det1 / det2;
|
||||||
det1 = dx1 * dy3 - dy1 * dx3;
|
det1 = dx1 * dy3 - dy1 * dx3;
|
||||||
matrix[2][1] = det1 / det2;
|
matrix.coeff[2][1] = det1 / det2;
|
||||||
|
|
||||||
matrix[0][0] = tx2 - tx1 + matrix[2][0] * tx2;
|
matrix.coeff[0][0] = tx2 - tx1 + matrix.coeff[2][0] * tx2;
|
||||||
matrix[0][1] = tx3 - tx1 + matrix[2][1] * tx3;
|
matrix.coeff[0][1] = tx3 - tx1 + matrix.coeff[2][1] * tx3;
|
||||||
matrix[0][2] = tx1;
|
matrix.coeff[0][2] = tx1;
|
||||||
|
|
||||||
matrix[1][0] = ty2 - ty1 + matrix[2][0] * ty2;
|
matrix.coeff[1][0] = ty2 - ty1 + matrix.coeff[2][0] * ty2;
|
||||||
matrix[1][1] = ty3 - ty1 + matrix[2][1] * ty3;
|
matrix.coeff[1][1] = ty3 - ty1 + matrix.coeff[2][1] * ty3;
|
||||||
matrix[1][2] = ty1;
|
matrix.coeff[1][2] = ty1;
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix[2][2] = 1.0;
|
matrix.coeff[2][2] = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_matrix3_identity (result);
|
gimp_matrix3_identity (result);
|
||||||
gimp_matrix3_translate (result, -x1, -y1);
|
gimp_matrix3_translate (result, -x1, -y1);
|
||||||
gimp_matrix3_scale (result, scalex, scaley);
|
gimp_matrix3_scale (result, scalex, scaley);
|
||||||
gimp_matrix3_mult (matrix, result);
|
gimp_matrix3_mult (&matrix, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ void gimp_drawable_transform_matrix_rotate (gint x1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
void gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
void gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
||||||
gdouble cy,
|
gdouble cy,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
void gimp_drawable_transform_matrix_scale (gint x1,
|
void gimp_drawable_transform_matrix_scale (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
|
@ -38,14 +38,14 @@ void gimp_drawable_transform_matrix_scale (gint x1,
|
||||||
gdouble ty1,
|
gdouble ty1,
|
||||||
gdouble tx2,
|
gdouble tx2,
|
||||||
gdouble ty2,
|
gdouble ty2,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
void gimp_drawable_transform_matrix_shear (gint x1,
|
void gimp_drawable_transform_matrix_shear (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
GimpOrientationType orientation,
|
GimpOrientationType orientation,
|
||||||
gdouble amount,
|
gdouble amount,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
void gimp_drawable_transform_matrix_perspective (gint x1,
|
void gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
|
@ -58,7 +58,7 @@ void gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
gdouble ty3,
|
gdouble ty3,
|
||||||
gdouble tx4,
|
gdouble tx4,
|
||||||
gdouble ty5,
|
gdouble ty5,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_DRAWABLE_TRANSFORM_SHEAR_H__ */
|
#endif /* __GIMP_DRAWABLE_TRANSFORM_SHEAR_H__ */
|
||||||
|
|
|
@ -83,13 +83,13 @@ static void gimp_channel_rotate (GimpItem *item,
|
||||||
gdouble center_x,
|
gdouble center_x,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean flip_result);
|
gboolean flip_result);
|
||||||
static void gimp_channel_transform (GimpItem *item,
|
static void gimp_channel_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
GimpProgressFunc progress_callback,
|
GimpProgressFunc progress_callback,
|
||||||
gpointer progress_data);
|
gpointer progress_data);
|
||||||
|
|
||||||
static void gimp_channel_push_undo (GimpChannel *mask,
|
static void gimp_channel_push_undo (GimpChannel *mask,
|
||||||
const gchar *undo_desc);
|
const gchar *undo_desc);
|
||||||
|
@ -468,7 +468,7 @@ gimp_channel_rotate (GimpItem *item,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_channel_transform (GimpItem *item,
|
gimp_channel_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
|
|
@ -83,13 +83,13 @@ static void gimp_channel_rotate (GimpItem *item,
|
||||||
gdouble center_x,
|
gdouble center_x,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean flip_result);
|
gboolean flip_result);
|
||||||
static void gimp_channel_transform (GimpItem *item,
|
static void gimp_channel_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
GimpProgressFunc progress_callback,
|
GimpProgressFunc progress_callback,
|
||||||
gpointer progress_data);
|
gpointer progress_data);
|
||||||
|
|
||||||
static void gimp_channel_push_undo (GimpChannel *mask,
|
static void gimp_channel_push_undo (GimpChannel *mask,
|
||||||
const gchar *undo_desc);
|
const gchar *undo_desc);
|
||||||
|
@ -468,7 +468,7 @@ gimp_channel_rotate (GimpItem *item,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_channel_transform (GimpItem *item,
|
gimp_channel_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
|
|
@ -28,12 +28,12 @@
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_drawable_transform_matrix_rotate (gint x1,
|
gimp_drawable_transform_matrix_rotate (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
gdouble cx;
|
gdouble cx;
|
||||||
gdouble cy;
|
gdouble cy;
|
||||||
|
@ -48,10 +48,10 @@ gimp_drawable_transform_matrix_rotate (gint x1,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
||||||
gdouble cy,
|
gdouble cy,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
gimp_matrix3_identity (result);
|
gimp_matrix3_identity (result);
|
||||||
gimp_matrix3_translate (result, -cx, -cy);
|
gimp_matrix3_translate (result, -cx, -cy);
|
||||||
|
@ -60,15 +60,15 @@ gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_drawable_transform_matrix_scale (gint x1,
|
gimp_drawable_transform_matrix_scale (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
gdouble tx1,
|
gdouble tx1,
|
||||||
gdouble ty1,
|
gdouble ty1,
|
||||||
gdouble tx2,
|
gdouble tx2,
|
||||||
gdouble ty2,
|
gdouble ty2,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
gdouble scalex;
|
gdouble scalex;
|
||||||
gdouble scaley;
|
gdouble scaley;
|
||||||
|
@ -94,7 +94,7 @@ gimp_drawable_transform_matrix_shear (gint x1,
|
||||||
gint y2,
|
gint y2,
|
||||||
GimpOrientationType orientation,
|
GimpOrientationType orientation,
|
||||||
gdouble amount,
|
gdouble amount,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
|
@ -124,19 +124,19 @@ gimp_drawable_transform_matrix_shear (gint x1,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_drawable_transform_matrix_perspective (gint x1,
|
gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
gdouble tx1,
|
gdouble tx1,
|
||||||
gdouble ty1,
|
gdouble ty1,
|
||||||
gdouble tx2,
|
gdouble tx2,
|
||||||
gdouble ty2,
|
gdouble ty2,
|
||||||
gdouble tx3,
|
gdouble tx3,
|
||||||
gdouble ty3,
|
gdouble ty3,
|
||||||
gdouble tx4,
|
gdouble tx4,
|
||||||
gdouble ty4,
|
gdouble ty4,
|
||||||
GimpMatrix3 result)
|
GimpMatrix3 *result)
|
||||||
{
|
{
|
||||||
GimpMatrix3 matrix;
|
GimpMatrix3 matrix;
|
||||||
gdouble scalex;
|
gdouble scalex;
|
||||||
|
@ -167,14 +167,14 @@ gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
/* Is the mapping affine? */
|
/* Is the mapping affine? */
|
||||||
if ((dx3 == 0.0) && (dy3 == 0.0))
|
if ((dx3 == 0.0) && (dy3 == 0.0))
|
||||||
{
|
{
|
||||||
matrix[0][0] = tx2 - tx1;
|
matrix.coeff[0][0] = tx2 - tx1;
|
||||||
matrix[0][1] = tx4 - tx2;
|
matrix.coeff[0][1] = tx4 - tx2;
|
||||||
matrix[0][2] = tx1;
|
matrix.coeff[0][2] = tx1;
|
||||||
matrix[1][0] = ty2 - ty1;
|
matrix.coeff[1][0] = ty2 - ty1;
|
||||||
matrix[1][1] = ty4 - ty2;
|
matrix.coeff[1][1] = ty4 - ty2;
|
||||||
matrix[1][2] = ty1;
|
matrix.coeff[1][2] = ty1;
|
||||||
matrix[2][0] = 0.0;
|
matrix.coeff[2][0] = 0.0;
|
||||||
matrix[2][1] = 0.0;
|
matrix.coeff[2][1] = 0.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -182,24 +182,24 @@ gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
|
|
||||||
det1 = dx3 * dy2 - dy3 * dx2;
|
det1 = dx3 * dy2 - dy3 * dx2;
|
||||||
det2 = dx1 * dy2 - dy1 * dx2;
|
det2 = dx1 * dy2 - dy1 * dx2;
|
||||||
matrix[2][0] = det1 / det2;
|
matrix.coeff[2][0] = det1 / det2;
|
||||||
det1 = dx1 * dy3 - dy1 * dx3;
|
det1 = dx1 * dy3 - dy1 * dx3;
|
||||||
matrix[2][1] = det1 / det2;
|
matrix.coeff[2][1] = det1 / det2;
|
||||||
|
|
||||||
matrix[0][0] = tx2 - tx1 + matrix[2][0] * tx2;
|
matrix.coeff[0][0] = tx2 - tx1 + matrix.coeff[2][0] * tx2;
|
||||||
matrix[0][1] = tx3 - tx1 + matrix[2][1] * tx3;
|
matrix.coeff[0][1] = tx3 - tx1 + matrix.coeff[2][1] * tx3;
|
||||||
matrix[0][2] = tx1;
|
matrix.coeff[0][2] = tx1;
|
||||||
|
|
||||||
matrix[1][0] = ty2 - ty1 + matrix[2][0] * ty2;
|
matrix.coeff[1][0] = ty2 - ty1 + matrix.coeff[2][0] * ty2;
|
||||||
matrix[1][1] = ty3 - ty1 + matrix[2][1] * ty3;
|
matrix.coeff[1][1] = ty3 - ty1 + matrix.coeff[2][1] * ty3;
|
||||||
matrix[1][2] = ty1;
|
matrix.coeff[1][2] = ty1;
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix[2][2] = 1.0;
|
matrix.coeff[2][2] = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_matrix3_identity (result);
|
gimp_matrix3_identity (result);
|
||||||
gimp_matrix3_translate (result, -x1, -y1);
|
gimp_matrix3_translate (result, -x1, -y1);
|
||||||
gimp_matrix3_scale (result, scalex, scaley);
|
gimp_matrix3_scale (result, scalex, scaley);
|
||||||
gimp_matrix3_mult (matrix, result);
|
gimp_matrix3_mult (&matrix, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ void gimp_drawable_transform_matrix_rotate (gint x1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
void gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
void gimp_drawable_transform_matrix_rotate_center (gdouble cx,
|
||||||
gdouble cy,
|
gdouble cy,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
void gimp_drawable_transform_matrix_scale (gint x1,
|
void gimp_drawable_transform_matrix_scale (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
|
@ -38,14 +38,14 @@ void gimp_drawable_transform_matrix_scale (gint x1,
|
||||||
gdouble ty1,
|
gdouble ty1,
|
||||||
gdouble tx2,
|
gdouble tx2,
|
||||||
gdouble ty2,
|
gdouble ty2,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
void gimp_drawable_transform_matrix_shear (gint x1,
|
void gimp_drawable_transform_matrix_shear (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
gint y2,
|
gint y2,
|
||||||
GimpOrientationType orientation,
|
GimpOrientationType orientation,
|
||||||
gdouble amount,
|
gdouble amount,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
void gimp_drawable_transform_matrix_perspective (gint x1,
|
void gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
gint y1,
|
gint y1,
|
||||||
gint x2,
|
gint x2,
|
||||||
|
@ -58,7 +58,7 @@ void gimp_drawable_transform_matrix_perspective (gint x1,
|
||||||
gdouble ty3,
|
gdouble ty3,
|
||||||
gdouble tx4,
|
gdouble tx4,
|
||||||
gdouble ty5,
|
gdouble ty5,
|
||||||
GimpMatrix3 result);
|
GimpMatrix3 *result);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_DRAWABLE_TRANSFORM_SHEAR_H__ */
|
#endif /* __GIMP_DRAWABLE_TRANSFORM_SHEAR_H__ */
|
||||||
|
|
|
@ -100,7 +100,7 @@ sample_linear(PixelSurround *surround,
|
||||||
TileManager *
|
TileManager *
|
||||||
gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
TileManager *orig_tiles,
|
TileManager *orig_tiles,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
@ -110,8 +110,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
GimpImage *gimage;
|
GimpImage *gimage;
|
||||||
PixelRegion destPR;
|
PixelRegion destPR;
|
||||||
TileManager *new_tiles;
|
TileManager *new_tiles;
|
||||||
GimpMatrix3 m;
|
GimpMatrix3 m = *matrix;
|
||||||
GimpMatrix3 im;
|
GimpMatrix3 inv = *matrix;
|
||||||
PixelSurround surround;
|
PixelSurround surround;
|
||||||
|
|
||||||
gint x1, y1, x2, y2; /* target bounding box */
|
gint x1, y1, x2, y2; /* target bounding box */
|
||||||
|
@ -191,14 +191,12 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
/* keep the original matrix here, so we dont need to recalculate
|
/* keep the original matrix here, so we dont need to recalculate
|
||||||
* the inverse later
|
* the inverse later
|
||||||
*/
|
*/
|
||||||
gimp_matrix3_duplicate (matrix, m);
|
gimp_matrix3_invert (&inv);
|
||||||
gimp_matrix3_invert (matrix, im);
|
|
||||||
matrix = im;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Find the inverse of the transformation matrix */
|
/* Find the inverse of the transformation matrix */
|
||||||
gimp_matrix3_invert (matrix, m);
|
gimp_matrix3_invert (&m);
|
||||||
}
|
}
|
||||||
|
|
||||||
tile_manager_get_offsets (orig_tiles, &u1, &v1);
|
tile_manager_get_offsets (orig_tiles, &u1, &v1);
|
||||||
|
@ -224,10 +222,10 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
gdouble dx3, dy3;
|
gdouble dx3, dy3;
|
||||||
gdouble dx4, dy4;
|
gdouble dx4, dy4;
|
||||||
|
|
||||||
gimp_matrix3_transform_point (matrix, u1, v1, &dx1, &dy1);
|
gimp_matrix3_transform_point (&inv, u1, v1, &dx1, &dy1);
|
||||||
gimp_matrix3_transform_point (matrix, u2, v1, &dx2, &dy2);
|
gimp_matrix3_transform_point (&inv, u2, v1, &dx2, &dy2);
|
||||||
gimp_matrix3_transform_point (matrix, u1, v2, &dx3, &dy3);
|
gimp_matrix3_transform_point (&inv, u1, v2, &dx3, &dy3);
|
||||||
gimp_matrix3_transform_point (matrix, u2, v2, &dx4, &dy4);
|
gimp_matrix3_transform_point (&inv, u2, v2, &dx4, &dy4);
|
||||||
|
|
||||||
x1 = ROUND (MIN4 (dx1, dx2, dx3, dx4));
|
x1 = ROUND (MIN4 (dx1, dx2, dx3, dx4));
|
||||||
y1 = ROUND (MIN4 (dy1, dy2, dy3, dy4));
|
y1 = ROUND (MIN4 (dy1, dy2, dy3, dy4));
|
||||||
|
@ -261,9 +259,9 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
|
|
||||||
dest = g_new (guchar, tile_manager_width (new_tiles) * bytes);
|
dest = g_new (guchar, tile_manager_width (new_tiles) * bytes);
|
||||||
|
|
||||||
uinc = m[0][0];
|
uinc = m.coeff[0][0];
|
||||||
vinc = m[1][0];
|
vinc = m.coeff[1][0];
|
||||||
winc = m[2][0];
|
winc = m.coeff[2][0];
|
||||||
|
|
||||||
coords = (interpolation_type != GIMP_INTERPOLATION_NONE) ? 5 : 1;
|
coords = (interpolation_type != GIMP_INTERPOLATION_NONE) ? 5 : 1;
|
||||||
|
|
||||||
|
@ -277,30 +275,30 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
(* progress_callback) (y1, y2, y, progress_data);
|
(* progress_callback) (y1, y2, y, progress_data);
|
||||||
|
|
||||||
/* set up inverse transform steps */
|
/* set up inverse transform steps */
|
||||||
tu[0] = uinc * (x1 + 0.5) + m[0][1] * (y + 0.5) + m[0][2] - 0.5;
|
tu[0] = uinc * (x1 + 0.5) + m.coeff[0][1] * (y + 0.5) + m.coeff[0][2] - 0.5;
|
||||||
tv[0] = vinc * (x1 + 0.5) + m[1][1] * (y + 0.5) + m[1][2] - 0.5;
|
tv[0] = vinc * (x1 + 0.5) + m.coeff[1][1] * (y + 0.5) + m.coeff[1][2] - 0.5;
|
||||||
tw[0] = winc * (x1 + 0.5) + m[2][1] * (y + 0.5) + m[2][2];
|
tw[0] = winc * (x1 + 0.5) + m.coeff[2][1] * (y + 0.5) + m.coeff[2][2];
|
||||||
|
|
||||||
if (interpolation_type != GIMP_INTERPOLATION_NONE)
|
if (interpolation_type != GIMP_INTERPOLATION_NONE)
|
||||||
{
|
{
|
||||||
gdouble xx = x1 + 0.5;
|
gdouble xx = x1 + 0.5;
|
||||||
gdouble yy = y + 0.5;
|
gdouble yy = y + 0.5;
|
||||||
|
|
||||||
tu[1] = uinc * (xx - 1) + m[0][1] * (yy ) + m[0][2] - 0.5;
|
tu[1] = uinc * (xx - 1) + m.coeff[0][1] * (yy ) + m.coeff[0][2] - 0.5;
|
||||||
tv[1] = vinc * (xx - 1) + m[1][1] * (yy ) + m[1][2] - 0.5;
|
tv[1] = vinc * (xx - 1) + m.coeff[1][1] * (yy ) + m.coeff[1][2] - 0.5;
|
||||||
tw[1] = winc * (xx - 1) + m[2][1] * (yy ) + m[2][2];
|
tw[1] = winc * (xx - 1) + m.coeff[2][1] * (yy ) + m.coeff[2][2];
|
||||||
|
|
||||||
tu[2] = uinc * (xx ) + m[0][1] * (yy - 1) + m[0][2] - 0.5;
|
tu[2] = uinc * (xx ) + m.coeff[0][1] * (yy - 1) + m.coeff[0][2] - 0.5;
|
||||||
tv[2] = vinc * (xx ) + m[1][1] * (yy - 1) + m[1][2] - 0.5;
|
tv[2] = vinc * (xx ) + m.coeff[1][1] * (yy - 1) + m.coeff[1][2] - 0.5;
|
||||||
tw[2] = winc * (xx ) + m[2][1] * (yy - 1) + m[2][2];
|
tw[2] = winc * (xx ) + m.coeff[2][1] * (yy - 1) + m.coeff[2][2];
|
||||||
|
|
||||||
tu[3] = uinc * (xx + 1) + m[0][1] * (yy ) + m[0][2] - 0.5;
|
tu[3] = uinc * (xx + 1) + m.coeff[0][1] * (yy ) + m.coeff[0][2] - 0.5;
|
||||||
tv[3] = vinc * (xx + 1) + m[1][1] * (yy ) + m[1][2] - 0.5;
|
tv[3] = vinc * (xx + 1) + m.coeff[1][1] * (yy ) + m.coeff[1][2] - 0.5;
|
||||||
tw[3] = winc * (xx + 1) + m[2][1] * (yy ) + m[2][2];
|
tw[3] = winc * (xx + 1) + m.coeff[2][1] * (yy ) + m.coeff[2][2];
|
||||||
|
|
||||||
tu[4] = uinc * (xx ) + m[0][1] * (yy + 1) + m[0][2] - 0.5;
|
tu[4] = uinc * (xx ) + m.coeff[0][1] * (yy + 1) + m.coeff[0][2] - 0.5;
|
||||||
tv[4] = vinc * (xx ) + m[1][1] * (yy + 1) + m[1][2] - 0.5;
|
tv[4] = vinc * (xx ) + m.coeff[1][1] * (yy + 1) + m.coeff[1][2] - 0.5;
|
||||||
tw[4] = winc * (xx ) + m[2][1] * (yy + 1) + m[2][2];
|
tw[4] = winc * (xx ) + m.coeff[2][1] * (yy + 1) + m.coeff[2][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
d = dest;
|
d = dest;
|
||||||
|
@ -805,7 +803,7 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gimp_drawable_transform_affine (GimpDrawable *drawable,
|
gimp_drawable_transform_affine (GimpDrawable *drawable,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result)
|
gboolean clip_result)
|
||||||
|
|
|
@ -33,42 +33,42 @@ typedef enum
|
||||||
} GimpTransformBoundingBox;
|
} GimpTransformBoundingBox;
|
||||||
|
|
||||||
|
|
||||||
TileManager * gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
TileManager * gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||||
TileManager *orig_tiles,
|
TileManager *orig_tiles,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
GimpProgressFunc progress_callback,
|
GimpProgressFunc progress_callback,
|
||||||
gpointer progress_data);
|
gpointer progress_data);
|
||||||
TileManager * gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
|
TileManager * gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
|
||||||
TileManager *orig_tiles,
|
TileManager *orig_tiles,
|
||||||
GimpOrientationType flip_type,
|
GimpOrientationType flip_type,
|
||||||
gdouble axis,
|
gdouble axis,
|
||||||
gboolean clip_result);
|
gboolean clip_result);
|
||||||
|
|
||||||
TileManager * gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
|
TileManager * gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
|
||||||
TileManager *orig_tiles,
|
TileManager *orig_tiles,
|
||||||
GimpRotationType rotate_type,
|
GimpRotationType rotate_type,
|
||||||
gdouble center_x,
|
gdouble center_x,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean clip_result);
|
gboolean clip_result);
|
||||||
gboolean gimp_drawable_transform_affine (GimpDrawable *drawable,
|
gboolean gimp_drawable_transform_affine (GimpDrawable *drawable,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result);
|
gboolean clip_result);
|
||||||
gboolean gimp_drawable_transform_flip (GimpDrawable *drawable,
|
gboolean gimp_drawable_transform_flip (GimpDrawable *drawable,
|
||||||
GimpOrientationType flip_type);
|
GimpOrientationType flip_type);
|
||||||
|
|
||||||
|
|
||||||
gboolean gimp_drawable_transform_rotate (GimpDrawable *drawable,
|
gboolean gimp_drawable_transform_rotate (GimpDrawable *drawable,
|
||||||
GimpRotationType rotate_type);
|
GimpRotationType rotate_type);
|
||||||
TileManager * gimp_drawable_transform_cut (GimpDrawable *drawable,
|
TileManager * gimp_drawable_transform_cut (GimpDrawable *drawable,
|
||||||
gboolean *new_layer);
|
gboolean *new_layer);
|
||||||
gboolean gimp_drawable_transform_paste (GimpDrawable *drawable,
|
gboolean gimp_drawable_transform_paste (GimpDrawable *drawable,
|
||||||
TileManager *tiles,
|
TileManager *tiles,
|
||||||
gboolean new_layer);
|
gboolean new_layer);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_DRAWABLE_TRANSFORM_H__ */
|
#endif /* __GIMP_DRAWABLE_TRANSFORM_H__ */
|
||||||
|
|
|
@ -98,7 +98,7 @@ static void gimp_drawable_rotate (GimpItem *item,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean clip_result);
|
gboolean clip_result);
|
||||||
static void gimp_drawable_transform (GimpItem *item,
|
static void gimp_drawable_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
@ -524,7 +524,7 @@ gimp_drawable_rotate (GimpItem *item,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_drawable_transform (GimpItem *item,
|
gimp_drawable_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
|
|
@ -141,7 +141,7 @@ gimp_item_linked_rotate (GimpItem *item,
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_item_linked_transform (GimpItem *item,
|
gimp_item_linked_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
|
|
@ -34,7 +34,7 @@ void gimp_item_linked_rotate (GimpItem *item,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean clip_result);
|
gboolean clip_result);
|
||||||
void gimp_item_linked_transform (GimpItem *item,
|
void gimp_item_linked_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
|
|
@ -687,7 +687,7 @@ gimp_item_rotate (GimpItem *item,
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_item_transform (GimpItem *item,
|
gimp_item_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
|
|
@ -90,7 +90,7 @@ struct _GimpItemClass
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean clip_result);
|
gboolean clip_result);
|
||||||
void (* transform) (GimpItem *item,
|
void (* transform) (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
@ -165,13 +165,13 @@ void gimp_item_rotate (GimpItem *item,
|
||||||
gdouble center_x,
|
gdouble center_x,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean flip_result);
|
gboolean flip_result);
|
||||||
void gimp_item_transform (GimpItem *item,
|
void gimp_item_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
GimpProgressFunc progress_callback,
|
GimpProgressFunc progress_callback,
|
||||||
gpointer progress_data);
|
gpointer progress_data);
|
||||||
|
|
||||||
gint gimp_item_get_ID (GimpItem *item);
|
gint gimp_item_get_ID (GimpItem *item);
|
||||||
GimpItem * gimp_item_get_by_ID (Gimp *gimp,
|
GimpItem * gimp_item_get_by_ID (Gimp *gimp,
|
||||||
|
|
|
@ -101,7 +101,7 @@ static void gimp_layer_rotate (GimpItem *item,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean clip_result);
|
gboolean clip_result);
|
||||||
static void gimp_layer_transform (GimpItem *item,
|
static void gimp_layer_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
@ -540,7 +540,7 @@ gimp_layer_rotate (GimpItem *item,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_layer_transform (GimpItem *item,
|
gimp_layer_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
|
|
@ -172,7 +172,7 @@ perspective_invoker (Gimp *gimp,
|
||||||
trans_info[Y2],
|
trans_info[Y2],
|
||||||
trans_info[X3],
|
trans_info[X3],
|
||||||
trans_info[Y3],
|
trans_info[Y3],
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -181,7 +181,7 @@ perspective_invoker (Gimp *gimp,
|
||||||
|
|
||||||
/* Perspective the selection */
|
/* Perspective the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ rotate_invoker (Gimp *gimp,
|
||||||
/* Assemble the transformation matrix */
|
/* Assemble the transformation matrix */
|
||||||
gimp_drawable_transform_matrix_rotate (x1, y1, x2, y2,
|
gimp_drawable_transform_matrix_rotate (x1, y1, x2, y2,
|
||||||
angle,
|
angle,
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -310,7 +310,7 @@ rotate_invoker (Gimp *gimp,
|
||||||
|
|
||||||
/* Rotate the selection */
|
/* Rotate the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ scale_invoker (Gimp *gimp,
|
||||||
trans_info[Y0],
|
trans_info[Y0],
|
||||||
trans_info[X1],
|
trans_info[X1],
|
||||||
trans_info[Y1],
|
trans_info[Y1],
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -415,7 +415,7 @@ scale_invoker (Gimp *gimp,
|
||||||
|
|
||||||
/* Scale the selection */
|
/* Scale the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -525,7 +525,7 @@ shear_invoker (Gimp *gimp,
|
||||||
gimp_drawable_transform_matrix_shear (x1, y1, x2, y2,
|
gimp_drawable_transform_matrix_shear (x1, y1, x2, y2,
|
||||||
shear_type,
|
shear_type,
|
||||||
magnitude,
|
magnitude,
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -534,7 +534,7 @@ shear_invoker (Gimp *gimp,
|
||||||
|
|
||||||
/* Shear the selection */
|
/* Shear the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,11 +636,11 @@ transform_2d_invoker (Gimp *gimp,
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
/* Assemble the transformation matrix */
|
/* Assemble the transformation matrix */
|
||||||
gimp_matrix3_identity (matrix);
|
gimp_matrix3_identity (&matrix);
|
||||||
gimp_matrix3_translate (matrix, -source_x, -source_y);
|
gimp_matrix3_translate (&matrix, -source_x, -source_y);
|
||||||
gimp_matrix3_scale (matrix, scale_x, scale_y);
|
gimp_matrix3_scale (&matrix, scale_x, scale_y);
|
||||||
gimp_matrix3_rotate (matrix, angle);
|
gimp_matrix3_rotate (&matrix, angle);
|
||||||
gimp_matrix3_translate (matrix, dest_x, dest_y);
|
gimp_matrix3_translate (&matrix, dest_x, dest_y);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -649,7 +649,7 @@ transform_2d_invoker (Gimp *gimp,
|
||||||
|
|
||||||
/* Transform the selection */
|
/* Transform the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ gimp_perspective_tool_recalc (GimpTransformTool *tr_tool,
|
||||||
tr_tool->trans_info[Y2],
|
tr_tool->trans_info[Y2],
|
||||||
tr_tool->trans_info[X3],
|
tr_tool->trans_info[X3],
|
||||||
tr_tool->trans_info[Y3],
|
tr_tool->trans_info[Y3],
|
||||||
tr_tool->transform);
|
&tr_tool->transform);
|
||||||
|
|
||||||
/* transform the bounding box */
|
/* transform the bounding box */
|
||||||
gimp_transform_tool_transform_bounding_box (tr_tool);
|
gimp_transform_tool_transform_bounding_box (tr_tool);
|
||||||
|
@ -252,7 +252,7 @@ perspective_info_update (GimpTransformTool *tr_tool)
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
p += g_snprintf (p, MAX_INFO_BUF - (p - matrix_row_buf[i]),
|
p += g_snprintf (p, MAX_INFO_BUF - (p - matrix_row_buf[i]),
|
||||||
"%10.3g", tr_tool->transform[i][j]);
|
"%10.3g", tr_tool->transform.coeff[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -344,7 +344,7 @@ gimp_rotate_tool_recalc (GimpTransformTool *tr_tool,
|
||||||
gimp_drawable_transform_matrix_rotate_center (tr_tool->cx,
|
gimp_drawable_transform_matrix_rotate_center (tr_tool->cx,
|
||||||
tr_tool->cy,
|
tr_tool->cy,
|
||||||
tr_tool->trans_info[ANGLE],
|
tr_tool->trans_info[ANGLE],
|
||||||
tr_tool->transform);
|
&tr_tool->transform);
|
||||||
|
|
||||||
/* transform the bounding box */
|
/* transform the bounding box */
|
||||||
gimp_transform_tool_transform_bounding_box (tr_tool);
|
gimp_transform_tool_transform_bounding_box (tr_tool);
|
||||||
|
|
|
@ -398,7 +398,7 @@ gimp_scale_tool_recalc (GimpTransformTool *tr_tool,
|
||||||
tr_tool->trans_info[Y0],
|
tr_tool->trans_info[Y0],
|
||||||
tr_tool->trans_info[X1],
|
tr_tool->trans_info[X1],
|
||||||
tr_tool->trans_info[Y1],
|
tr_tool->trans_info[Y1],
|
||||||
tr_tool->transform);
|
&tr_tool->transform);
|
||||||
|
|
||||||
/* transform the bounding box */
|
/* transform the bounding box */
|
||||||
gimp_transform_tool_transform_bounding_box (tr_tool);
|
gimp_transform_tool_transform_bounding_box (tr_tool);
|
||||||
|
|
|
@ -286,7 +286,7 @@ gimp_shear_tool_recalc (GimpTransformTool *tr_tool,
|
||||||
tr_tool->y2,
|
tr_tool->y2,
|
||||||
tr_tool->trans_info[HORZ_OR_VERT],
|
tr_tool->trans_info[HORZ_OR_VERT],
|
||||||
amount,
|
amount,
|
||||||
tr_tool->transform);
|
&tr_tool->transform);
|
||||||
|
|
||||||
/* transform the bounding box */
|
/* transform the bounding box */
|
||||||
gimp_transform_tool_transform_bounding_box (tr_tool);
|
gimp_transform_tool_transform_bounding_box (tr_tool);
|
||||||
|
|
|
@ -224,7 +224,7 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
|
||||||
tr_tool->old_trans_info[i] = 0.0;
|
tr_tool->old_trans_info[i] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_matrix3_identity (tr_tool->transform);
|
gimp_matrix3_identity (&tr_tool->transform);
|
||||||
|
|
||||||
tr_tool->use_grid = TRUE;
|
tr_tool->use_grid = TRUE;
|
||||||
tr_tool->use_center = TRUE;
|
tr_tool->use_center = TRUE;
|
||||||
|
@ -728,24 +728,24 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
|
||||||
FALSE);
|
FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (tr_tool->type == GIMP_TRANSFORM_TYPE_PATH)
|
if (tr_tool->type == GIMP_TRANSFORM_TYPE_PATH)
|
||||||
{
|
{
|
||||||
GimpMatrix3 tmp_matrix;
|
|
||||||
|
|
||||||
if (options->direction == GIMP_TRANSFORM_BACKWARD)
|
if (options->direction == GIMP_TRANSFORM_BACKWARD)
|
||||||
{
|
{
|
||||||
gimp_matrix3_invert (tr_tool->transform, tmp_matrix);
|
GimpMatrix3 inv_matrix = tr_tool->transform;
|
||||||
|
|
||||||
|
gimp_matrix3_invert (&inv_matrix);
|
||||||
|
path_transform_draw_current (tool->gdisp,
|
||||||
|
draw_tool, inv_matrix);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_matrix3_duplicate (tr_tool->transform, tmp_matrix);
|
path_transform_draw_current (tool->gdisp,
|
||||||
}
|
draw_tool, tr_tool->transform);
|
||||||
|
}
|
||||||
#if 0
|
|
||||||
path_transform_draw_current (tool->gdisp,
|
|
||||||
draw_tool, tmp_matrix);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static TileManager *
|
static TileManager *
|
||||||
|
@ -768,7 +768,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
if (gimp_item_get_linked (active_item))
|
if (gimp_item_get_linked (active_item))
|
||||||
gimp_item_linked_transform (active_item, tr_tool->transform,
|
gimp_item_linked_transform (active_item, &tr_tool->transform,
|
||||||
options->direction,
|
options->direction,
|
||||||
options->interpolation, options->clip,
|
options->interpolation, options->clip,
|
||||||
progress ?
|
progress ?
|
||||||
|
@ -792,7 +792,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
|
||||||
ret =
|
ret =
|
||||||
gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (active_item),
|
gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (active_item),
|
||||||
tr_tool->original,
|
tr_tool->original,
|
||||||
tr_tool->transform,
|
&tr_tool->transform,
|
||||||
options->direction,
|
options->direction,
|
||||||
options->interpolation,
|
options->interpolation,
|
||||||
clip_result,
|
clip_result,
|
||||||
|
@ -952,20 +952,20 @@ gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_TRANSFORM_TOOL (tr_tool));
|
g_return_if_fail (GIMP_IS_TRANSFORM_TOOL (tr_tool));
|
||||||
|
|
||||||
gimp_matrix3_transform_point (tr_tool->transform,
|
gimp_matrix3_transform_point (&tr_tool->transform,
|
||||||
tr_tool->x1, tr_tool->y1,
|
tr_tool->x1, tr_tool->y1,
|
||||||
&tr_tool->tx1, &tr_tool->ty1);
|
&tr_tool->tx1, &tr_tool->ty1);
|
||||||
gimp_matrix3_transform_point (tr_tool->transform,
|
gimp_matrix3_transform_point (&tr_tool->transform,
|
||||||
tr_tool->x2, tr_tool->y1,
|
tr_tool->x2, tr_tool->y1,
|
||||||
&tr_tool->tx2, &tr_tool->ty2);
|
&tr_tool->tx2, &tr_tool->ty2);
|
||||||
gimp_matrix3_transform_point (tr_tool->transform,
|
gimp_matrix3_transform_point (&tr_tool->transform,
|
||||||
tr_tool->x1, tr_tool->y2,
|
tr_tool->x1, tr_tool->y2,
|
||||||
&tr_tool->tx3, &tr_tool->ty3);
|
&tr_tool->tx3, &tr_tool->ty3);
|
||||||
gimp_matrix3_transform_point (tr_tool->transform,
|
gimp_matrix3_transform_point (&tr_tool->transform,
|
||||||
tr_tool->x2, tr_tool->y2,
|
tr_tool->x2, tr_tool->y2,
|
||||||
&tr_tool->tx4, &tr_tool->ty4);
|
&tr_tool->tx4, &tr_tool->ty4);
|
||||||
|
|
||||||
gimp_matrix3_transform_point (tr_tool->transform,
|
gimp_matrix3_transform_point (&tr_tool->transform,
|
||||||
tr_tool->cx, tr_tool->cy,
|
tr_tool->cx, tr_tool->cy,
|
||||||
&tr_tool->tcx, &tr_tool->tcy);
|
&tr_tool->tcx, &tr_tool->tcy);
|
||||||
|
|
||||||
|
@ -979,7 +979,7 @@ gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool)
|
||||||
|
|
||||||
for (i = 0; i < k; i++)
|
for (i = 0; i < k; i++)
|
||||||
{
|
{
|
||||||
gimp_matrix3_transform_point (tr_tool->transform,
|
gimp_matrix3_transform_point (&tr_tool->transform,
|
||||||
tr_tool->grid_coords[gci],
|
tr_tool->grid_coords[gci],
|
||||||
tr_tool->grid_coords[gci + 1],
|
tr_tool->grid_coords[gci + 1],
|
||||||
&tr_tool->tgrid_coords[gci],
|
&tr_tool->tgrid_coords[gci],
|
||||||
|
|
|
@ -80,38 +80,38 @@ static void gimp_vectors_rotate (GimpItem *item,
|
||||||
gdouble center_x,
|
gdouble center_x,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gboolean clip_result);
|
gboolean clip_result);
|
||||||
static void gimp_vectors_transform (GimpItem *item,
|
static void gimp_vectors_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interp_type,
|
GimpInterpolationType interp_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
GimpProgressFunc progress_callback,
|
GimpProgressFunc progress_callback,
|
||||||
gpointer progress_data);
|
gpointer progress_data);
|
||||||
|
|
||||||
static void gimp_vectors_real_thaw (GimpVectors *vectors);
|
static void gimp_vectors_real_thaw (GimpVectors *vectors);
|
||||||
static void gimp_vectors_real_stroke_add (GimpVectors *vectors,
|
static void gimp_vectors_real_stroke_add (GimpVectors *vectors,
|
||||||
GimpStroke *stroke);
|
GimpStroke *stroke);
|
||||||
static GimpStroke * gimp_vectors_real_stroke_get (const GimpVectors *vectors,
|
static GimpStroke * gimp_vectors_real_stroke_get (const GimpVectors *vectors,
|
||||||
const GimpCoords *coord);
|
const GimpCoords *coord);
|
||||||
static GimpStroke *gimp_vectors_real_stroke_get_next(const GimpVectors *vectors,
|
static GimpStroke *gimp_vectors_real_stroke_get_next(const GimpVectors *vectors,
|
||||||
const GimpStroke *prev);
|
const GimpStroke *prev);
|
||||||
static gdouble gimp_vectors_real_stroke_get_length (const GimpVectors *vectors,
|
static gdouble gimp_vectors_real_stroke_get_length (const GimpVectors *vectors,
|
||||||
const GimpStroke *prev);
|
const GimpStroke *prev);
|
||||||
static GimpAnchor * gimp_vectors_real_anchor_get (const GimpVectors *vectors,
|
static GimpAnchor * gimp_vectors_real_anchor_get (const GimpVectors *vectors,
|
||||||
const GimpCoords *coord,
|
const GimpCoords *coord,
|
||||||
GimpStroke **ret_stroke);
|
GimpStroke **ret_stroke);
|
||||||
static void gimp_vectors_real_anchor_delete (GimpVectors *vectors,
|
static void gimp_vectors_real_anchor_delete (GimpVectors *vectors,
|
||||||
GimpAnchor *anchor);
|
GimpAnchor *anchor);
|
||||||
static gdouble gimp_vectors_real_get_length (const GimpVectors *vectors,
|
static gdouble gimp_vectors_real_get_length (const GimpVectors *vectors,
|
||||||
const GimpAnchor *start);
|
const GimpAnchor *start);
|
||||||
static gdouble gimp_vectors_real_get_distance (const GimpVectors *vectors,
|
static gdouble gimp_vectors_real_get_distance (const GimpVectors *vectors,
|
||||||
const GimpCoords *coord);
|
const GimpCoords *coord);
|
||||||
static gint gimp_vectors_real_interpolate (const GimpVectors *vectors,
|
static gint gimp_vectors_real_interpolate (const GimpVectors *vectors,
|
||||||
const GimpStroke *stroke,
|
const GimpStroke *stroke,
|
||||||
gdouble precision,
|
gdouble precision,
|
||||||
gint max_points,
|
gint max_points,
|
||||||
GimpCoords *ret_coords);
|
GimpCoords *ret_coords);
|
||||||
static GimpVectors * gimp_vectors_real_make_bezier (const GimpVectors *vectors);
|
static GimpVectors * gimp_vectors_real_make_bezier (const GimpVectors *vectors);
|
||||||
|
|
||||||
|
|
||||||
/* private variables */
|
/* private variables */
|
||||||
|
@ -463,7 +463,7 @@ gimp_vectors_rotate (GimpItem *item,
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_drawable_transform_matrix_rotate_center (center_x, center_y, angle,
|
gimp_drawable_transform_matrix_rotate_center (center_x, center_y, angle,
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
vectors = GIMP_VECTORS (item);
|
vectors = GIMP_VECTORS (item);
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ gimp_vectors_rotate (GimpItem *item,
|
||||||
{
|
{
|
||||||
GimpAnchor *anchor = list2->data;
|
GimpAnchor *anchor = list2->data;
|
||||||
|
|
||||||
gimp_matrix3_transform_point (matrix,
|
gimp_matrix3_transform_point (&matrix,
|
||||||
anchor->position.x,
|
anchor->position.x,
|
||||||
anchor->position.y,
|
anchor->position.y,
|
||||||
&anchor->position.x,
|
&anchor->position.x,
|
||||||
|
@ -495,7 +495,7 @@ gimp_vectors_rotate (GimpItem *item,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_vectors_transform (GimpItem *item,
|
gimp_vectors_transform (GimpItem *item,
|
||||||
GimpMatrix3 matrix,
|
const GimpMatrix3 *matrix,
|
||||||
GimpTransformDirection direction,
|
GimpTransformDirection direction,
|
||||||
GimpInterpolationType interpolation_type,
|
GimpInterpolationType interpolation_type,
|
||||||
gboolean clip_result,
|
gboolean clip_result,
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-07-07 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* libgimpmath/libgimpmath-sections.txt
|
||||||
|
* libgimpmath/tmpl/gimpmatrix.sgml: updated.
|
||||||
|
|
||||||
2003-07-02 Michael Natterer <mitch@gimp.org>
|
2003-07-02 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* libgimpbase/tmpl/gimpbasetypes.sgml
|
* libgimpbase/tmpl/gimpbasetypes.sgml
|
||||||
|
|
|
@ -19,8 +19,8 @@ gimp_md5_get_digest
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gimpmatrix</FILE>
|
<FILE>gimpmatrix</FILE>
|
||||||
<TITLE>GimpMatrix</TITLE>
|
<TITLE>GimpMatrix</TITLE>
|
||||||
GimpMatrix3[3][3]
|
GimpMatrix3
|
||||||
GimpMatrix4[4][4]
|
GimpMatrix4
|
||||||
gimp_matrix3_transform_point
|
gimp_matrix3_transform_point
|
||||||
gimp_matrix3_mult
|
gimp_matrix3_mult
|
||||||
gimp_matrix3_identity
|
gimp_matrix3_identity
|
||||||
|
@ -31,7 +31,6 @@ gimp_matrix3_xshear
|
||||||
gimp_matrix3_yshear
|
gimp_matrix3_yshear
|
||||||
gimp_matrix3_determinant
|
gimp_matrix3_determinant
|
||||||
gimp_matrix3_invert
|
gimp_matrix3_invert
|
||||||
gimp_matrix3_duplicate
|
|
||||||
gimp_matrix3_is_diagonal
|
gimp_matrix3_is_diagonal
|
||||||
gimp_matrix3_is_identity
|
gimp_matrix3_is_identity
|
||||||
gimp_matrix3_is_simple
|
gimp_matrix3_is_simple
|
||||||
|
|
|
@ -24,17 +24,19 @@ basic matrix manipulations and tests.
|
||||||
#GimpVector4
|
#GimpVector4
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<!-- ##### TYPEDEF GimpMatrix3[3][3] ##### -->
|
<!-- ##### STRUCT GimpMatrix3 ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
@coeff:
|
||||||
|
|
||||||
<!-- ##### TYPEDEF GimpMatrix4[4][4] ##### -->
|
<!-- ##### STRUCT GimpMatrix4 ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
@coeff:
|
||||||
|
|
||||||
<!-- ##### FUNCTION gimp_matrix3_transform_point ##### -->
|
<!-- ##### FUNCTION gimp_matrix3_transform_point ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
@ -127,16 +129,6 @@ basic matrix manipulations and tests.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@matrix:
|
@matrix:
|
||||||
@matrix_inv:
|
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION gimp_matrix3_duplicate ##### -->
|
|
||||||
<para>
|
|
||||||
|
|
||||||
</para>
|
|
||||||
|
|
||||||
@src:
|
|
||||||
@target:
|
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION gimp_matrix3_is_diagonal ##### -->
|
<!-- ##### FUNCTION gimp_matrix3_is_diagonal ##### -->
|
||||||
|
|
|
@ -24,30 +24,13 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct _GimpMatrix3 GimpMatrix3;
|
||||||
typedef gdouble GimpMatrix3[3][3];
|
typedef struct _GimpMatrix4 GimpMatrix4;
|
||||||
typedef gdouble GimpMatrix4[4][4];
|
|
||||||
|
|
||||||
typedef struct _GimpVector2 GimpVector2;
|
typedef struct _GimpVector2 GimpVector2;
|
||||||
typedef struct _GimpVector3 GimpVector3;
|
typedef struct _GimpVector3 GimpVector3;
|
||||||
typedef struct _GimpVector4 GimpVector4;
|
typedef struct _GimpVector4 GimpVector4;
|
||||||
|
|
||||||
struct _GimpVector2
|
|
||||||
{
|
|
||||||
gdouble x, y;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GimpVector3
|
|
||||||
{
|
|
||||||
gdouble x, y, z;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GimpVector4
|
|
||||||
{
|
|
||||||
gdouble x, y, z, w;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GIMP_MATH_TYPES_H__ */
|
#endif /* __GIMP_MATH_TYPES_H__ */
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <string.h> /* memcmp */
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "gimpmath.h"
|
#include "gimpmath.h"
|
||||||
|
@ -43,55 +41,59 @@
|
||||||
* Transforms a point in 2D as specified by the transformation matrix.
|
* Transforms a point in 2D as specified by the transformation matrix.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_transform_point (GimpMatrix3 matrix,
|
gimp_matrix3_transform_point (const GimpMatrix3 *matrix,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
gdouble *newx,
|
gdouble *newx,
|
||||||
gdouble *newy)
|
gdouble *newy)
|
||||||
{
|
{
|
||||||
gdouble w;
|
gdouble w;
|
||||||
|
|
||||||
w = matrix[2][0]*x + matrix[2][1]*y + matrix[2][2];
|
w = matrix->coeff[2][0] * x + matrix->coeff[2][1] * y + matrix->coeff[2][2];
|
||||||
|
|
||||||
if (w == 0.0)
|
if (w == 0.0)
|
||||||
w = 1.0;
|
w = 1.0;
|
||||||
else
|
else
|
||||||
w = 1.0/w;
|
w = 1.0/w;
|
||||||
|
|
||||||
*newx = (matrix[0][0]*x + matrix[0][1]*y + matrix[0][2])*w;
|
*newx = (matrix->coeff[0][0] * x +
|
||||||
*newy = (matrix[1][0]*x + matrix[1][1]*y + matrix[1][2])*w;
|
matrix->coeff[0][1] * y +
|
||||||
|
matrix->coeff[0][2]) * w;
|
||||||
|
*newy = (matrix->coeff[1][0] * x +
|
||||||
|
matrix->coeff[1][1] * y +
|
||||||
|
matrix->coeff[1][2]) * w;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_matrix3_mult:
|
* gimp_matrix3_mult:
|
||||||
* @matrix1: The first input matrix.
|
* @matrix1: The first input matrix.
|
||||||
* @matrix2: The second input matrix which will be oeverwritten ba the result.
|
* @matrix2: The second input matrix which will be oeverwritten by the result.
|
||||||
*
|
*
|
||||||
* Multiplies two matrices and puts the result into the second one.
|
* Multiplies two matrices and puts the result into the second one.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_mult (GimpMatrix3 matrix1,
|
gimp_matrix3_mult (const GimpMatrix3 *matrix1,
|
||||||
GimpMatrix3 matrix2)
|
GimpMatrix3 *matrix2)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j;
|
||||||
GimpMatrix3 tmp;
|
GimpMatrix3 tmp;
|
||||||
gdouble t1, t2, t3;
|
gdouble t1, t2, t3;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
t1 = matrix1[i][0];
|
t1 = matrix1->coeff[i][0];
|
||||||
t2 = matrix1[i][1];
|
t2 = matrix1->coeff[i][1];
|
||||||
t3 = matrix1[i][2];
|
t3 = matrix1->coeff[i][2];
|
||||||
|
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
tmp[i][j] = t1 * matrix2[0][j];
|
tmp.coeff[i][j] = t1 * matrix2->coeff[0][j];
|
||||||
tmp[i][j] += t2 * matrix2[1][j];
|
tmp.coeff[i][j] += t2 * matrix2->coeff[1][j];
|
||||||
tmp[i][j] += t3 * matrix2[2][j];
|
tmp.coeff[i][j] += t3 * matrix2->coeff[2][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* put the results in matrix2 */
|
*matrix2 = tmp;
|
||||||
memcpy (&matrix2[0][0], &tmp[0][0], sizeof (GimpMatrix3));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,13 +103,13 @@ gimp_matrix3_mult (GimpMatrix3 matrix1,
|
||||||
* Sets the matrix to the identity matrix.
|
* Sets the matrix to the identity matrix.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_identity (GimpMatrix3 matrix)
|
gimp_matrix3_identity (GimpMatrix3 *matrix)
|
||||||
{
|
{
|
||||||
static GimpMatrix3 identity = { { 1.0, 0.0, 0.0 },
|
static GimpMatrix3 identity = { { { 1.0, 0.0, 0.0 },
|
||||||
{ 0.0, 1.0, 0.0 },
|
{ 0.0, 1.0, 0.0 },
|
||||||
{ 0.0, 0.0, 1.0 } };
|
{ 0.0, 0.0, 1.0 } } };
|
||||||
|
|
||||||
memcpy (&matrix[0][0], &identity[0][0], sizeof (GimpMatrix3));
|
*matrix = identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,22 +121,22 @@ gimp_matrix3_identity (GimpMatrix3 matrix)
|
||||||
* Translates the matrix by x and y.
|
* Translates the matrix by x and y.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_translate (GimpMatrix3 matrix,
|
gimp_matrix3_translate (GimpMatrix3 *matrix,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y)
|
gdouble y)
|
||||||
{
|
{
|
||||||
gdouble g, h, i;
|
gdouble g, h, i;
|
||||||
|
|
||||||
g = matrix[2][0];
|
g = matrix->coeff[2][0];
|
||||||
h = matrix[2][1];
|
h = matrix->coeff[2][1];
|
||||||
i = matrix[2][2];
|
i = matrix->coeff[2][2];
|
||||||
|
|
||||||
matrix[0][0] += x * g;
|
matrix->coeff[0][0] += x * g;
|
||||||
matrix[0][1] += x * h;
|
matrix->coeff[0][1] += x * h;
|
||||||
matrix[0][2] += x * i;
|
matrix->coeff[0][2] += x * i;
|
||||||
matrix[1][0] += y * g;
|
matrix->coeff[1][0] += y * g;
|
||||||
matrix[1][1] += y * h;
|
matrix->coeff[1][1] += y * h;
|
||||||
matrix[1][2] += y * i;
|
matrix->coeff[1][2] += y * i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,17 +148,17 @@ gimp_matrix3_translate (GimpMatrix3 matrix,
|
||||||
* Scales the matrix by x and y
|
* Scales the matrix by x and y
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_scale (GimpMatrix3 matrix,
|
gimp_matrix3_scale (GimpMatrix3 *matrix,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y)
|
gdouble y)
|
||||||
{
|
{
|
||||||
matrix[0][0] *= x;
|
matrix->coeff[0][0] *= x;
|
||||||
matrix[0][1] *= x;
|
matrix->coeff[0][1] *= x;
|
||||||
matrix[0][2] *= x;
|
matrix->coeff[0][2] *= x;
|
||||||
|
|
||||||
matrix[1][0] *= y;
|
matrix->coeff[1][0] *= y;
|
||||||
matrix[1][1] *= y;
|
matrix->coeff[1][1] *= y;
|
||||||
matrix[1][2] *= y;
|
matrix->coeff[1][2] *= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,8 +169,8 @@ gimp_matrix3_scale (GimpMatrix3 matrix,
|
||||||
* Rotates the matrix by theta degrees.
|
* Rotates the matrix by theta degrees.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_rotate (GimpMatrix3 matrix,
|
gimp_matrix3_rotate (GimpMatrix3 *matrix,
|
||||||
gdouble theta)
|
gdouble theta)
|
||||||
{
|
{
|
||||||
gdouble t1, t2;
|
gdouble t1, t2;
|
||||||
gdouble cost, sint;
|
gdouble cost, sint;
|
||||||
|
@ -176,20 +178,20 @@ gimp_matrix3_rotate (GimpMatrix3 matrix,
|
||||||
cost = cos (theta);
|
cost = cos (theta);
|
||||||
sint = sin (theta);
|
sint = sin (theta);
|
||||||
|
|
||||||
t1 = matrix[0][0];
|
t1 = matrix->coeff[0][0];
|
||||||
t2 = matrix[1][0];
|
t2 = matrix->coeff[1][0];
|
||||||
matrix[0][0] = cost * t1 - sint * t2;
|
matrix->coeff[0][0] = cost * t1 - sint * t2;
|
||||||
matrix[1][0] = sint * t1 + cost * t2;
|
matrix->coeff[1][0] = sint * t1 + cost * t2;
|
||||||
|
|
||||||
t1 = matrix[0][1];
|
t1 = matrix->coeff[0][1];
|
||||||
t2 = matrix[1][1];
|
t2 = matrix->coeff[1][1];
|
||||||
matrix[0][1] = cost * t1 - sint * t2;
|
matrix->coeff[0][1] = cost * t1 - sint * t2;
|
||||||
matrix[1][1] = sint*t1 + cost*t2;
|
matrix->coeff[1][1] = sint * t1 + cost * t2;
|
||||||
|
|
||||||
t1 = matrix[0][2];
|
t1 = matrix->coeff[0][2];
|
||||||
t2 = matrix[1][2];
|
t2 = matrix->coeff[1][2];
|
||||||
matrix[0][2] = cost*t1 - sint*t2;
|
matrix->coeff[0][2] = cost * t1 - sint * t2;
|
||||||
matrix[1][2] = sint*t1 + cost*t2;
|
matrix->coeff[1][2] = sint * t1 + cost * t2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,12 +202,12 @@ gimp_matrix3_rotate (GimpMatrix3 matrix,
|
||||||
* Shears the matrix in the X direction.
|
* Shears the matrix in the X direction.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_xshear (GimpMatrix3 matrix,
|
gimp_matrix3_xshear (GimpMatrix3 *matrix,
|
||||||
gdouble amount)
|
gdouble amount)
|
||||||
{
|
{
|
||||||
matrix[0][0] += amount * matrix[1][0];
|
matrix->coeff[0][0] += amount * matrix->coeff[1][0];
|
||||||
matrix[0][1] += amount * matrix[1][1];
|
matrix->coeff[0][1] += amount * matrix->coeff[1][1];
|
||||||
matrix[0][2] += amount * matrix[1][2];
|
matrix->coeff[0][2] += amount * matrix->coeff[1][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,12 +218,12 @@ gimp_matrix3_xshear (GimpMatrix3 matrix,
|
||||||
* Shears the matrix in the Y direction.
|
* Shears the matrix in the Y direction.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_yshear (GimpMatrix3 matrix,
|
gimp_matrix3_yshear (GimpMatrix3 *matrix,
|
||||||
gdouble amount)
|
gdouble amount)
|
||||||
{
|
{
|
||||||
matrix[1][0] += amount * matrix[0][0];
|
matrix->coeff[1][0] += amount * matrix->coeff[0][0];
|
||||||
matrix[1][1] += amount * matrix[0][1];
|
matrix->coeff[1][1] += amount * matrix->coeff[0][1];
|
||||||
matrix[1][2] += amount * matrix[0][2];
|
matrix->coeff[1][2] += amount * matrix->coeff[0][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,16 +235,19 @@ gimp_matrix3_yshear (GimpMatrix3 matrix,
|
||||||
* Returns: The determinant.
|
* Returns: The determinant.
|
||||||
*/
|
*/
|
||||||
gdouble
|
gdouble
|
||||||
gimp_matrix3_determinant (GimpMatrix3 matrix)
|
gimp_matrix3_determinant (const GimpMatrix3 *matrix)
|
||||||
{
|
{
|
||||||
gdouble determinant;
|
gdouble determinant;
|
||||||
|
|
||||||
determinant =
|
determinant = (matrix->coeff[0][0] *
|
||||||
matrix[0][0] * (matrix[1][1]*matrix[2][2] - matrix[1][2]*matrix[2][1]);
|
(matrix->coeff[1][1] * matrix->coeff[2][2] -
|
||||||
determinant -=
|
matrix->coeff[1][2] * matrix->coeff[2][1]));
|
||||||
matrix[1][0] * (matrix[0][1]*matrix[2][2] - matrix[0][2]*matrix[2][1]);
|
determinant -= (matrix->coeff[1][0] *
|
||||||
determinant +=
|
(matrix->coeff[0][1] * matrix->coeff[2][2] -
|
||||||
matrix[2][0] * (matrix[0][1]*matrix[1][2] - matrix[0][2]*matrix[1][1]);
|
matrix->coeff[0][2] * matrix->coeff[2][1]));
|
||||||
|
determinant += (matrix->coeff[2][0] *
|
||||||
|
(matrix->coeff[0][1] * matrix->coeff[1][2] -
|
||||||
|
matrix->coeff[0][2] * matrix->coeff[1][1]));
|
||||||
|
|
||||||
return determinant;
|
return determinant;
|
||||||
}
|
}
|
||||||
|
@ -250,64 +255,50 @@ gimp_matrix3_determinant (GimpMatrix3 matrix)
|
||||||
/**
|
/**
|
||||||
* gimp_matrix3_invert:
|
* gimp_matrix3_invert:
|
||||||
* @matrix: The matrix that is to be inverted.
|
* @matrix: The matrix that is to be inverted.
|
||||||
* @matrix_inv: A matrix the inverted matrix should be written into.
|
|
||||||
*
|
*
|
||||||
* Inverts the given matrix.
|
* Inverts the given matrix.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_matrix3_invert (GimpMatrix3 matrix,
|
gimp_matrix3_invert (GimpMatrix3 *matrix)
|
||||||
GimpMatrix3 matrix_inv)
|
|
||||||
{
|
{
|
||||||
gdouble det_1;
|
GimpMatrix3 inv;
|
||||||
|
gdouble det;
|
||||||
|
|
||||||
det_1 = gimp_matrix3_determinant (matrix);
|
det = gimp_matrix3_determinant (matrix);
|
||||||
|
|
||||||
if (det_1 == 0.0)
|
if (det == 0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
det_1 = 1.0 / det_1;
|
det = 1.0 / det;
|
||||||
|
|
||||||
matrix_inv[0][0] =
|
inv.coeff[0][0] = (matrix->coeff[1][1] * matrix->coeff[2][2] -
|
||||||
(matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1]) * det_1;
|
matrix->coeff[1][2] * matrix->coeff[2][1]) * det;
|
||||||
|
|
||||||
matrix_inv[1][0] =
|
inv.coeff[1][0] = - (matrix->coeff[1][0] * matrix->coeff[2][2] -
|
||||||
- (matrix[1][0] * matrix[2][2] - matrix[1][2] * matrix[2][0]) * det_1;
|
matrix->coeff[1][2] * matrix->coeff[2][0]) * det;
|
||||||
|
|
||||||
matrix_inv[2][0] =
|
inv.coeff[2][0] = (matrix->coeff[1][0] * matrix->coeff[2][1] -
|
||||||
(matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0]) * det_1;
|
matrix->coeff[1][1] * matrix->coeff[2][0]) * det;
|
||||||
|
|
||||||
matrix_inv[0][1] =
|
inv.coeff[0][1] = - (matrix->coeff[0][1] * matrix->coeff[2][2] -
|
||||||
- (matrix[0][1] * matrix[2][2] - matrix[0][2] * matrix[2][1] ) * det_1;
|
matrix->coeff[0][2] * matrix->coeff[2][1]) * det;
|
||||||
|
|
||||||
matrix_inv[1][1] =
|
inv.coeff[1][1] = (matrix->coeff[0][0] * matrix->coeff[2][2] -
|
||||||
(matrix[0][0] * matrix[2][2] - matrix[0][2] * matrix[2][0]) * det_1;
|
matrix->coeff[0][2] * matrix->coeff[2][0]) * det;
|
||||||
|
|
||||||
matrix_inv[2][1] =
|
inv.coeff[2][1] = - (matrix->coeff[0][0] * matrix->coeff[2][1] -
|
||||||
- (matrix[0][0] * matrix[2][1] - matrix[0][1] * matrix[2][0]) * det_1;
|
matrix->coeff[0][1] * matrix->coeff[2][0]) * det;
|
||||||
|
|
||||||
matrix_inv[0][2] =
|
inv.coeff[0][2] = (matrix->coeff[0][1] * matrix->coeff[1][2] -
|
||||||
(matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1]) * det_1;
|
matrix->coeff[0][2] * matrix->coeff[1][1]) * det;
|
||||||
|
|
||||||
matrix_inv[1][2] =
|
inv.coeff[1][2] = - (matrix->coeff[0][0] * matrix->coeff[1][2] -
|
||||||
- (matrix[0][0] * matrix[1][2] - matrix[0][2] * matrix[1][0]) * det_1;
|
matrix->coeff[0][2] * matrix->coeff[1][0]) * det;
|
||||||
|
|
||||||
matrix_inv[2][2] =
|
inv.coeff[2][2] = (matrix->coeff[0][0] * matrix->coeff[1][1] -
|
||||||
(matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]) * det_1;
|
matrix->coeff[0][1] * matrix->coeff[1][0]) * det;
|
||||||
}
|
|
||||||
|
|
||||||
|
*matrix = inv;
|
||||||
/**
|
|
||||||
* gimp_matrix3_duplicate:
|
|
||||||
* @src: The source matrix.
|
|
||||||
* @target: The destination matrix.
|
|
||||||
*
|
|
||||||
* Copies the source matrix to the destination matrix.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gimp_matrix3_duplicate (GimpMatrix3 src,
|
|
||||||
GimpMatrix3 target)
|
|
||||||
{
|
|
||||||
memcpy (&target[0][0], &src[0][0], sizeof (GimpMatrix3));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,7 +314,7 @@ gimp_matrix3_duplicate (GimpMatrix3 src,
|
||||||
* Returns: TRUE if the matrix is diagonal.
|
* Returns: TRUE if the matrix is diagonal.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gimp_matrix3_is_diagonal (GimpMatrix3 matrix)
|
gimp_matrix3_is_diagonal (const GimpMatrix3 *matrix)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
|
||||||
|
@ -331,7 +322,7 @@ gimp_matrix3_is_diagonal (GimpMatrix3 matrix)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
if (i != j && fabs (matrix[i][j]) > EPSILON)
|
if (i != j && fabs (matrix->coeff[i][j]) > EPSILON)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,9 +339,9 @@ gimp_matrix3_is_diagonal (GimpMatrix3 matrix)
|
||||||
* Returns: TRUE if the matrix is the identity matrix.
|
* Returns: TRUE if the matrix is the identity matrix.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gimp_matrix3_is_identity (GimpMatrix3 matrix)
|
gimp_matrix3_is_identity (const GimpMatrix3 *matrix)
|
||||||
{
|
{
|
||||||
gint i,j;
|
gint i, j;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
@ -358,12 +349,12 @@ gimp_matrix3_is_identity (GimpMatrix3 matrix)
|
||||||
{
|
{
|
||||||
if (i == j)
|
if (i == j)
|
||||||
{
|
{
|
||||||
if (fabs (matrix[i][j] - 1.0) > EPSILON)
|
if (fabs (matrix->coeff[i][j] - 1.0) > EPSILON)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fabs (matrix[i][j]) > EPSILON)
|
if (fabs (matrix->coeff[i][j]) > EPSILON)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,16 +380,16 @@ gimp_matrix3_is_identity (GimpMatrix3 matrix)
|
||||||
* 0 or 1
|
* 0 or 1
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gimp_matrix3_is_simple (GimpMatrix3 matrix)
|
gimp_matrix3_is_simple (const GimpMatrix3 *matrix)
|
||||||
{
|
{
|
||||||
gdouble absm;
|
gdouble absm;
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 2; j++)
|
for (j = 0; j < 2; j++)
|
||||||
{
|
{
|
||||||
absm = fabs (matrix[i][j]);
|
absm = fabs (matrix->coeff[i][j]);
|
||||||
if (absm > EPSILON && fabs (absm - 1.0) > EPSILON)
|
if (absm > EPSILON && fabs (absm - 1.0) > EPSILON)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -408,12 +399,12 @@ gimp_matrix3_is_simple (GimpMatrix3 matrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_matrix4_to_deg (GimpMatrix4 matrix,
|
gimp_matrix4_to_deg (const GimpMatrix4 *matrix,
|
||||||
gdouble *a,
|
gdouble *a,
|
||||||
gdouble *b,
|
gdouble *b,
|
||||||
gdouble *c)
|
gdouble *c)
|
||||||
{
|
{
|
||||||
*a = 180 * (asin (matrix[1][0]) / G_PI_2);
|
*a = 180 * (asin (matrix->coeff[1][0]) / G_PI_2);
|
||||||
*b = 180 * (asin (matrix[2][0]) / G_PI_2);
|
*b = 180 * (asin (matrix->coeff[2][0]) / G_PI_2);
|
||||||
*c = 180 * (asin (matrix[2][1]) / G_PI_2);
|
*c = 180 * (asin (matrix->coeff[2][1]) / G_PI_2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,42 +27,49 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
/* For information look into the C source or the html documentation */
|
/* For information look into the C source or the html documentation */
|
||||||
|
|
||||||
|
struct _GimpMatrix3
|
||||||
|
{
|
||||||
|
gdouble coeff[3][3];
|
||||||
|
};
|
||||||
|
|
||||||
void gimp_matrix3_transform_point (GimpMatrix3 matrix,
|
struct _GimpMatrix4
|
||||||
gdouble x,
|
{
|
||||||
gdouble y,
|
gdouble coeff[4][4];
|
||||||
gdouble *newx,
|
};
|
||||||
gdouble *newy);
|
|
||||||
void gimp_matrix3_mult (GimpMatrix3 matrix1,
|
|
||||||
GimpMatrix3 matrix2);
|
|
||||||
void gimp_matrix3_identity (GimpMatrix3 matrix);
|
|
||||||
void gimp_matrix3_translate (GimpMatrix3 matrix,
|
|
||||||
gdouble x,
|
|
||||||
gdouble y);
|
|
||||||
void gimp_matrix3_scale (GimpMatrix3 matrix,
|
|
||||||
gdouble x,
|
|
||||||
gdouble y);
|
|
||||||
void gimp_matrix3_rotate (GimpMatrix3 matrix,
|
|
||||||
gdouble theta);
|
|
||||||
void gimp_matrix3_xshear (GimpMatrix3 matrix,
|
|
||||||
gdouble amount);
|
|
||||||
void gimp_matrix3_yshear (GimpMatrix3 matrix,
|
|
||||||
gdouble amount);
|
|
||||||
gdouble gimp_matrix3_determinant (GimpMatrix3 matrix);
|
|
||||||
void gimp_matrix3_invert (GimpMatrix3 matrix,
|
|
||||||
GimpMatrix3 matrix_inv);
|
|
||||||
void gimp_matrix3_duplicate (GimpMatrix3 src,
|
|
||||||
GimpMatrix3 target);
|
|
||||||
|
|
||||||
gboolean gimp_matrix3_is_diagonal (GimpMatrix3 matrix);
|
|
||||||
gboolean gimp_matrix3_is_identity (GimpMatrix3 matrix);
|
|
||||||
gboolean gimp_matrix3_is_simple (GimpMatrix3 matrix);
|
|
||||||
|
|
||||||
|
|
||||||
void gimp_matrix4_to_deg (GimpMatrix4 matrix,
|
void gimp_matrix3_transform_point (const GimpMatrix3 *matrix,
|
||||||
gdouble *a,
|
gdouble x,
|
||||||
gdouble *b,
|
gdouble y,
|
||||||
gdouble *c);
|
gdouble *newx,
|
||||||
|
gdouble *newy);
|
||||||
|
void gimp_matrix3_mult (const GimpMatrix3 *matrix1,
|
||||||
|
GimpMatrix3 *matrix2);
|
||||||
|
void gimp_matrix3_identity (GimpMatrix3 *matrix);
|
||||||
|
void gimp_matrix3_translate (GimpMatrix3 *matrix,
|
||||||
|
gdouble x,
|
||||||
|
gdouble y);
|
||||||
|
void gimp_matrix3_scale (GimpMatrix3 *matrix,
|
||||||
|
gdouble x,
|
||||||
|
gdouble y);
|
||||||
|
void gimp_matrix3_rotate (GimpMatrix3 *matrix,
|
||||||
|
gdouble theta);
|
||||||
|
void gimp_matrix3_xshear (GimpMatrix3 *matrix,
|
||||||
|
gdouble amount);
|
||||||
|
void gimp_matrix3_yshear (GimpMatrix3 *matrix,
|
||||||
|
gdouble amount);
|
||||||
|
gdouble gimp_matrix3_determinant (const GimpMatrix3 *matrix);
|
||||||
|
void gimp_matrix3_invert (GimpMatrix3 *matrix);
|
||||||
|
|
||||||
|
gboolean gimp_matrix3_is_diagonal (const GimpMatrix3 *matrix);
|
||||||
|
gboolean gimp_matrix3_is_identity (const GimpMatrix3 *matrix);
|
||||||
|
gboolean gimp_matrix3_is_simple (const GimpMatrix3 *matrix);
|
||||||
|
|
||||||
|
|
||||||
|
void gimp_matrix4_to_deg (const GimpMatrix4 *matrix,
|
||||||
|
gdouble *a,
|
||||||
|
gdouble *b,
|
||||||
|
gdouble *c);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -30,6 +30,21 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
/* For information look into the C source or the html documentation */
|
/* For information look into the C source or the html documentation */
|
||||||
|
|
||||||
|
struct _GimpVector2
|
||||||
|
{
|
||||||
|
gdouble x, y;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpVector3
|
||||||
|
{
|
||||||
|
gdouble x, y, z;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpVector4
|
||||||
|
{
|
||||||
|
gdouble x, y, z, w;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Two dimensional vector functions */
|
/* Two dimensional vector functions */
|
||||||
/* ================================ */
|
/* ================================ */
|
||||||
|
|
|
@ -137,7 +137,7 @@ HELP
|
||||||
trans_info[Y2],
|
trans_info[Y2],
|
||||||
trans_info[X3],
|
trans_info[X3],
|
||||||
trans_info[Y3],
|
trans_info[Y3],
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -146,7 +146,7 @@ HELP
|
||||||
|
|
||||||
/* Perspective the selection */
|
/* Perspective the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
|
@ -191,7 +191,7 @@ HELP
|
||||||
/* Assemble the transformation matrix */
|
/* Assemble the transformation matrix */
|
||||||
gimp_drawable_transform_matrix_rotate (x1, y1, x2, y2,
|
gimp_drawable_transform_matrix_rotate (x1, y1, x2, y2,
|
||||||
angle,
|
angle,
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -200,7 +200,7 @@ HELP
|
||||||
|
|
||||||
/* Rotate the selection */
|
/* Rotate the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
|
@ -260,7 +260,7 @@ HELP
|
||||||
trans_info[Y0],
|
trans_info[Y0],
|
||||||
trans_info[X1],
|
trans_info[X1],
|
||||||
trans_info[Y1],
|
trans_info[Y1],
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -269,7 +269,7 @@ HELP
|
||||||
|
|
||||||
/* Scale the selection */
|
/* Scale the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -325,7 +325,7 @@ HELP
|
||||||
gimp_drawable_transform_matrix_shear (x1, y1, x2, y2,
|
gimp_drawable_transform_matrix_shear (x1, y1, x2, y2,
|
||||||
shear_type,
|
shear_type,
|
||||||
magnitude,
|
magnitude,
|
||||||
matrix);
|
&matrix);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -334,7 +334,7 @@ HELP
|
||||||
|
|
||||||
/* Shear the selection */
|
/* Shear the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
|
@ -390,11 +390,11 @@ HELP
|
||||||
code => <<'CODE'
|
code => <<'CODE'
|
||||||
{
|
{
|
||||||
/* Assemble the transformation matrix */
|
/* Assemble the transformation matrix */
|
||||||
gimp_matrix3_identity (matrix);
|
gimp_matrix3_identity (&matrix);
|
||||||
gimp_matrix3_translate (matrix, -source_x, -source_y);
|
gimp_matrix3_translate (&matrix, -source_x, -source_y);
|
||||||
gimp_matrix3_scale (matrix, scale_x, scale_y);
|
gimp_matrix3_scale (&matrix, scale_x, scale_y);
|
||||||
gimp_matrix3_rotate (matrix, angle);
|
gimp_matrix3_rotate (&matrix, angle);
|
||||||
gimp_matrix3_translate (matrix, dest_x, dest_y);
|
gimp_matrix3_translate (&matrix, dest_x, dest_y);
|
||||||
|
|
||||||
if (interpolation)
|
if (interpolation)
|
||||||
interpolation_type = gimp->config->interpolation_type;
|
interpolation_type = gimp->config->interpolation_type;
|
||||||
|
@ -403,7 +403,7 @@ HELP
|
||||||
|
|
||||||
/* Transform the selection */
|
/* Transform the selection */
|
||||||
success = gimp_drawable_transform_affine (drawable,
|
success = gimp_drawable_transform_affine (drawable,
|
||||||
matrix, GIMP_TRANSFORM_FORWARD,
|
&matrix, GIMP_TRANSFORM_FORWARD,
|
||||||
interpolation_type, FALSE);
|
interpolation_type, FALSE);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue