Commit 65717041 authored by Jehan's avatar Jehan

app: save image symmetries in the XCF file.

Symmetries are saved in a parasite, which is backward compatible.
parent 9090a984
......@@ -45,6 +45,7 @@
#include "core/gimpimage-metadata.h"
#include "core/gimpimage-private.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimpimage-symmetry.h"
#include "core/gimpimage-undo.h"
#include "core/gimpitemstack.h"
#include "core/gimplayer-floating-selection.h"
......@@ -53,6 +54,7 @@
#include "core/gimpparasitelist.h"
#include "core/gimpprogress.h"
#include "core/gimpselection.h"
#include "core/gimpsymmetry.h"
#include "core/gimptemplate.h"
#include "operations/layer-modes/gimp-layer-modes.h"
......@@ -160,6 +162,8 @@ xcf_load_image (Gimp *gimp,
gint image_type;
GimpPrecision precision = GIMP_PRECISION_U8_GAMMA;
gint num_successful_elements = 0;
GList *syms;
GList *iter;
/* read in the image width, height and type */
xcf_read_int32 (info, (guint32 *) &width, 1);
......@@ -272,6 +276,39 @@ xcf_load_image (Gimp *gimp,
gimp_parasite_name (parasite));
}
/* check for symmetry parasites */
syms = gimp_image_symmetry_list ();
for (iter = syms; iter; iter = g_list_next (iter))
{
GType type = (GType) iter->data;
gchar *parasite_name = gimp_symmetry_parasite_name (type);
parasite = gimp_image_parasite_find (image,
parasite_name);
g_free (parasite_name);
if (parasite)
{
GimpSymmetry *sym = gimp_symmetry_from_parasite (parasite,
image,
type);
if (sym)
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
gimp_parasite_list_remove (private->parasites,
gimp_parasite_name (parasite));
gimp_image_symmetry_add (image, sym);
g_signal_emit_by_name (sym, "active-changed", NULL);
if (sym->active)
gimp_image_set_active_symmetry (image, type);
}
}
}
g_list_free (syms);
/* migrate the old "exif-data" parasite */
parasite = gimp_image_parasite_find (GIMP_IMAGE (image),
"exif-data");
......
......@@ -45,11 +45,13 @@
#include "core/gimpimage-metadata.h"
#include "core/gimpimage-private.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimpimage-symmetry.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimpparasitelist.h"
#include "core/gimpprogress.h"
#include "core/gimpsamplepoint.h"
#include "core/gimpsymmetry.h"
#include "operations/layer-modes/gimp-layer-modes.h"
......@@ -358,6 +360,8 @@ xcf_save_image_props (XcfInfo *info,
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
GimpParasite *grid_parasite = NULL;
GimpParasite *meta_parasite = NULL;
GList *symmetry_parasites = NULL;
GList *iter;
GimpUnit unit = gimp_image_get_unit (image);
gdouble xres;
gdouble yres;
......@@ -428,6 +432,23 @@ xcf_save_image_props (XcfInfo *info,
}
}
if (g_list_length (gimp_image_symmetry_get (image)))
{
GimpParasite *parasite = NULL;
GimpSymmetry *symmetry;
for (iter = gimp_image_symmetry_get (image); iter; iter = g_list_next (iter))
{
symmetry = GIMP_SYMMETRY (iter->data);
if (G_TYPE_FROM_INSTANCE (symmetry) == GIMP_TYPE_SYMMETRY)
/* Do not save the identity symmetry. */
continue;
parasite = gimp_symmetry_to_parasite (GIMP_SYMMETRY (iter->data));
gimp_parasite_list_add (private->parasites, parasite);
symmetry_parasites = g_list_prepend (symmetry_parasites, parasite);
}
}
if (gimp_parasite_list_length (private->parasites) > 0)
{
xcf_check_error (xcf_save_prop (info, image, PROP_PARASITES, error,
......@@ -448,6 +469,16 @@ xcf_save_image_props (XcfInfo *info,
gimp_parasite_free (meta_parasite);
}
for (iter = symmetry_parasites; iter; iter = g_list_next (iter))
{
GimpParasite *parasite = iter->data;
gimp_parasite_list_remove (private->parasites,
gimp_parasite_name (parasite));
}
g_list_free_full (symmetry_parasites,
(GDestroyNotify) gimp_parasite_free);
xcf_check_error (xcf_save_prop (info, image, PROP_END, error));
return TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment