broken pipe in the middle of the last commit...
* app/xcf/xcf-save.c: when saving a text layer, store an extra parasite that holds all information about the text. * app/xcf/xcf-load.c: if a "gimp-text-layer" parasite is found and it can be successfully deserialized to a GimpText object, convert the layer to a text layer and remove the parasite. * devel-docs/parasites.txt: documented the new "gimp-text-layer" parasite.
This commit is contained in:
@ -46,6 +46,9 @@
|
|||||||
#include "core/gimpparasitelist.h"
|
#include "core/gimpparasitelist.h"
|
||||||
#include "core/gimpunit.h"
|
#include "core/gimpunit.h"
|
||||||
|
|
||||||
|
#include "text/gimptextlayer.h"
|
||||||
|
#include "text/gimptext-parasite.h"
|
||||||
|
|
||||||
#include "vectors/gimpvectors.h"
|
#include "vectors/gimpvectors.h"
|
||||||
#include "vectors/gimpvectors-compat.h"
|
#include "vectors/gimpvectors-compat.h"
|
||||||
|
|
||||||
@ -724,6 +727,7 @@ xcf_load_layer (XcfInfo *info,
|
|||||||
{
|
{
|
||||||
GimpLayer *layer;
|
GimpLayer *layer;
|
||||||
GimpLayerMask *layer_mask;
|
GimpLayerMask *layer_mask;
|
||||||
|
GimpParasite *parasite;
|
||||||
guint32 hierarchy_offset;
|
guint32 hierarchy_offset;
|
||||||
guint32 layer_mask_offset;
|
guint32 layer_mask_offset;
|
||||||
gboolean apply_mask;
|
gboolean apply_mask;
|
||||||
@ -759,6 +763,30 @@ xcf_load_layer (XcfInfo *info,
|
|||||||
&apply_mask, &edit_mask, &show_mask))
|
&apply_mask, &edit_mask, &show_mask))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
/* check for a gimp-text parasite */
|
||||||
|
parasite = gimp_item_parasite_find (GIMP_ITEM (layer),
|
||||||
|
gimp_text_parasite_name ());
|
||||||
|
if (parasite)
|
||||||
|
{
|
||||||
|
GimpText *text = gimp_text_from_parasite (parasite);
|
||||||
|
|
||||||
|
if (text)
|
||||||
|
{
|
||||||
|
gboolean active;
|
||||||
|
|
||||||
|
gimp_parasite_list_remove (GIMP_ITEM (layer)->parasites,
|
||||||
|
gimp_parasite_name (parasite));
|
||||||
|
|
||||||
|
active = (info->active_layer == layer);
|
||||||
|
|
||||||
|
/* convert the layer to a text layer */
|
||||||
|
layer = gimp_text_layer_from_layer (layer, text);
|
||||||
|
|
||||||
|
if (active)
|
||||||
|
info->active_layer = layer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* read the hierarchy and layer mask offsets */
|
/* read the hierarchy and layer mask offsets */
|
||||||
info->cp += xcf_read_int32 (info->fp, &hierarchy_offset, 1);
|
info->cp += xcf_read_int32 (info->fp, &hierarchy_offset, 1);
|
||||||
info->cp += xcf_read_int32 (info->fp, &layer_mask_offset, 1);
|
info->cp += xcf_read_int32 (info->fp, &layer_mask_offset, 1);
|
||||||
|
@ -43,6 +43,9 @@
|
|||||||
#include "core/gimpparasitelist.h"
|
#include "core/gimpparasitelist.h"
|
||||||
#include "core/gimpunit.h"
|
#include "core/gimpunit.h"
|
||||||
|
|
||||||
|
#include "text/gimptextlayer.h"
|
||||||
|
#include "text/gimptext-parasite.h"
|
||||||
|
|
||||||
#include "vectors/gimpvectors.h"
|
#include "vectors/gimpvectors.h"
|
||||||
#include "vectors/gimpvectors-compat.h"
|
#include "vectors/gimpvectors-compat.h"
|
||||||
|
|
||||||
@ -433,6 +436,8 @@ xcf_save_layer_props (XcfInfo *info,
|
|||||||
GimpLayer *layer,
|
GimpLayer *layer,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
GimpParasite *parasite = NULL;
|
||||||
|
|
||||||
if (layer == gimp_image_get_active_layer (gimage))
|
if (layer == gimp_image_get_active_layer (gimage))
|
||||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_ACTIVE_LAYER, error));
|
xcf_check_error (xcf_save_prop (info, gimage, PROP_ACTIVE_LAYER, error));
|
||||||
|
|
||||||
@ -479,9 +484,26 @@ xcf_save_layer_props (XcfInfo *info,
|
|||||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_TATTOO, error,
|
xcf_check_error (xcf_save_prop (info, gimage, PROP_TATTOO, error,
|
||||||
GIMP_ITEM (layer)->tattoo));
|
GIMP_ITEM (layer)->tattoo));
|
||||||
|
|
||||||
|
if (GIMP_IS_TEXT_LAYER (layer))
|
||||||
|
{
|
||||||
|
GimpText *text = gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer));
|
||||||
|
|
||||||
|
parasite = gimp_text_to_parasite (text);
|
||||||
|
gimp_parasite_list_add (GIMP_ITEM (layer)->parasites, parasite);
|
||||||
|
}
|
||||||
|
|
||||||
if (gimp_parasite_list_length (GIMP_ITEM (layer)->parasites) > 0)
|
if (gimp_parasite_list_length (GIMP_ITEM (layer)->parasites) > 0)
|
||||||
|
{
|
||||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_PARASITES, error,
|
xcf_check_error (xcf_save_prop (info, gimage, PROP_PARASITES, error,
|
||||||
GIMP_ITEM (layer)->parasites));
|
GIMP_ITEM (layer)->parasites));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parasite)
|
||||||
|
{
|
||||||
|
gimp_parasite_list_remove (GIMP_ITEM (layer)->parasites,
|
||||||
|
gimp_parasite_name (parasite));
|
||||||
|
gimp_parasite_free (parasite);
|
||||||
|
}
|
||||||
|
|
||||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_END, error));
|
xcf_check_error (xcf_save_prop (info, gimage, PROP_END, error));
|
||||||
|
|
||||||
|
@ -76,6 +76,13 @@ Global data follows no strict rules.
|
|||||||
think of ;-) Determines how one index from each dimension is
|
think of ;-) Determines how one index from each dimension is
|
||||||
selected (until we have pinpointed the brush to use).
|
selected (until we have pinpointed the brush to use).
|
||||||
|
|
||||||
|
"gimp-text-layer" (LAYER, PERSISTENT)
|
||||||
|
The associated GimpText object serialized to a string. For
|
||||||
|
convenience the string is terminated by a trailing '\0'.
|
||||||
|
The idea of using a parasite for text layers is to keep the XCF
|
||||||
|
files backward compatible. Although gimp-1.2 doesn't know how
|
||||||
|
to handle the text layer, it keeps the parasite intact.
|
||||||
|
|
||||||
"tiff-save-options" (IMAGE)
|
"tiff-save-options" (IMAGE)
|
||||||
The TiffSaveVals structure from the TIFF plugin.
|
The TiffSaveVals structure from the TIFF plugin.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user