Re: [Gimp-developer] Gimp Plug-in for Retrieving Text Layers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bill,

BillC@xxxxxxxxxx wrote:
> I am having difficulties enumerating, and identifying layers in a Gimp 
> Plug-in.  Is there 
> a good source for code that shows how to do this? 

Not really - the usual way is to do something like this:

gint nlayers, i;
gint *layers = gimp_image_get_layers(image_id, &nlayers);
/* layers[0] is the top layer */

for (i = 0; i < nlayers; i++)
{
  /* Do stuff with layers[i] */
  /* layer is a text layer if the parasite "gimp-text-layer" has been
   * set */
  GimpDrawable *layer = gimp_drawable_get (layers[i]);
  GimpParasite *text_parasite = gimp_drawable_parasite_find
                                  (layers[i], "gimp-text-layer");
  if (text_parasite != NULL)
    /* We have a text layer */
  
} 

All the standard GIMP parasites are listed in the gimp sources,
in devel-docs/parasites.txt. There are also docs for things like
debugging plug-ins, overviews of many of the GIMP's internal
formats including xcf, and some documentation for important
subsystems like undo, as well as gtkdocs for the libgimp API.

> To do this, I need to iterate through all of the layers, find the 
> text ones, get the text
> and save it to a file.

I'm not sure how the text is stores in a gimp-text-layer
parasite. It is a GimpText object serialised to a string, if that
helps any. UTSL (Use the Source, Luke) or ask Sven :)

Hope this helps,

Cheers,
Dave.

-- 
        David Neary,
        Lyon, France
   E-Mail: bolsh@xxxxxxxx
CV: http://dneary.free.fr/CV/

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux