mirror of https://github.com/GNOME/gimp.git
Issue #12011: gimp-path-import-from-file etc. are misnamed.
This commit is contained in:
parent
d0983a2bbd
commit
b8712b27de
|
@ -61,6 +61,8 @@
|
||||||
#include "plug-in/gimpplugin-cleanup.h"
|
#include "plug-in/gimpplugin-cleanup.h"
|
||||||
#include "plug-in/gimpplugin.h"
|
#include "plug-in/gimpplugin.h"
|
||||||
#include "plug-in/gimppluginmanager.h"
|
#include "plug-in/gimppluginmanager.h"
|
||||||
|
#include "vectors/gimppath-export.h"
|
||||||
|
#include "vectors/gimppath-import.h"
|
||||||
#include "vectors/gimppath.h"
|
#include "vectors/gimppath.h"
|
||||||
|
|
||||||
#include "gimppdb.h"
|
#include "gimppdb.h"
|
||||||
|
@ -1104,6 +1106,212 @@ image_remove_path_invoker (GimpProcedure *procedure,
|
||||||
error ? *error : NULL);
|
error ? *error : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GimpValueArray *
|
||||||
|
image_import_paths_from_file_invoker (GimpProcedure *procedure,
|
||||||
|
Gimp *gimp,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpProgress *progress,
|
||||||
|
const GimpValueArray *args,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean success = TRUE;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
GimpImage *image;
|
||||||
|
GFile *file;
|
||||||
|
gboolean merge;
|
||||||
|
gboolean scale;
|
||||||
|
gint num_paths = 0;
|
||||||
|
GimpPath **path = NULL;
|
||||||
|
|
||||||
|
image = g_value_get_object (gimp_value_array_index (args, 0));
|
||||||
|
file = g_value_get_object (gimp_value_array_index (args, 1));
|
||||||
|
merge = g_value_get_boolean (gimp_value_array_index (args, 2));
|
||||||
|
scale = g_value_get_boolean (gimp_value_array_index (args, 3));
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
GList *path_list = NULL;
|
||||||
|
|
||||||
|
/* FIXME tree */
|
||||||
|
success = gimp_path_import_file (image, file,
|
||||||
|
merge, scale, NULL, -1,
|
||||||
|
&path_list, error);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
num_paths = g_list_length (path_list);
|
||||||
|
|
||||||
|
if (num_paths)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
path = g_new (GimpPath *, num_paths);
|
||||||
|
|
||||||
|
for (i = 0, list = path_list;
|
||||||
|
i < num_paths;
|
||||||
|
i++, list = g_list_next (list))
|
||||||
|
{
|
||||||
|
path[i] = g_object_ref (list->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (path_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||||
|
error ? *error : NULL);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
g_value_set_int (gimp_value_array_index (return_vals, 1), num_paths);
|
||||||
|
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_PATH, (GObject **) path, num_paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
return return_vals;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GimpValueArray *
|
||||||
|
image_import_paths_from_string_invoker (GimpProcedure *procedure,
|
||||||
|
Gimp *gimp,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpProgress *progress,
|
||||||
|
const GimpValueArray *args,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean success = TRUE;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
GimpImage *image;
|
||||||
|
const gchar *string;
|
||||||
|
gint length;
|
||||||
|
gboolean merge;
|
||||||
|
gboolean scale;
|
||||||
|
gint num_paths = 0;
|
||||||
|
GimpPath **path = NULL;
|
||||||
|
|
||||||
|
image = g_value_get_object (gimp_value_array_index (args, 0));
|
||||||
|
string = g_value_get_string (gimp_value_array_index (args, 1));
|
||||||
|
length = g_value_get_int (gimp_value_array_index (args, 2));
|
||||||
|
merge = g_value_get_boolean (gimp_value_array_index (args, 3));
|
||||||
|
scale = g_value_get_boolean (gimp_value_array_index (args, 4));
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
GList *path_list = NULL;
|
||||||
|
|
||||||
|
/* FIXME tree */
|
||||||
|
success = gimp_path_import_buffer (image, string, length,
|
||||||
|
merge, scale, NULL, -1,
|
||||||
|
&path_list, error);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
num_paths = g_list_length (path_list);
|
||||||
|
|
||||||
|
if (num_paths)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
path = g_new (GimpPath *, num_paths);
|
||||||
|
|
||||||
|
for (i = 0, list = path_list;
|
||||||
|
i < num_paths;
|
||||||
|
i++, list = g_list_next (list))
|
||||||
|
{
|
||||||
|
path[i] = g_object_ref (list->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (path_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||||
|
error ? *error : NULL);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
g_value_set_int (gimp_value_array_index (return_vals, 1), num_paths);
|
||||||
|
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_PATH, (GObject **) path, num_paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
return return_vals;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GimpValueArray *
|
||||||
|
image_export_path_to_file_invoker (GimpProcedure *procedure,
|
||||||
|
Gimp *gimp,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpProgress *progress,
|
||||||
|
const GimpValueArray *args,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean success = TRUE;
|
||||||
|
GimpImage *image;
|
||||||
|
GFile *file;
|
||||||
|
GimpPath *path;
|
||||||
|
|
||||||
|
image = g_value_get_object (gimp_value_array_index (args, 0));
|
||||||
|
file = g_value_get_object (gimp_value_array_index (args, 1));
|
||||||
|
path = g_value_get_object (gimp_value_array_index (args, 2));
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
GList *path_list = NULL;
|
||||||
|
|
||||||
|
if (path != NULL)
|
||||||
|
path_list = g_list_prepend (path_list, path);
|
||||||
|
|
||||||
|
success = gimp_path_export_file (image, path_list, file, error);
|
||||||
|
|
||||||
|
g_list_free (path_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
return gimp_procedure_get_return_values (procedure, success,
|
||||||
|
error ? *error : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GimpValueArray *
|
||||||
|
image_export_path_to_string_invoker (GimpProcedure *procedure,
|
||||||
|
Gimp *gimp,
|
||||||
|
GimpContext *context,
|
||||||
|
GimpProgress *progress,
|
||||||
|
const GimpValueArray *args,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean success = TRUE;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
GimpImage *image;
|
||||||
|
GimpPath *path;
|
||||||
|
gchar *string = NULL;
|
||||||
|
|
||||||
|
image = g_value_get_object (gimp_value_array_index (args, 0));
|
||||||
|
path = g_value_get_object (gimp_value_array_index (args, 1));
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
GList *path_list = NULL;
|
||||||
|
|
||||||
|
if (path != NULL)
|
||||||
|
path_list = g_list_prepend (path_list, path);
|
||||||
|
|
||||||
|
string = gimp_path_export_string (image, path_list);
|
||||||
|
g_list_free (path_list);
|
||||||
|
|
||||||
|
success = (string != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||||
|
error ? *error : NULL);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
g_value_take_string (gimp_value_array_index (return_vals, 1), string);
|
||||||
|
|
||||||
|
return return_vals;
|
||||||
|
}
|
||||||
|
|
||||||
static GimpValueArray *
|
static GimpValueArray *
|
||||||
image_freeze_paths_invoker (GimpProcedure *procedure,
|
image_freeze_paths_invoker (GimpProcedure *procedure,
|
||||||
Gimp *gimp,
|
Gimp *gimp,
|
||||||
|
@ -3895,6 +4103,190 @@ register_image_procs (GimpPDB *pdb)
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
g_object_unref (procedure);
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gimp-image-import-paths-from-file
|
||||||
|
*/
|
||||||
|
procedure = gimp_procedure_new (image_import_paths_from_file_invoker);
|
||||||
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||||
|
"gimp-image-import-paths-from-file");
|
||||||
|
gimp_procedure_set_static_help (procedure,
|
||||||
|
"Import paths from an SVG file.",
|
||||||
|
"This procedure imports paths from an SVG file. SVG elements other than paths and basic shapes are ignored.",
|
||||||
|
NULL);
|
||||||
|
gimp_procedure_set_static_attribution (procedure,
|
||||||
|
"Simon Budig",
|
||||||
|
"Simon Budig",
|
||||||
|
"2006");
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_image ("image",
|
||||||
|
"image",
|
||||||
|
"The image",
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
g_param_spec_object ("file",
|
||||||
|
"file",
|
||||||
|
"The SVG file to import.",
|
||||||
|
G_TYPE_FILE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
g_param_spec_boolean ("merge",
|
||||||
|
"merge",
|
||||||
|
"Merge paths into a single path object.",
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
g_param_spec_boolean ("scale",
|
||||||
|
"scale",
|
||||||
|
"Scale the SVG to image dimensions.",
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_return_value (procedure,
|
||||||
|
g_param_spec_int ("num-paths",
|
||||||
|
"num paths",
|
||||||
|
"The number of newly created path",
|
||||||
|
0, G_MAXINT32, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_return_value (procedure,
|
||||||
|
gimp_param_spec_object_array ("path",
|
||||||
|
"path",
|
||||||
|
"The list of newly created path",
|
||||||
|
GIMP_TYPE_PATH,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gimp-image-import-paths-from-string
|
||||||
|
*/
|
||||||
|
procedure = gimp_procedure_new (image_import_paths_from_string_invoker);
|
||||||
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||||
|
"gimp-image-import-paths-from-string");
|
||||||
|
gimp_procedure_set_static_help (procedure,
|
||||||
|
"Import paths from an SVG string.",
|
||||||
|
"This procedure works like [method@Gimp.Image.import_paths_from_file] but takes a string rather than reading the SVG from a file. This allows you to write scripts that generate SVG and feed it to GIMP.",
|
||||||
|
NULL);
|
||||||
|
gimp_procedure_set_static_attribution (procedure,
|
||||||
|
"Simon Budig",
|
||||||
|
"Simon Budig",
|
||||||
|
"2006");
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_image ("image",
|
||||||
|
"image",
|
||||||
|
"The image",
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_string ("string",
|
||||||
|
"string",
|
||||||
|
"A string that must be a complete and valid SVG document.",
|
||||||
|
TRUE, FALSE, FALSE,
|
||||||
|
NULL,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
g_param_spec_int ("length",
|
||||||
|
"length",
|
||||||
|
"Number of bytes in string or -1 if the string is NULL terminated.",
|
||||||
|
G_MININT32, G_MAXINT32, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
g_param_spec_boolean ("merge",
|
||||||
|
"merge",
|
||||||
|
"Merge paths into a single path object.",
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
g_param_spec_boolean ("scale",
|
||||||
|
"scale",
|
||||||
|
"Scale the SVG to image dimensions.",
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_return_value (procedure,
|
||||||
|
g_param_spec_int ("num-paths",
|
||||||
|
"num paths",
|
||||||
|
"The number of newly created path",
|
||||||
|
0, G_MAXINT32, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_return_value (procedure,
|
||||||
|
gimp_param_spec_object_array ("path",
|
||||||
|
"path",
|
||||||
|
"The list of newly created path",
|
||||||
|
GIMP_TYPE_PATH,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gimp-image-export-path-to-file
|
||||||
|
*/
|
||||||
|
procedure = gimp_procedure_new (image_export_path_to_file_invoker);
|
||||||
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||||
|
"gimp-image-export-path-to-file");
|
||||||
|
gimp_procedure_set_static_help (procedure,
|
||||||
|
"save a path as an SVG file.",
|
||||||
|
"This procedure creates an SVG file to save a Path object, that is, a path. The resulting file can be edited using a vector graphics application, or later reloaded into GIMP. Pass %NULL as the 'path' argument to export all paths in the image.",
|
||||||
|
NULL);
|
||||||
|
gimp_procedure_set_static_attribution (procedure,
|
||||||
|
"Bill Skaggs <weskaggs@primate.ucdavis.edu>",
|
||||||
|
"Bill Skaggs",
|
||||||
|
"2007");
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_image ("image",
|
||||||
|
"image",
|
||||||
|
"The image",
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
g_param_spec_object ("file",
|
||||||
|
"file",
|
||||||
|
"The SVG file to create.",
|
||||||
|
G_TYPE_FILE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_path ("path",
|
||||||
|
"path",
|
||||||
|
"The path object to export, or %NULL for all in the image",
|
||||||
|
TRUE,
|
||||||
|
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
|
||||||
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
|
g_object_unref (procedure);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gimp-image-export-path-to-string
|
||||||
|
*/
|
||||||
|
procedure = gimp_procedure_new (image_export_path_to_string_invoker);
|
||||||
|
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||||
|
"gimp-image-export-path-to-string");
|
||||||
|
gimp_procedure_set_static_help (procedure,
|
||||||
|
"Save a path as an SVG string.",
|
||||||
|
"This procedure works like [method@Gimp.Image.export_path_to_file] but creates a string rather than a file. The string is NULL-terminated and holds a complete XML document. Pass %NULL as the 'path' argument to export all paths in the image.",
|
||||||
|
NULL);
|
||||||
|
gimp_procedure_set_static_attribution (procedure,
|
||||||
|
"Bill Skaggs <weskaggs@primate.ucdavis.edu>",
|
||||||
|
"Bill Skaggs",
|
||||||
|
"2007");
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_image ("image",
|
||||||
|
"image",
|
||||||
|
"The image",
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_procedure_add_argument (procedure,
|
||||||
|
gimp_param_spec_path ("path",
|
||||||
|
"path",
|
||||||
|
"The path object to export, or %NULL for all in the image",
|
||||||
|
TRUE,
|
||||||
|
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
|
||||||
|
gimp_procedure_add_return_value (procedure,
|
||||||
|
gimp_param_spec_string ("string",
|
||||||
|
"string",
|
||||||
|
"A string whose contents are a complete SVG document.",
|
||||||
|
FALSE, FALSE, FALSE,
|
||||||
|
NULL,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
|
g_object_unref (procedure);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gimp-image-freeze-paths
|
* gimp-image-freeze-paths
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -40,8 +40,6 @@
|
||||||
#include "text/gimptextlayer.h"
|
#include "text/gimptextlayer.h"
|
||||||
#include "vectors/gimpanchor.h"
|
#include "vectors/gimpanchor.h"
|
||||||
#include "vectors/gimpbezierstroke.h"
|
#include "vectors/gimpbezierstroke.h"
|
||||||
#include "vectors/gimppath-export.h"
|
|
||||||
#include "vectors/gimppath-import.h"
|
|
||||||
#include "vectors/gimppath.h"
|
#include "vectors/gimppath.h"
|
||||||
#include "vectors/gimpstroke-new.h"
|
#include "vectors/gimpstroke-new.h"
|
||||||
|
|
||||||
|
@ -1140,212 +1138,6 @@ path_bezier_stroke_new_ellipse_invoker (GimpProcedure *procedure,
|
||||||
return return_vals;
|
return return_vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GimpValueArray *
|
|
||||||
path_import_from_file_invoker (GimpProcedure *procedure,
|
|
||||||
Gimp *gimp,
|
|
||||||
GimpContext *context,
|
|
||||||
GimpProgress *progress,
|
|
||||||
const GimpValueArray *args,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean success = TRUE;
|
|
||||||
GimpValueArray *return_vals;
|
|
||||||
GimpImage *image;
|
|
||||||
GFile *file;
|
|
||||||
gboolean merge;
|
|
||||||
gboolean scale;
|
|
||||||
gint num_paths = 0;
|
|
||||||
GimpPath **path = NULL;
|
|
||||||
|
|
||||||
image = g_value_get_object (gimp_value_array_index (args, 0));
|
|
||||||
file = g_value_get_object (gimp_value_array_index (args, 1));
|
|
||||||
merge = g_value_get_boolean (gimp_value_array_index (args, 2));
|
|
||||||
scale = g_value_get_boolean (gimp_value_array_index (args, 3));
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
GList *path_list = NULL;
|
|
||||||
|
|
||||||
/* FIXME tree */
|
|
||||||
success = gimp_path_import_file (image, file,
|
|
||||||
merge, scale, NULL, -1,
|
|
||||||
&path_list, error);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
num_paths = g_list_length (path_list);
|
|
||||||
|
|
||||||
if (num_paths)
|
|
||||||
{
|
|
||||||
GList *list;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
path = g_new (GimpPath *, num_paths);
|
|
||||||
|
|
||||||
for (i = 0, list = path_list;
|
|
||||||
i < num_paths;
|
|
||||||
i++, list = g_list_next (list))
|
|
||||||
{
|
|
||||||
path[i] = g_object_ref (list->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free (path_list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
||||||
error ? *error : NULL);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
g_value_set_int (gimp_value_array_index (return_vals, 1), num_paths);
|
|
||||||
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_PATH, (GObject **) path, num_paths);
|
|
||||||
}
|
|
||||||
|
|
||||||
return return_vals;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GimpValueArray *
|
|
||||||
path_import_from_string_invoker (GimpProcedure *procedure,
|
|
||||||
Gimp *gimp,
|
|
||||||
GimpContext *context,
|
|
||||||
GimpProgress *progress,
|
|
||||||
const GimpValueArray *args,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean success = TRUE;
|
|
||||||
GimpValueArray *return_vals;
|
|
||||||
GimpImage *image;
|
|
||||||
const gchar *string;
|
|
||||||
gint length;
|
|
||||||
gboolean merge;
|
|
||||||
gboolean scale;
|
|
||||||
gint num_paths = 0;
|
|
||||||
GimpPath **path = NULL;
|
|
||||||
|
|
||||||
image = g_value_get_object (gimp_value_array_index (args, 0));
|
|
||||||
string = g_value_get_string (gimp_value_array_index (args, 1));
|
|
||||||
length = g_value_get_int (gimp_value_array_index (args, 2));
|
|
||||||
merge = g_value_get_boolean (gimp_value_array_index (args, 3));
|
|
||||||
scale = g_value_get_boolean (gimp_value_array_index (args, 4));
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
GList *path_list = NULL;
|
|
||||||
|
|
||||||
/* FIXME tree */
|
|
||||||
success = gimp_path_import_buffer (image, string, length,
|
|
||||||
merge, scale, NULL, -1,
|
|
||||||
&path_list, error);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
num_paths = g_list_length (path_list);
|
|
||||||
|
|
||||||
if (num_paths)
|
|
||||||
{
|
|
||||||
GList *list;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
path = g_new (GimpPath *, num_paths);
|
|
||||||
|
|
||||||
for (i = 0, list = path_list;
|
|
||||||
i < num_paths;
|
|
||||||
i++, list = g_list_next (list))
|
|
||||||
{
|
|
||||||
path[i] = g_object_ref (list->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free (path_list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
||||||
error ? *error : NULL);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
g_value_set_int (gimp_value_array_index (return_vals, 1), num_paths);
|
|
||||||
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_PATH, (GObject **) path, num_paths);
|
|
||||||
}
|
|
||||||
|
|
||||||
return return_vals;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GimpValueArray *
|
|
||||||
path_export_to_file_invoker (GimpProcedure *procedure,
|
|
||||||
Gimp *gimp,
|
|
||||||
GimpContext *context,
|
|
||||||
GimpProgress *progress,
|
|
||||||
const GimpValueArray *args,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean success = TRUE;
|
|
||||||
GimpImage *image;
|
|
||||||
GFile *file;
|
|
||||||
GimpPath *path;
|
|
||||||
|
|
||||||
image = g_value_get_object (gimp_value_array_index (args, 0));
|
|
||||||
file = g_value_get_object (gimp_value_array_index (args, 1));
|
|
||||||
path = g_value_get_object (gimp_value_array_index (args, 2));
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
GList *path_list = NULL;
|
|
||||||
|
|
||||||
if (path != NULL)
|
|
||||||
path_list = g_list_prepend (path_list, path);
|
|
||||||
|
|
||||||
success = gimp_path_export_file (image, path_list, file, error);
|
|
||||||
|
|
||||||
g_list_free (path_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return gimp_procedure_get_return_values (procedure, success,
|
|
||||||
error ? *error : NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GimpValueArray *
|
|
||||||
path_export_to_string_invoker (GimpProcedure *procedure,
|
|
||||||
Gimp *gimp,
|
|
||||||
GimpContext *context,
|
|
||||||
GimpProgress *progress,
|
|
||||||
const GimpValueArray *args,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean success = TRUE;
|
|
||||||
GimpValueArray *return_vals;
|
|
||||||
GimpImage *image;
|
|
||||||
GimpPath *path;
|
|
||||||
gchar *string = NULL;
|
|
||||||
|
|
||||||
image = g_value_get_object (gimp_value_array_index (args, 0));
|
|
||||||
path = g_value_get_object (gimp_value_array_index (args, 1));
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
GList *path_list = NULL;
|
|
||||||
|
|
||||||
if (path != NULL)
|
|
||||||
path_list = g_list_prepend (path_list, path);
|
|
||||||
|
|
||||||
string = gimp_path_export_string (image, path_list);
|
|
||||||
g_list_free (path_list);
|
|
||||||
|
|
||||||
success = (string != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
|
||||||
error ? *error : NULL);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
g_value_take_string (gimp_value_array_index (return_vals, 1), string);
|
|
||||||
|
|
||||||
return return_vals;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
register_path_procs (GimpPDB *pdb)
|
register_path_procs (GimpPDB *pdb)
|
||||||
{
|
{
|
||||||
|
@ -2320,188 +2112,4 @@ register_path_procs (GimpPDB *pdb)
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
gimp_pdb_register_procedure (pdb, procedure);
|
||||||
g_object_unref (procedure);
|
g_object_unref (procedure);
|
||||||
|
|
||||||
/*
|
|
||||||
* gimp-path-import-from-file
|
|
||||||
*/
|
|
||||||
procedure = gimp_procedure_new (path_import_from_file_invoker);
|
|
||||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
||||||
"gimp-path-import-from-file");
|
|
||||||
gimp_procedure_set_static_help (procedure,
|
|
||||||
"Import paths from an SVG file.",
|
|
||||||
"This procedure imports paths from an SVG file. SVG elements other than paths and basic shapes are ignored.",
|
|
||||||
NULL);
|
|
||||||
gimp_procedure_set_static_attribution (procedure,
|
|
||||||
"Simon Budig",
|
|
||||||
"Simon Budig",
|
|
||||||
"2006");
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_image ("image",
|
|
||||||
"image",
|
|
||||||
"The image",
|
|
||||||
FALSE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
g_param_spec_object ("file",
|
|
||||||
"file",
|
|
||||||
"The SVG file to import.",
|
|
||||||
G_TYPE_FILE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
g_param_spec_boolean ("merge",
|
|
||||||
"merge",
|
|
||||||
"Merge paths into a single path object.",
|
|
||||||
FALSE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
g_param_spec_boolean ("scale",
|
|
||||||
"scale",
|
|
||||||
"Scale the SVG to image dimensions.",
|
|
||||||
FALSE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_return_value (procedure,
|
|
||||||
g_param_spec_int ("num-paths",
|
|
||||||
"num paths",
|
|
||||||
"The number of newly created path",
|
|
||||||
0, G_MAXINT32, 0,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_return_value (procedure,
|
|
||||||
gimp_param_spec_object_array ("path",
|
|
||||||
"path",
|
|
||||||
"The list of newly created path",
|
|
||||||
GIMP_TYPE_PATH,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
|
||||||
g_object_unref (procedure);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gimp-path-import-from-string
|
|
||||||
*/
|
|
||||||
procedure = gimp_procedure_new (path_import_from_string_invoker);
|
|
||||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
||||||
"gimp-path-import-from-string");
|
|
||||||
gimp_procedure_set_static_help (procedure,
|
|
||||||
"Import paths from an SVG string.",
|
|
||||||
"This procedure works like 'gimp-path-import-from-file' but takes a string rather than reading the SVG from a file. This allows you to write scripts that generate SVG and feed it to GIMP.",
|
|
||||||
NULL);
|
|
||||||
gimp_procedure_set_static_attribution (procedure,
|
|
||||||
"Simon Budig",
|
|
||||||
"Simon Budig",
|
|
||||||
"2006");
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_image ("image",
|
|
||||||
"image",
|
|
||||||
"The image",
|
|
||||||
FALSE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_string ("string",
|
|
||||||
"string",
|
|
||||||
"A string that must be a complete and valid SVG document.",
|
|
||||||
TRUE, FALSE, FALSE,
|
|
||||||
NULL,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
g_param_spec_int ("length",
|
|
||||||
"length",
|
|
||||||
"Number of bytes in string or -1 if the string is NULL terminated.",
|
|
||||||
G_MININT32, G_MAXINT32, 0,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
g_param_spec_boolean ("merge",
|
|
||||||
"merge",
|
|
||||||
"Merge paths into a single path object.",
|
|
||||||
FALSE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
g_param_spec_boolean ("scale",
|
|
||||||
"scale",
|
|
||||||
"Scale the SVG to image dimensions.",
|
|
||||||
FALSE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_return_value (procedure,
|
|
||||||
g_param_spec_int ("num-paths",
|
|
||||||
"num paths",
|
|
||||||
"The number of newly created path",
|
|
||||||
0, G_MAXINT32, 0,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_return_value (procedure,
|
|
||||||
gimp_param_spec_object_array ("path",
|
|
||||||
"path",
|
|
||||||
"The list of newly created path",
|
|
||||||
GIMP_TYPE_PATH,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
|
||||||
g_object_unref (procedure);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gimp-path-export-to-file
|
|
||||||
*/
|
|
||||||
procedure = gimp_procedure_new (path_export_to_file_invoker);
|
|
||||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
||||||
"gimp-path-export-to-file");
|
|
||||||
gimp_procedure_set_static_help (procedure,
|
|
||||||
"save a path as an SVG file.",
|
|
||||||
"This procedure creates an SVG file to save a Path object, that is, a path. The resulting file can be edited using a vector graphics application, or later reloaded into GIMP. Pass %NULL as the 'path' argument to export all paths in the image.",
|
|
||||||
NULL);
|
|
||||||
gimp_procedure_set_static_attribution (procedure,
|
|
||||||
"Bill Skaggs <weskaggs@primate.ucdavis.edu>",
|
|
||||||
"Bill Skaggs",
|
|
||||||
"2007");
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_image ("image",
|
|
||||||
"image",
|
|
||||||
"The image",
|
|
||||||
FALSE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
g_param_spec_object ("file",
|
|
||||||
"file",
|
|
||||||
"The SVG file to create.",
|
|
||||||
G_TYPE_FILE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_path ("path",
|
|
||||||
"path",
|
|
||||||
"The path object to export, or %NULL for all in the image",
|
|
||||||
TRUE,
|
|
||||||
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
|
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
|
||||||
g_object_unref (procedure);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gimp-path-export-to-string
|
|
||||||
*/
|
|
||||||
procedure = gimp_procedure_new (path_export_to_string_invoker);
|
|
||||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
|
||||||
"gimp-path-export-to-string");
|
|
||||||
gimp_procedure_set_static_help (procedure,
|
|
||||||
"Save a path as an SVG string.",
|
|
||||||
"This procedure works like 'gimp-path-export-to-file' but creates a string rather than a file. The string is NULL-terminated and holds a complete XML document. Pass %NULL as the 'path' argument to export all paths in the image.",
|
|
||||||
NULL);
|
|
||||||
gimp_procedure_set_static_attribution (procedure,
|
|
||||||
"Bill Skaggs <weskaggs@primate.ucdavis.edu>",
|
|
||||||
"Bill Skaggs",
|
|
||||||
"2007");
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_image ("image",
|
|
||||||
"image",
|
|
||||||
"The image",
|
|
||||||
FALSE,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_procedure_add_argument (procedure,
|
|
||||||
gimp_param_spec_path ("path",
|
|
||||||
"path",
|
|
||||||
"The path object to export, or %NULL for all in the image",
|
|
||||||
TRUE,
|
|
||||||
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
|
|
||||||
gimp_procedure_add_return_value (procedure,
|
|
||||||
gimp_param_spec_string ("string",
|
|
||||||
"string",
|
|
||||||
"A string whose contents are a complete SVG document.",
|
|
||||||
FALSE, FALSE, FALSE,
|
|
||||||
NULL,
|
|
||||||
GIMP_PARAM_READWRITE));
|
|
||||||
gimp_pdb_register_procedure (pdb, procedure);
|
|
||||||
g_object_unref (procedure);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,14 +166,14 @@ possible in the previous API is obviously still possible.
|
||||||
| `gimp_path_delete()` | `gimp_image_remove_path()` |
|
| `gimp_path_delete()` | `gimp_image_remove_path()` |
|
||||||
| `gimp_path_get_current()` | `gimp_image_get_selected_paths()` |
|
| `gimp_path_get_current()` | `gimp_image_get_selected_paths()` |
|
||||||
| `gimp_path_get_locked()` | *N/A* |
|
| `gimp_path_get_locked()` | *N/A* |
|
||||||
| `gimp_path_get_points()` | `gimp_path_stroke_get_points()` |
|
| `gimp_path_get_points()` | `gimp_path_stroke_get_points()` |
|
||||||
| `gimp_path_get_point_at_dist()` | `gimp_path_stroke_get_point_at_dist()` |
|
| `gimp_path_get_point_at_dist()` | `gimp_path_stroke_get_point_at_dist()` |
|
||||||
| `gimp_path_get_tattoo()` | `gimp_item_get_tattoo()` |
|
| `gimp_path_get_tattoo()` | `gimp_item_get_tattoo()` |
|
||||||
| `gimp_path_import()` | `gimp_path_import_from_file()` |
|
| `gimp_path_import()` | `gimp_image_import_paths_from_file()` |
|
||||||
| `gimp_path_list()` | `gimp_image_get_paths()` |
|
| `gimp_path_list()` | `gimp_image_get_paths()` |
|
||||||
| `gimp_path_set_current()` | `gimp_image_set_selected_paths()` |
|
| `gimp_path_set_current()` | `gimp_image_set_selected_paths()` |
|
||||||
| `gimp_path_set_locked()` | *N/A* |
|
| `gimp_path_set_locked()` | *N/A* |
|
||||||
| `gimp_path_set_points()` | `gimp_path_stroke_new_from_points()` |
|
| `gimp_path_set_points()` | `gimp_path_stroke_new_from_points()` |
|
||||||
| `gimp_path_set_tattoo()` | `gimp_item_set_tattoo()` |
|
| `gimp_path_set_tattoo()` | `gimp_item_set_tattoo()` |
|
||||||
| `gimp_path_stroke_current()` | `gimp_edit_stroke_vectors()` |
|
| `gimp_path_stroke_current()` | `gimp_edit_stroke_vectors()` |
|
||||||
| `gimp_path_to_selection()` | `gimp_image_select_item()` |
|
| `gimp_path_to_selection()` | `gimp_image_select_item()` |
|
||||||
|
@ -201,11 +201,15 @@ possible in the previous API is obviously still possible.
|
||||||
| `gimp_toggle_button_sensitive_update()` | `g_object_bind_property()` |
|
| `gimp_toggle_button_sensitive_update()` | `g_object_bind_property()` |
|
||||||
| `gimp_transform_2d()` | `gimp_item_transform_2d()` |
|
| `gimp_transform_2d()` | `gimp_item_transform_2d()` |
|
||||||
| `gimp_unit_menu_update()` | `#GimpUnitComboBox` |
|
| `gimp_unit_menu_update()` | `#GimpUnitComboBox` |
|
||||||
|
| `gimp_vectors_export_to_file()` | `gimp_image_export_path_to_file()` |
|
||||||
|
| `gimp_vectors_export_to_string()` | `gimp_image_export_path_to_string()` |
|
||||||
| `gimp_vectors_get_image()` | `gimp_item_get_image()` |
|
| `gimp_vectors_get_image()` | `gimp_item_get_image()` |
|
||||||
| `gimp_vectors_get_linked()` | *N/A* |
|
| `gimp_vectors_get_linked()` | *N/A* |
|
||||||
| `gimp_vectors_get_name()` | `gimp_item_get_name()` |
|
| `gimp_vectors_get_name()` | `gimp_item_get_name()` |
|
||||||
| `gimp_vectors_get_tattoo()` | `gimp_item_get_tattoo()` |
|
| `gimp_vectors_get_tattoo()` | `gimp_item_get_tattoo()` |
|
||||||
| `gimp_vectors_get_visible()` | `gimp_item_get_visible()` |
|
| `gimp_vectors_get_visible()` | `gimp_item_get_visible()` |
|
||||||
|
| `gimp_vectors_import_from_file()` | `gimp_image_import_paths_from_file()` |
|
||||||
|
| `gimp_vectors_import_from_string()` | `gimp_image_import_paths_from_string()` |
|
||||||
| `gimp_vectors_is_valid()` | `gimp_item_is_valid()` |
|
| `gimp_vectors_is_valid()` | `gimp_item_is_valid()` |
|
||||||
| `gimp_vectors_parasite_attach()` | `gimp_item_attach_parasite()` |
|
| `gimp_vectors_parasite_attach()` | `gimp_item_attach_parasite()` |
|
||||||
| `gimp_vectors_parasite_detach()` | `gimp_item_detach_parasite()` |
|
| `gimp_vectors_parasite_detach()` | `gimp_item_detach_parasite()` |
|
||||||
|
|
|
@ -397,6 +397,8 @@ EXPORTS
|
||||||
gimp_image_delete_sample_point
|
gimp_image_delete_sample_point
|
||||||
gimp_image_detach_parasite
|
gimp_image_detach_parasite
|
||||||
gimp_image_duplicate
|
gimp_image_duplicate
|
||||||
|
gimp_image_export_path_to_file
|
||||||
|
gimp_image_export_path_to_string
|
||||||
gimp_image_find_next_guide
|
gimp_image_find_next_guide
|
||||||
gimp_image_find_next_sample_point
|
gimp_image_find_next_sample_point
|
||||||
gimp_image_flatten
|
gimp_image_flatten
|
||||||
|
@ -465,6 +467,8 @@ EXPORTS
|
||||||
gimp_image_grid_set_spacing
|
gimp_image_grid_set_spacing
|
||||||
gimp_image_grid_set_style
|
gimp_image_grid_set_style
|
||||||
gimp_image_id_is_valid
|
gimp_image_id_is_valid
|
||||||
|
gimp_image_import_paths_from_file
|
||||||
|
gimp_image_import_paths_from_string
|
||||||
gimp_image_insert_channel
|
gimp_image_insert_channel
|
||||||
gimp_image_insert_layer
|
gimp_image_insert_layer
|
||||||
gimp_image_insert_path
|
gimp_image_insert_path
|
||||||
|
@ -716,13 +720,9 @@ EXPORTS
|
||||||
gimp_path_bezier_stroke_new_ellipse
|
gimp_path_bezier_stroke_new_ellipse
|
||||||
gimp_path_bezier_stroke_new_moveto
|
gimp_path_bezier_stroke_new_moveto
|
||||||
gimp_path_copy
|
gimp_path_copy
|
||||||
gimp_path_export_to_file
|
|
||||||
gimp_path_export_to_string
|
|
||||||
gimp_path_get_by_id
|
gimp_path_get_by_id
|
||||||
gimp_path_get_strokes
|
gimp_path_get_strokes
|
||||||
gimp_path_get_type
|
gimp_path_get_type
|
||||||
gimp_path_import_from_file
|
|
||||||
gimp_path_import_from_string
|
|
||||||
gimp_path_new
|
gimp_path_new
|
||||||
gimp_path_new_from_text_layer
|
gimp_path_new_from_text_layer
|
||||||
gimp_path_remove_stroke
|
gimp_path_remove_stroke
|
||||||
|
|
|
@ -1256,6 +1256,214 @@ gimp_image_remove_path (GimpImage *image,
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_image_import_paths_from_file:
|
||||||
|
* @image: The image.
|
||||||
|
* @file: The SVG file to import.
|
||||||
|
* @merge: Merge paths into a single path object.
|
||||||
|
* @scale: Scale the SVG to image dimensions.
|
||||||
|
* @num_paths: (out): The number of newly created path.
|
||||||
|
* @path: (out) (array length=num_paths) (element-type GimpPath) (transfer container): The list of newly created path.
|
||||||
|
*
|
||||||
|
* Import paths from an SVG file.
|
||||||
|
*
|
||||||
|
* This procedure imports paths from an SVG file. SVG elements other
|
||||||
|
* than paths and basic shapes are ignored.
|
||||||
|
*
|
||||||
|
* Returns: TRUE on success.
|
||||||
|
*
|
||||||
|
* Since: 2.4
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
gimp_image_import_paths_from_file (GimpImage *image,
|
||||||
|
GFile *file,
|
||||||
|
gboolean merge,
|
||||||
|
gboolean scale,
|
||||||
|
gint *num_paths,
|
||||||
|
GimpPath ***path)
|
||||||
|
{
|
||||||
|
GimpValueArray *args;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
gboolean success = TRUE;
|
||||||
|
|
||||||
|
args = gimp_value_array_new_from_types (NULL,
|
||||||
|
GIMP_TYPE_IMAGE, image,
|
||||||
|
G_TYPE_FILE, file,
|
||||||
|
G_TYPE_BOOLEAN, merge,
|
||||||
|
G_TYPE_BOOLEAN, scale,
|
||||||
|
G_TYPE_NONE);
|
||||||
|
|
||||||
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||||
|
"gimp-image-import-paths-from-file",
|
||||||
|
args);
|
||||||
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
*num_paths = 0;
|
||||||
|
*path = NULL;
|
||||||
|
|
||||||
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
*num_paths = GIMP_VALUES_GET_INT (return_vals, 1);
|
||||||
|
{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index (return_vals, 2)); if (a) *path = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_image_import_paths_from_string:
|
||||||
|
* @image: The image.
|
||||||
|
* @string: A string that must be a complete and valid SVG document.
|
||||||
|
* @length: Number of bytes in string or -1 if the string is NULL terminated.
|
||||||
|
* @merge: Merge paths into a single path object.
|
||||||
|
* @scale: Scale the SVG to image dimensions.
|
||||||
|
* @num_paths: (out): The number of newly created path.
|
||||||
|
* @path: (out) (array length=num_paths) (element-type GimpPath) (transfer container): The list of newly created path.
|
||||||
|
*
|
||||||
|
* Import paths from an SVG string.
|
||||||
|
*
|
||||||
|
* This procedure works like [method@Gimp.Image.import_paths_from_file]
|
||||||
|
* but takes a string rather than reading the SVG from a file. This
|
||||||
|
* allows you to write scripts that generate SVG and feed it to GIMP.
|
||||||
|
*
|
||||||
|
* Returns: TRUE on success.
|
||||||
|
*
|
||||||
|
* Since: 2.4
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
gimp_image_import_paths_from_string (GimpImage *image,
|
||||||
|
const gchar *string,
|
||||||
|
gint length,
|
||||||
|
gboolean merge,
|
||||||
|
gboolean scale,
|
||||||
|
gint *num_paths,
|
||||||
|
GimpPath ***path)
|
||||||
|
{
|
||||||
|
GimpValueArray *args;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
gboolean success = TRUE;
|
||||||
|
|
||||||
|
args = gimp_value_array_new_from_types (NULL,
|
||||||
|
GIMP_TYPE_IMAGE, image,
|
||||||
|
G_TYPE_STRING, string,
|
||||||
|
G_TYPE_INT, length,
|
||||||
|
G_TYPE_BOOLEAN, merge,
|
||||||
|
G_TYPE_BOOLEAN, scale,
|
||||||
|
G_TYPE_NONE);
|
||||||
|
|
||||||
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||||
|
"gimp-image-import-paths-from-string",
|
||||||
|
args);
|
||||||
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
*num_paths = 0;
|
||||||
|
*path = NULL;
|
||||||
|
|
||||||
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
*num_paths = GIMP_VALUES_GET_INT (return_vals, 1);
|
||||||
|
{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index (return_vals, 2)); if (a) *path = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_image_export_path_to_file:
|
||||||
|
* @image: The image.
|
||||||
|
* @file: The SVG file to create.
|
||||||
|
* @path: (nullable): The path object to export, or %NULL for all in the image.
|
||||||
|
*
|
||||||
|
* save a path as an SVG file.
|
||||||
|
*
|
||||||
|
* This procedure creates an SVG file to save a Path object, that is, a
|
||||||
|
* path. The resulting file can be edited using a vector graphics
|
||||||
|
* application, or later reloaded into GIMP. Pass %NULL as the 'path'
|
||||||
|
* argument to export all paths in the image.
|
||||||
|
*
|
||||||
|
* Returns: TRUE on success.
|
||||||
|
*
|
||||||
|
* Since: 2.6
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
gimp_image_export_path_to_file (GimpImage *image,
|
||||||
|
GFile *file,
|
||||||
|
GimpPath *path)
|
||||||
|
{
|
||||||
|
GimpValueArray *args;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
gboolean success = TRUE;
|
||||||
|
|
||||||
|
args = gimp_value_array_new_from_types (NULL,
|
||||||
|
GIMP_TYPE_IMAGE, image,
|
||||||
|
G_TYPE_FILE, file,
|
||||||
|
GIMP_TYPE_PATH, path,
|
||||||
|
G_TYPE_NONE);
|
||||||
|
|
||||||
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||||
|
"gimp-image-export-path-to-file",
|
||||||
|
args);
|
||||||
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
||||||
|
|
||||||
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_image_export_path_to_string:
|
||||||
|
* @image: The image.
|
||||||
|
* @path: (nullable): The path object to export, or %NULL for all in the image.
|
||||||
|
*
|
||||||
|
* Save a path as an SVG string.
|
||||||
|
*
|
||||||
|
* This procedure works like [method@Gimp.Image.export_path_to_file]
|
||||||
|
* but creates a string rather than a file. The string is
|
||||||
|
* NULL-terminated and holds a complete XML document. Pass %NULL as the
|
||||||
|
* 'path' argument to export all paths in the image.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full):
|
||||||
|
* A string whose contents are a complete SVG document.
|
||||||
|
* The returned value must be freed with g_free().
|
||||||
|
*
|
||||||
|
* Since: 2.6
|
||||||
|
**/
|
||||||
|
gchar *
|
||||||
|
gimp_image_export_path_to_string (GimpImage *image,
|
||||||
|
GimpPath *path)
|
||||||
|
{
|
||||||
|
GimpValueArray *args;
|
||||||
|
GimpValueArray *return_vals;
|
||||||
|
gchar *string = NULL;
|
||||||
|
|
||||||
|
args = gimp_value_array_new_from_types (NULL,
|
||||||
|
GIMP_TYPE_IMAGE, image,
|
||||||
|
GIMP_TYPE_PATH, path,
|
||||||
|
G_TYPE_NONE);
|
||||||
|
|
||||||
|
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||||
|
"gimp-image-export-path-to-string",
|
||||||
|
args);
|
||||||
|
gimp_value_array_unref (args);
|
||||||
|
|
||||||
|
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||||
|
string = GIMP_VALUES_DUP_STRING (return_vals, 1);
|
||||||
|
|
||||||
|
gimp_value_array_unref (return_vals);
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_image_freeze_paths:
|
* gimp_image_freeze_paths:
|
||||||
* @image: The image.
|
* @image: The image.
|
||||||
|
|
|
@ -32,173 +32,191 @@ 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 */
|
||||||
|
|
||||||
|
|
||||||
gboolean gimp_image_id_is_valid (gint image_id);
|
gboolean gimp_image_id_is_valid (gint image_id);
|
||||||
GimpImage** gimp_get_images (gint *num_images);
|
GimpImage** gimp_get_images (gint *num_images);
|
||||||
GimpImage* gimp_image_new (gint width,
|
GimpImage* gimp_image_new (gint width,
|
||||||
gint height,
|
gint height,
|
||||||
GimpImageBaseType type);
|
GimpImageBaseType type);
|
||||||
GimpImage* gimp_image_new_with_precision (gint width,
|
GimpImage* gimp_image_new_with_precision (gint width,
|
||||||
gint height,
|
gint height,
|
||||||
GimpImageBaseType type,
|
GimpImageBaseType type,
|
||||||
GimpPrecision precision);
|
GimpPrecision precision);
|
||||||
GimpImage* gimp_image_duplicate (GimpImage *image);
|
GimpImage* gimp_image_duplicate (GimpImage *image);
|
||||||
gboolean gimp_image_delete (GimpImage *image);
|
gboolean gimp_image_delete (GimpImage *image);
|
||||||
GimpImageBaseType gimp_image_get_base_type (GimpImage *image);
|
GimpImageBaseType gimp_image_get_base_type (GimpImage *image);
|
||||||
GimpPrecision gimp_image_get_precision (GimpImage *image);
|
GimpPrecision gimp_image_get_precision (GimpImage *image);
|
||||||
GimpLayerMode gimp_image_get_default_new_layer_mode (GimpImage *image);
|
GimpLayerMode gimp_image_get_default_new_layer_mode (GimpImage *image);
|
||||||
gint gimp_image_get_width (GimpImage *image);
|
gint gimp_image_get_width (GimpImage *image);
|
||||||
gint gimp_image_get_height (GimpImage *image);
|
gint gimp_image_get_height (GimpImage *image);
|
||||||
GimpLayer** gimp_image_get_layers (GimpImage *image,
|
GimpLayer** gimp_image_get_layers (GimpImage *image,
|
||||||
gint *num_layers);
|
gint *num_layers);
|
||||||
GimpChannel** gimp_image_get_channels (GimpImage *image,
|
GimpChannel** gimp_image_get_channels (GimpImage *image,
|
||||||
gint *num_channels);
|
gint *num_channels);
|
||||||
GimpPath** gimp_image_get_paths (GimpImage *image,
|
GimpPath** gimp_image_get_paths (GimpImage *image,
|
||||||
gint *num_paths);
|
gint *num_paths);
|
||||||
gboolean gimp_image_unset_active_channel (GimpImage *image);
|
gboolean gimp_image_unset_active_channel (GimpImage *image);
|
||||||
GimpLayer* gimp_image_get_floating_sel (GimpImage *image);
|
GimpLayer* gimp_image_get_floating_sel (GimpImage *image);
|
||||||
GimpDrawable* gimp_image_floating_sel_attached_to (GimpImage *image);
|
GimpDrawable* gimp_image_floating_sel_attached_to (GimpImage *image);
|
||||||
gboolean gimp_image_pick_color (GimpImage *image,
|
gboolean gimp_image_pick_color (GimpImage *image,
|
||||||
gint num_drawables,
|
gint num_drawables,
|
||||||
const GimpItem **drawables,
|
const GimpItem **drawables,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
gboolean sample_merged,
|
gboolean sample_merged,
|
||||||
gboolean sample_average,
|
gboolean sample_average,
|
||||||
gdouble average_radius,
|
gdouble average_radius,
|
||||||
GeglColor **color);
|
GeglColor **color);
|
||||||
GimpLayer* gimp_image_pick_correlate_layer (GimpImage *image,
|
GimpLayer* gimp_image_pick_correlate_layer (GimpImage *image,
|
||||||
gint x,
|
gint x,
|
||||||
gint y);
|
gint y);
|
||||||
gboolean gimp_image_insert_layer (GimpImage *image,
|
gboolean gimp_image_insert_layer (GimpImage *image,
|
||||||
GimpLayer *layer,
|
GimpLayer *layer,
|
||||||
GimpLayer *parent,
|
GimpLayer *parent,
|
||||||
gint position);
|
gint position);
|
||||||
gboolean gimp_image_remove_layer (GimpImage *image,
|
gboolean gimp_image_remove_layer (GimpImage *image,
|
||||||
GimpLayer *layer);
|
GimpLayer *layer);
|
||||||
gboolean gimp_image_freeze_layers (GimpImage *image);
|
gboolean gimp_image_freeze_layers (GimpImage *image);
|
||||||
gboolean gimp_image_thaw_layers (GimpImage *image);
|
gboolean gimp_image_thaw_layers (GimpImage *image);
|
||||||
gboolean gimp_image_insert_channel (GimpImage *image,
|
gboolean gimp_image_insert_channel (GimpImage *image,
|
||||||
GimpChannel *channel,
|
GimpChannel *channel,
|
||||||
GimpChannel *parent,
|
GimpChannel *parent,
|
||||||
gint position);
|
gint position);
|
||||||
gboolean gimp_image_remove_channel (GimpImage *image,
|
gboolean gimp_image_remove_channel (GimpImage *image,
|
||||||
GimpChannel *channel);
|
GimpChannel *channel);
|
||||||
gboolean gimp_image_freeze_channels (GimpImage *image);
|
gboolean gimp_image_freeze_channels (GimpImage *image);
|
||||||
gboolean gimp_image_thaw_channels (GimpImage *image);
|
gboolean gimp_image_thaw_channels (GimpImage *image);
|
||||||
gboolean gimp_image_insert_path (GimpImage *image,
|
gboolean gimp_image_insert_path (GimpImage *image,
|
||||||
GimpPath *path,
|
GimpPath *path,
|
||||||
GimpPath *parent,
|
GimpPath *parent,
|
||||||
gint position);
|
gint position);
|
||||||
gboolean gimp_image_remove_path (GimpImage *image,
|
gboolean gimp_image_remove_path (GimpImage *image,
|
||||||
GimpPath *path);
|
GimpPath *path);
|
||||||
gboolean gimp_image_freeze_paths (GimpImage *image);
|
gboolean gimp_image_import_paths_from_file (GimpImage *image,
|
||||||
gboolean gimp_image_thaw_paths (GimpImage *image);
|
GFile *file,
|
||||||
gint gimp_image_get_item_position (GimpImage *image,
|
gboolean merge,
|
||||||
GimpItem *item);
|
gboolean scale,
|
||||||
gboolean gimp_image_raise_item (GimpImage *image,
|
gint *num_paths,
|
||||||
GimpItem *item);
|
GimpPath ***path);
|
||||||
gboolean gimp_image_lower_item (GimpImage *image,
|
gboolean gimp_image_import_paths_from_string (GimpImage *image,
|
||||||
GimpItem *item);
|
const gchar *string,
|
||||||
gboolean gimp_image_raise_item_to_top (GimpImage *image,
|
gint length,
|
||||||
GimpItem *item);
|
gboolean merge,
|
||||||
gboolean gimp_image_lower_item_to_bottom (GimpImage *image,
|
gboolean scale,
|
||||||
GimpItem *item);
|
gint *num_paths,
|
||||||
gboolean gimp_image_reorder_item (GimpImage *image,
|
GimpPath ***path);
|
||||||
GimpItem *item,
|
gboolean gimp_image_export_path_to_file (GimpImage *image,
|
||||||
GimpItem *parent,
|
GFile *file,
|
||||||
gint position);
|
GimpPath *path);
|
||||||
GimpLayer* gimp_image_flatten (GimpImage *image);
|
gchar* gimp_image_export_path_to_string (GimpImage *image,
|
||||||
GimpLayer* gimp_image_merge_visible_layers (GimpImage *image,
|
GimpPath *path);
|
||||||
GimpMergeType merge_type);
|
gboolean gimp_image_freeze_paths (GimpImage *image);
|
||||||
GimpLayer* gimp_image_merge_down (GimpImage *image,
|
gboolean gimp_image_thaw_paths (GimpImage *image);
|
||||||
GimpLayer *merge_layer,
|
gint gimp_image_get_item_position (GimpImage *image,
|
||||||
GimpMergeType merge_type);
|
GimpItem *item);
|
||||||
G_GNUC_INTERNAL GBytes* _gimp_image_get_colormap (GimpImage *image);
|
gboolean gimp_image_raise_item (GimpImage *image,
|
||||||
G_GNUC_INTERNAL gboolean _gimp_image_set_colormap (GimpImage *image,
|
GimpItem *item);
|
||||||
GBytes *colormap);
|
gboolean gimp_image_lower_item (GimpImage *image,
|
||||||
GimpPalette* gimp_image_get_palette (GimpImage *image);
|
GimpItem *item);
|
||||||
G_GNUC_INTERNAL gchar* _gimp_image_get_metadata (GimpImage *image);
|
gboolean gimp_image_raise_item_to_top (GimpImage *image,
|
||||||
G_GNUC_INTERNAL gboolean _gimp_image_set_metadata (GimpImage *image,
|
GimpItem *item);
|
||||||
const gchar *metadata_string);
|
gboolean gimp_image_lower_item_to_bottom (GimpImage *image,
|
||||||
gboolean gimp_image_clean_all (GimpImage *image);
|
GimpItem *item);
|
||||||
gboolean gimp_image_is_dirty (GimpImage *image);
|
gboolean gimp_image_reorder_item (GimpImage *image,
|
||||||
G_GNUC_INTERNAL gboolean _gimp_image_thumbnail (GimpImage *image,
|
GimpItem *item,
|
||||||
gint width,
|
GimpItem *parent,
|
||||||
gint height,
|
gint position);
|
||||||
gint *actual_width,
|
GimpLayer* gimp_image_flatten (GimpImage *image);
|
||||||
gint *actual_height,
|
GimpLayer* gimp_image_merge_visible_layers (GimpImage *image,
|
||||||
gint *bpp,
|
GimpMergeType merge_type);
|
||||||
GBytes **thumbnail_data);
|
GimpLayer* gimp_image_merge_down (GimpImage *image,
|
||||||
GimpLayer** gimp_image_get_selected_layers (GimpImage *image,
|
GimpLayer *merge_layer,
|
||||||
gint *num_layers);
|
GimpMergeType merge_type);
|
||||||
gboolean gimp_image_set_selected_layers (GimpImage *image,
|
G_GNUC_INTERNAL GBytes* _gimp_image_get_colormap (GimpImage *image);
|
||||||
gint num_layers,
|
G_GNUC_INTERNAL gboolean _gimp_image_set_colormap (GimpImage *image,
|
||||||
const GimpLayer **layers);
|
GBytes *colormap);
|
||||||
GimpChannel** gimp_image_get_selected_channels (GimpImage *image,
|
GimpPalette* gimp_image_get_palette (GimpImage *image);
|
||||||
gint *num_channels);
|
G_GNUC_INTERNAL gchar* _gimp_image_get_metadata (GimpImage *image);
|
||||||
gboolean gimp_image_set_selected_channels (GimpImage *image,
|
G_GNUC_INTERNAL gboolean _gimp_image_set_metadata (GimpImage *image,
|
||||||
gint num_channels,
|
const gchar *metadata_string);
|
||||||
const GimpChannel **channels);
|
gboolean gimp_image_clean_all (GimpImage *image);
|
||||||
GimpPath** gimp_image_get_selected_paths (GimpImage *image,
|
gboolean gimp_image_is_dirty (GimpImage *image);
|
||||||
gint *num_paths);
|
G_GNUC_INTERNAL gboolean _gimp_image_thumbnail (GimpImage *image,
|
||||||
gboolean gimp_image_set_selected_paths (GimpImage *image,
|
gint width,
|
||||||
gint num_paths,
|
gint height,
|
||||||
const GimpPath **paths);
|
gint *actual_width,
|
||||||
GimpItem** gimp_image_get_selected_drawables (GimpImage *image,
|
gint *actual_height,
|
||||||
gint *num_drawables);
|
gint *bpp,
|
||||||
GimpSelection* gimp_image_get_selection (GimpImage *image);
|
GBytes **thumbnail_data);
|
||||||
gboolean gimp_image_get_component_active (GimpImage *image,
|
GimpLayer** gimp_image_get_selected_layers (GimpImage *image,
|
||||||
GimpChannelType component);
|
gint *num_layers);
|
||||||
gboolean gimp_image_set_component_active (GimpImage *image,
|
gboolean gimp_image_set_selected_layers (GimpImage *image,
|
||||||
GimpChannelType component,
|
gint num_layers,
|
||||||
gboolean active);
|
const GimpLayer **layers);
|
||||||
gboolean gimp_image_get_component_visible (GimpImage *image,
|
GimpChannel** gimp_image_get_selected_channels (GimpImage *image,
|
||||||
GimpChannelType component);
|
gint *num_channels);
|
||||||
gboolean gimp_image_set_component_visible (GimpImage *image,
|
gboolean gimp_image_set_selected_channels (GimpImage *image,
|
||||||
GimpChannelType component,
|
gint num_channels,
|
||||||
gboolean visible);
|
const GimpChannel **channels);
|
||||||
GFile* gimp_image_get_file (GimpImage *image);
|
GimpPath** gimp_image_get_selected_paths (GimpImage *image,
|
||||||
gboolean gimp_image_set_file (GimpImage *image,
|
gint *num_paths);
|
||||||
GFile *file);
|
gboolean gimp_image_set_selected_paths (GimpImage *image,
|
||||||
GFile* gimp_image_get_xcf_file (GimpImage *image);
|
gint num_paths,
|
||||||
GFile* gimp_image_get_imported_file (GimpImage *image);
|
const GimpPath **paths);
|
||||||
GFile* gimp_image_get_exported_file (GimpImage *image);
|
GimpItem** gimp_image_get_selected_drawables (GimpImage *image,
|
||||||
gchar* gimp_image_get_name (GimpImage *image);
|
gint *num_drawables);
|
||||||
gboolean gimp_image_get_resolution (GimpImage *image,
|
GimpSelection* gimp_image_get_selection (GimpImage *image);
|
||||||
gdouble *xresolution,
|
gboolean gimp_image_get_component_active (GimpImage *image,
|
||||||
gdouble *yresolution);
|
GimpChannelType component);
|
||||||
gboolean gimp_image_set_resolution (GimpImage *image,
|
gboolean gimp_image_set_component_active (GimpImage *image,
|
||||||
gdouble xresolution,
|
GimpChannelType component,
|
||||||
gdouble yresolution);
|
gboolean active);
|
||||||
GimpUnit* gimp_image_get_unit (GimpImage *image);
|
gboolean gimp_image_get_component_visible (GimpImage *image,
|
||||||
gboolean gimp_image_set_unit (GimpImage *image,
|
GimpChannelType component);
|
||||||
GimpUnit *unit);
|
gboolean gimp_image_set_component_visible (GimpImage *image,
|
||||||
guint gimp_image_get_tattoo_state (GimpImage *image);
|
GimpChannelType component,
|
||||||
gboolean gimp_image_set_tattoo_state (GimpImage *image,
|
gboolean visible);
|
||||||
guint tattoo_state);
|
GFile* gimp_image_get_file (GimpImage *image);
|
||||||
GimpLayer* gimp_image_get_layer_by_tattoo (GimpImage *image,
|
gboolean gimp_image_set_file (GimpImage *image,
|
||||||
guint tattoo);
|
GFile *file);
|
||||||
GimpChannel* gimp_image_get_channel_by_tattoo (GimpImage *image,
|
GFile* gimp_image_get_xcf_file (GimpImage *image);
|
||||||
guint tattoo);
|
GFile* gimp_image_get_imported_file (GimpImage *image);
|
||||||
GimpPath* gimp_image_get_path_by_tattoo (GimpImage *image,
|
GFile* gimp_image_get_exported_file (GimpImage *image);
|
||||||
guint tattoo);
|
gchar* gimp_image_get_name (GimpImage *image);
|
||||||
GimpLayer* gimp_image_get_layer_by_name (GimpImage *image,
|
gboolean gimp_image_get_resolution (GimpImage *image,
|
||||||
const gchar *name);
|
gdouble *xresolution,
|
||||||
GimpChannel* gimp_image_get_channel_by_name (GimpImage *image,
|
gdouble *yresolution);
|
||||||
const gchar *name);
|
gboolean gimp_image_set_resolution (GimpImage *image,
|
||||||
GimpPath* gimp_image_get_path_by_name (GimpImage *image,
|
gdouble xresolution,
|
||||||
const gchar *name);
|
gdouble yresolution);
|
||||||
gboolean gimp_image_attach_parasite (GimpImage *image,
|
GimpUnit* gimp_image_get_unit (GimpImage *image);
|
||||||
const GimpParasite *parasite);
|
gboolean gimp_image_set_unit (GimpImage *image,
|
||||||
gboolean gimp_image_detach_parasite (GimpImage *image,
|
GimpUnit *unit);
|
||||||
const gchar *name);
|
guint gimp_image_get_tattoo_state (GimpImage *image);
|
||||||
GimpParasite* gimp_image_get_parasite (GimpImage *image,
|
gboolean gimp_image_set_tattoo_state (GimpImage *image,
|
||||||
const gchar *name);
|
guint tattoo_state);
|
||||||
gchar** gimp_image_get_parasite_list (GimpImage *image);
|
GimpLayer* gimp_image_get_layer_by_tattoo (GimpImage *image,
|
||||||
gboolean gimp_image_policy_rotate (GimpImage *image,
|
guint tattoo);
|
||||||
gboolean interactive);
|
GimpChannel* gimp_image_get_channel_by_tattoo (GimpImage *image,
|
||||||
gboolean gimp_image_policy_color_profile (GimpImage *image,
|
guint tattoo);
|
||||||
gboolean interactive);
|
GimpPath* gimp_image_get_path_by_tattoo (GimpImage *image,
|
||||||
|
guint tattoo);
|
||||||
|
GimpLayer* gimp_image_get_layer_by_name (GimpImage *image,
|
||||||
|
const gchar *name);
|
||||||
|
GimpChannel* gimp_image_get_channel_by_name (GimpImage *image,
|
||||||
|
const gchar *name);
|
||||||
|
GimpPath* gimp_image_get_path_by_name (GimpImage *image,
|
||||||
|
const gchar *name);
|
||||||
|
gboolean gimp_image_attach_parasite (GimpImage *image,
|
||||||
|
const GimpParasite *parasite);
|
||||||
|
gboolean gimp_image_detach_parasite (GimpImage *image,
|
||||||
|
const gchar *name);
|
||||||
|
GimpParasite* gimp_image_get_parasite (GimpImage *image,
|
||||||
|
const gchar *name);
|
||||||
|
gchar** gimp_image_get_parasite_list (GimpImage *image);
|
||||||
|
gboolean gimp_image_policy_rotate (GimpImage *image,
|
||||||
|
gboolean interactive);
|
||||||
|
gboolean gimp_image_policy_color_profile (GimpImage *image,
|
||||||
|
gboolean interactive);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -1065,211 +1065,3 @@ gimp_path_bezier_stroke_new_ellipse (GimpPath *path,
|
||||||
|
|
||||||
return stroke_id;
|
return stroke_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_path_import_from_file:
|
|
||||||
* @image: The image.
|
|
||||||
* @file: The SVG file to import.
|
|
||||||
* @merge: Merge paths into a single path object.
|
|
||||||
* @scale: Scale the SVG to image dimensions.
|
|
||||||
* @num_paths: (out): The number of newly created path.
|
|
||||||
* @path: (out) (array length=num_paths) (element-type GimpPath) (transfer container): The list of newly created path.
|
|
||||||
*
|
|
||||||
* Import paths from an SVG file.
|
|
||||||
*
|
|
||||||
* This procedure imports paths from an SVG file. SVG elements other
|
|
||||||
* than paths and basic shapes are ignored.
|
|
||||||
*
|
|
||||||
* Returns: TRUE on success.
|
|
||||||
*
|
|
||||||
* Since: 2.4
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gimp_path_import_from_file (GimpImage *image,
|
|
||||||
GFile *file,
|
|
||||||
gboolean merge,
|
|
||||||
gboolean scale,
|
|
||||||
gint *num_paths,
|
|
||||||
GimpPath ***path)
|
|
||||||
{
|
|
||||||
GimpValueArray *args;
|
|
||||||
GimpValueArray *return_vals;
|
|
||||||
gboolean success = TRUE;
|
|
||||||
|
|
||||||
args = gimp_value_array_new_from_types (NULL,
|
|
||||||
GIMP_TYPE_IMAGE, image,
|
|
||||||
G_TYPE_FILE, file,
|
|
||||||
G_TYPE_BOOLEAN, merge,
|
|
||||||
G_TYPE_BOOLEAN, scale,
|
|
||||||
G_TYPE_NONE);
|
|
||||||
|
|
||||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
||||||
"gimp-path-import-from-file",
|
|
||||||
args);
|
|
||||||
gimp_value_array_unref (args);
|
|
||||||
|
|
||||||
*num_paths = 0;
|
|
||||||
*path = NULL;
|
|
||||||
|
|
||||||
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
*num_paths = GIMP_VALUES_GET_INT (return_vals, 1);
|
|
||||||
{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index (return_vals, 2)); if (a) *path = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_value_array_unref (return_vals);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_path_import_from_string:
|
|
||||||
* @image: The image.
|
|
||||||
* @string: A string that must be a complete and valid SVG document.
|
|
||||||
* @length: Number of bytes in string or -1 if the string is NULL terminated.
|
|
||||||
* @merge: Merge paths into a single path object.
|
|
||||||
* @scale: Scale the SVG to image dimensions.
|
|
||||||
* @num_paths: (out): The number of newly created path.
|
|
||||||
* @path: (out) (array length=num_paths) (element-type GimpPath) (transfer container): The list of newly created path.
|
|
||||||
*
|
|
||||||
* Import paths from an SVG string.
|
|
||||||
*
|
|
||||||
* This procedure works like gimp_path_import_from_file() but takes a
|
|
||||||
* string rather than reading the SVG from a file. This allows you to
|
|
||||||
* write scripts that generate SVG and feed it to GIMP.
|
|
||||||
*
|
|
||||||
* Returns: TRUE on success.
|
|
||||||
*
|
|
||||||
* Since: 2.4
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gimp_path_import_from_string (GimpImage *image,
|
|
||||||
const gchar *string,
|
|
||||||
gint length,
|
|
||||||
gboolean merge,
|
|
||||||
gboolean scale,
|
|
||||||
gint *num_paths,
|
|
||||||
GimpPath ***path)
|
|
||||||
{
|
|
||||||
GimpValueArray *args;
|
|
||||||
GimpValueArray *return_vals;
|
|
||||||
gboolean success = TRUE;
|
|
||||||
|
|
||||||
args = gimp_value_array_new_from_types (NULL,
|
|
||||||
GIMP_TYPE_IMAGE, image,
|
|
||||||
G_TYPE_STRING, string,
|
|
||||||
G_TYPE_INT, length,
|
|
||||||
G_TYPE_BOOLEAN, merge,
|
|
||||||
G_TYPE_BOOLEAN, scale,
|
|
||||||
G_TYPE_NONE);
|
|
||||||
|
|
||||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
||||||
"gimp-path-import-from-string",
|
|
||||||
args);
|
|
||||||
gimp_value_array_unref (args);
|
|
||||||
|
|
||||||
*num_paths = 0;
|
|
||||||
*path = NULL;
|
|
||||||
|
|
||||||
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
*num_paths = GIMP_VALUES_GET_INT (return_vals, 1);
|
|
||||||
{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index (return_vals, 2)); if (a) *path = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_value_array_unref (return_vals);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_path_export_to_file:
|
|
||||||
* @image: The image.
|
|
||||||
* @file: The SVG file to create.
|
|
||||||
* @path: (nullable): The path object to export, or %NULL for all in the image.
|
|
||||||
*
|
|
||||||
* save a path as an SVG file.
|
|
||||||
*
|
|
||||||
* This procedure creates an SVG file to save a Path object, that is, a
|
|
||||||
* path. The resulting file can be edited using a vector graphics
|
|
||||||
* application, or later reloaded into GIMP. Pass %NULL as the 'path'
|
|
||||||
* argument to export all paths in the image.
|
|
||||||
*
|
|
||||||
* Returns: TRUE on success.
|
|
||||||
*
|
|
||||||
* Since: 2.6
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gimp_path_export_to_file (GimpImage *image,
|
|
||||||
GFile *file,
|
|
||||||
GimpPath *path)
|
|
||||||
{
|
|
||||||
GimpValueArray *args;
|
|
||||||
GimpValueArray *return_vals;
|
|
||||||
gboolean success = TRUE;
|
|
||||||
|
|
||||||
args = gimp_value_array_new_from_types (NULL,
|
|
||||||
GIMP_TYPE_IMAGE, image,
|
|
||||||
G_TYPE_FILE, file,
|
|
||||||
GIMP_TYPE_PATH, path,
|
|
||||||
G_TYPE_NONE);
|
|
||||||
|
|
||||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
||||||
"gimp-path-export-to-file",
|
|
||||||
args);
|
|
||||||
gimp_value_array_unref (args);
|
|
||||||
|
|
||||||
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
|
||||||
|
|
||||||
gimp_value_array_unref (return_vals);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_path_export_to_string:
|
|
||||||
* @image: The image.
|
|
||||||
* @path: (nullable): The path object to export, or %NULL for all in the image.
|
|
||||||
*
|
|
||||||
* Save a path as an SVG string.
|
|
||||||
*
|
|
||||||
* This procedure works like gimp_path_export_to_file() but creates a
|
|
||||||
* string rather than a file. The string is NULL-terminated and holds a
|
|
||||||
* complete XML document. Pass %NULL as the 'path' argument to export
|
|
||||||
* all paths in the image.
|
|
||||||
*
|
|
||||||
* Returns: (transfer full):
|
|
||||||
* A string whose contents are a complete SVG document.
|
|
||||||
* The returned value must be freed with g_free().
|
|
||||||
*
|
|
||||||
* Since: 2.6
|
|
||||||
**/
|
|
||||||
gchar *
|
|
||||||
gimp_path_export_to_string (GimpImage *image,
|
|
||||||
GimpPath *path)
|
|
||||||
{
|
|
||||||
GimpValueArray *args;
|
|
||||||
GimpValueArray *return_vals;
|
|
||||||
gchar *string = NULL;
|
|
||||||
|
|
||||||
args = gimp_value_array_new_from_types (NULL,
|
|
||||||
GIMP_TYPE_IMAGE, image,
|
|
||||||
GIMP_TYPE_PATH, path,
|
|
||||||
G_TYPE_NONE);
|
|
||||||
|
|
||||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
|
||||||
"gimp-path-export-to-string",
|
|
||||||
args);
|
|
||||||
gimp_value_array_unref (args);
|
|
||||||
|
|
||||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
|
||||||
string = GIMP_VALUES_DUP_STRING (return_vals, 1);
|
|
||||||
|
|
||||||
gimp_value_array_unref (return_vals);
|
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
|
@ -32,113 +32,95 @@ 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 */
|
||||||
|
|
||||||
|
|
||||||
GimpPath* gimp_path_new (GimpImage *image,
|
GimpPath* gimp_path_new (GimpImage *image,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
GimpPath* gimp_path_new_from_text_layer (GimpImage *image,
|
GimpPath* gimp_path_new_from_text_layer (GimpImage *image,
|
||||||
GimpLayer *layer);
|
GimpLayer *layer);
|
||||||
GimpPath* gimp_path_copy (GimpPath *path);
|
GimpPath* gimp_path_copy (GimpPath *path);
|
||||||
gint* gimp_path_get_strokes (GimpPath *path,
|
gint* gimp_path_get_strokes (GimpPath *path,
|
||||||
gint *num_strokes);
|
gint *num_strokes);
|
||||||
gdouble gimp_path_stroke_get_length (GimpPath *path,
|
gdouble gimp_path_stroke_get_length (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble precision);
|
gdouble precision);
|
||||||
gboolean gimp_path_stroke_get_point_at_dist (GimpPath *path,
|
gboolean gimp_path_stroke_get_point_at_dist (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble dist,
|
gdouble dist,
|
||||||
gdouble precision,
|
gdouble precision,
|
||||||
gdouble *x_point,
|
gdouble *x_point,
|
||||||
gdouble *y_point,
|
gdouble *y_point,
|
||||||
gdouble *slope,
|
gdouble *slope,
|
||||||
gboolean *valid);
|
gboolean *valid);
|
||||||
gboolean gimp_path_remove_stroke (GimpPath *path,
|
gboolean gimp_path_remove_stroke (GimpPath *path,
|
||||||
gint stroke_id);
|
gint stroke_id);
|
||||||
gboolean gimp_path_stroke_close (GimpPath *path,
|
gboolean gimp_path_stroke_close (GimpPath *path,
|
||||||
gint stroke_id);
|
gint stroke_id);
|
||||||
gboolean gimp_path_stroke_reverse (GimpPath *path,
|
gboolean gimp_path_stroke_reverse (GimpPath *path,
|
||||||
gint stroke_id);
|
gint stroke_id);
|
||||||
gboolean gimp_path_stroke_translate (GimpPath *path,
|
gboolean gimp_path_stroke_translate (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble off_x,
|
gdouble off_x,
|
||||||
gdouble off_y);
|
gdouble off_y);
|
||||||
gboolean gimp_path_stroke_scale (GimpPath *path,
|
gboolean gimp_path_stroke_scale (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble scale_x,
|
gdouble scale_x,
|
||||||
gdouble scale_y);
|
gdouble scale_y);
|
||||||
gboolean gimp_path_stroke_rotate (GimpPath *path,
|
gboolean gimp_path_stroke_rotate (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble center_x,
|
gdouble center_x,
|
||||||
gdouble center_y,
|
gdouble center_y,
|
||||||
gdouble angle);
|
gdouble angle);
|
||||||
gboolean gimp_path_stroke_flip (GimpPath *path,
|
gboolean gimp_path_stroke_flip (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
GimpOrientationType flip_type,
|
GimpOrientationType flip_type,
|
||||||
gdouble axis);
|
gdouble axis);
|
||||||
gboolean gimp_path_stroke_flip_free (GimpPath *path,
|
gboolean gimp_path_stroke_flip_free (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble x1,
|
gdouble x1,
|
||||||
gdouble y1,
|
gdouble y1,
|
||||||
gdouble x2,
|
gdouble x2,
|
||||||
gdouble y2);
|
gdouble y2);
|
||||||
GimpPathStrokeType gimp_path_stroke_get_points (GimpPath *path,
|
GimpPathStrokeType gimp_path_stroke_get_points (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gint *num_points,
|
gint *num_points,
|
||||||
gdouble **controlpoints,
|
gdouble **controlpoints,
|
||||||
gboolean *closed);
|
gboolean *closed);
|
||||||
gint gimp_path_stroke_new_from_points (GimpPath *path,
|
gint gimp_path_stroke_new_from_points (GimpPath *path,
|
||||||
GimpPathStrokeType type,
|
GimpPathStrokeType type,
|
||||||
gint num_points,
|
gint num_points,
|
||||||
const gdouble *controlpoints,
|
const gdouble *controlpoints,
|
||||||
gboolean closed);
|
gboolean closed);
|
||||||
gdouble* gimp_path_stroke_interpolate (GimpPath *path,
|
gdouble* gimp_path_stroke_interpolate (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble precision,
|
gdouble precision,
|
||||||
gint *num_coords,
|
gint *num_coords,
|
||||||
gboolean *closed);
|
gboolean *closed);
|
||||||
gint gimp_path_bezier_stroke_new_moveto (GimpPath *path,
|
gint gimp_path_bezier_stroke_new_moveto (GimpPath *path,
|
||||||
gdouble x0,
|
gdouble x0,
|
||||||
gdouble y0);
|
gdouble y0);
|
||||||
gboolean gimp_path_bezier_stroke_lineto (GimpPath *path,
|
gboolean gimp_path_bezier_stroke_lineto (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble x0,
|
gdouble x0,
|
||||||
gdouble y0);
|
gdouble y0);
|
||||||
gboolean gimp_path_bezier_stroke_conicto (GimpPath *path,
|
gboolean gimp_path_bezier_stroke_conicto (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble x0,
|
gdouble x0,
|
||||||
gdouble y0,
|
gdouble y0,
|
||||||
gdouble x1,
|
gdouble x1,
|
||||||
gdouble y1);
|
gdouble y1);
|
||||||
gboolean gimp_path_bezier_stroke_cubicto (GimpPath *path,
|
gboolean gimp_path_bezier_stroke_cubicto (GimpPath *path,
|
||||||
gint stroke_id,
|
gint stroke_id,
|
||||||
gdouble x0,
|
gdouble x0,
|
||||||
gdouble y0,
|
gdouble y0,
|
||||||
gdouble x1,
|
gdouble x1,
|
||||||
gdouble y1,
|
gdouble y1,
|
||||||
gdouble x2,
|
gdouble x2,
|
||||||
gdouble y2);
|
gdouble y2);
|
||||||
gint gimp_path_bezier_stroke_new_ellipse (GimpPath *path,
|
gint gimp_path_bezier_stroke_new_ellipse (GimpPath *path,
|
||||||
gdouble x0,
|
gdouble x0,
|
||||||
gdouble y0,
|
gdouble y0,
|
||||||
gdouble radius_x,
|
gdouble radius_x,
|
||||||
gdouble radius_y,
|
gdouble radius_y,
|
||||||
gdouble angle);
|
gdouble angle);
|
||||||
gboolean gimp_path_import_from_file (GimpImage *image,
|
|
||||||
GFile *file,
|
|
||||||
gboolean merge,
|
|
||||||
gboolean scale,
|
|
||||||
gint *num_paths,
|
|
||||||
GimpPath ***path);
|
|
||||||
gboolean gimp_path_import_from_string (GimpImage *image,
|
|
||||||
const gchar *string,
|
|
||||||
gint length,
|
|
||||||
gboolean merge,
|
|
||||||
gboolean scale,
|
|
||||||
gint *num_paths,
|
|
||||||
GimpPath ***path);
|
|
||||||
gboolean gimp_path_export_to_file (GimpImage *image,
|
|
||||||
GFile *file,
|
|
||||||
GimpPath *path);
|
|
||||||
gchar* gimp_path_export_to_string (GimpImage *image,
|
|
||||||
GimpPath *path);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -1283,6 +1283,222 @@ CODE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub image_import_paths_from_file {
|
||||||
|
$blurb = 'Import paths from an SVG file.';
|
||||||
|
|
||||||
|
$help = <<'HELP';
|
||||||
|
This procedure imports paths from an SVG file. SVG elements other than
|
||||||
|
paths and basic shapes are ignored.
|
||||||
|
HELP
|
||||||
|
|
||||||
|
&simon_pdb_misc('2006', '2.4');
|
||||||
|
|
||||||
|
@inargs = (
|
||||||
|
{ name => 'image', type => 'image',
|
||||||
|
desc => 'The image' },
|
||||||
|
{ name => 'file', type => 'file',
|
||||||
|
desc => 'The SVG file to import.' },
|
||||||
|
{ name => 'merge', type => 'boolean',
|
||||||
|
desc => 'Merge paths into a single path object.' },
|
||||||
|
{ name => 'scale', type => 'boolean',
|
||||||
|
desc => 'Scale the SVG to image dimensions.' }
|
||||||
|
);
|
||||||
|
|
||||||
|
@outargs = (
|
||||||
|
{ name => 'path', type => 'patharray', void_ret => 1,
|
||||||
|
desc => 'The list of newly created path',
|
||||||
|
array => { name => 'num_paths',
|
||||||
|
desc => 'The number of newly created path' } }
|
||||||
|
);
|
||||||
|
|
||||||
|
%invoke = (
|
||||||
|
headers => [ qw("vectors/gimppath-import.h") ],
|
||||||
|
code => <<'CODE'
|
||||||
|
{
|
||||||
|
GList *path_list = NULL;
|
||||||
|
|
||||||
|
/* FIXME tree */
|
||||||
|
success = gimp_path_import_file (image, file,
|
||||||
|
merge, scale, NULL, -1,
|
||||||
|
&path_list, error);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
num_paths = g_list_length (path_list);
|
||||||
|
|
||||||
|
if (num_paths)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
path = g_new (GimpPath *, num_paths);
|
||||||
|
|
||||||
|
for (i = 0, list = path_list;
|
||||||
|
i < num_paths;
|
||||||
|
i++, list = g_list_next (list))
|
||||||
|
{
|
||||||
|
path[i] = g_object_ref (list->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (path_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub image_import_paths_from_string {
|
||||||
|
$blurb = 'Import paths from an SVG string.';
|
||||||
|
|
||||||
|
$help = <<'HELP';
|
||||||
|
This procedure works like [method@Gimp.Image.import_paths_from_file] but takes a string
|
||||||
|
rather than reading the SVG from a file. This allows you to write scripts that
|
||||||
|
generate SVG and feed it to GIMP.
|
||||||
|
HELP
|
||||||
|
|
||||||
|
&simon_pdb_misc('2006', '2.4');
|
||||||
|
|
||||||
|
@inargs = (
|
||||||
|
{ name => 'image', type => 'image',
|
||||||
|
desc => 'The image' },
|
||||||
|
{ name => 'string', type => 'string', allow_non_utf8 => 1,
|
||||||
|
desc => 'A string that must be a complete and valid SVG document.' },
|
||||||
|
{ name => 'length', type => 'int32',
|
||||||
|
desc => 'Number of bytes in string or -1 if the string is NULL
|
||||||
|
terminated.' },
|
||||||
|
{ name => 'merge', type => 'boolean',
|
||||||
|
desc => 'Merge paths into a single path object.' },
|
||||||
|
{ name => 'scale', type => 'boolean',
|
||||||
|
desc => 'Scale the SVG to image dimensions.' }
|
||||||
|
);
|
||||||
|
|
||||||
|
@outargs = (
|
||||||
|
{ name => 'path', type => 'patharray', void_ret => 1,
|
||||||
|
desc => 'The list of newly created path',
|
||||||
|
array => { name => 'num_paths',
|
||||||
|
desc => 'The number of newly created path' } }
|
||||||
|
);
|
||||||
|
|
||||||
|
%invoke = (
|
||||||
|
headers => [ qw("vectors/gimppath-import.h") ],
|
||||||
|
code => <<'CODE'
|
||||||
|
{
|
||||||
|
GList *path_list = NULL;
|
||||||
|
|
||||||
|
/* FIXME tree */
|
||||||
|
success = gimp_path_import_buffer (image, string, length,
|
||||||
|
merge, scale, NULL, -1,
|
||||||
|
&path_list, error);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
num_paths = g_list_length (path_list);
|
||||||
|
|
||||||
|
if (num_paths)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
path = g_new (GimpPath *, num_paths);
|
||||||
|
|
||||||
|
for (i = 0, list = path_list;
|
||||||
|
i < num_paths;
|
||||||
|
i++, list = g_list_next (list))
|
||||||
|
{
|
||||||
|
path[i] = g_object_ref (list->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (path_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub image_export_path_to_file {
|
||||||
|
$blurb = 'save a path as an SVG file.';
|
||||||
|
|
||||||
|
$help = <<'HELP';
|
||||||
|
This procedure creates an SVG file to save a Path object, that is,
|
||||||
|
a path. The resulting file can be edited using a vector graphics
|
||||||
|
application, or later reloaded into GIMP. Pass %NULL as the 'path'
|
||||||
|
argument to export all paths in the image.
|
||||||
|
HELP
|
||||||
|
|
||||||
|
&bill_pdb_misc('2007', '2.6');
|
||||||
|
|
||||||
|
@inargs = (
|
||||||
|
{ name => 'image', type => 'image',
|
||||||
|
desc => 'The image' },
|
||||||
|
{ name => 'file', type => 'file',
|
||||||
|
desc => 'The SVG file to create.' },
|
||||||
|
{ name => 'path', type => 'path',
|
||||||
|
no_validate => 1, none_ok => 1,
|
||||||
|
desc => 'The path object to export, or %NULL for all in the image' }
|
||||||
|
);
|
||||||
|
|
||||||
|
%invoke = (
|
||||||
|
headers => [ qw("vectors/gimppath-export.h") ],
|
||||||
|
code => <<'CODE'
|
||||||
|
{
|
||||||
|
GList *path_list = NULL;
|
||||||
|
|
||||||
|
if (path != NULL)
|
||||||
|
path_list = g_list_prepend (path_list, path);
|
||||||
|
|
||||||
|
success = gimp_path_export_file (image, path_list, file, error);
|
||||||
|
|
||||||
|
g_list_free (path_list);
|
||||||
|
}
|
||||||
|
CODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub image_export_path_to_string {
|
||||||
|
$blurb = 'Save a path as an SVG string.';
|
||||||
|
|
||||||
|
$help = <<'HELP';
|
||||||
|
This procedure works like [method@Gimp.Image.export_path_to_file] but creates a string
|
||||||
|
rather than a file. The string is NULL-terminated and holds a
|
||||||
|
complete XML document. Pass %NULL as the 'path' argument to export
|
||||||
|
all paths in the image.
|
||||||
|
HELP
|
||||||
|
|
||||||
|
&bill_pdb_misc('2007', '2.6');
|
||||||
|
|
||||||
|
@inargs = (
|
||||||
|
{ name => 'image', type => 'image',
|
||||||
|
desc => 'The image' },
|
||||||
|
{ name => 'path', type => 'path',
|
||||||
|
no_validate => 1, none_ok => 1,
|
||||||
|
desc => 'The path object to export, or %NULL for all in the image' }
|
||||||
|
);
|
||||||
|
|
||||||
|
@outargs = (
|
||||||
|
{ name => 'string', type => 'string',
|
||||||
|
desc => 'A string whose contents are a complete SVG document.' }
|
||||||
|
);
|
||||||
|
|
||||||
|
%invoke = (
|
||||||
|
headers => [ qw("vectors/gimppath-export.h") ],
|
||||||
|
code => <<'CODE'
|
||||||
|
{
|
||||||
|
GList *path_list = NULL;
|
||||||
|
|
||||||
|
if (path != NULL)
|
||||||
|
path_list = g_list_prepend (path_list, path);
|
||||||
|
|
||||||
|
string = gimp_path_export_string (image, path_list);
|
||||||
|
g_list_free (path_list);
|
||||||
|
|
||||||
|
success = (string != NULL);
|
||||||
|
}
|
||||||
|
CODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
sub image_freeze_paths {
|
sub image_freeze_paths {
|
||||||
$blurb = "Freeze the image's path list.";
|
$blurb = "Freeze the image's path list.";
|
||||||
|
|
||||||
|
@ -3174,6 +3390,10 @@ CODE
|
||||||
image_insert_channel image_remove_channel
|
image_insert_channel image_remove_channel
|
||||||
image_freeze_channels image_thaw_channels
|
image_freeze_channels image_thaw_channels
|
||||||
image_insert_path image_remove_path
|
image_insert_path image_remove_path
|
||||||
|
image_import_paths_from_file
|
||||||
|
image_import_paths_from_string
|
||||||
|
image_export_path_to_file
|
||||||
|
image_export_path_to_string
|
||||||
image_freeze_paths image_thaw_paths
|
image_freeze_paths image_thaw_paths
|
||||||
image_get_item_position
|
image_get_item_position
|
||||||
image_raise_item image_lower_item
|
image_raise_item image_lower_item
|
||||||
|
|
|
@ -1115,222 +1115,6 @@ CODE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub path_import_from_file {
|
|
||||||
$blurb = 'Import paths from an SVG file.';
|
|
||||||
|
|
||||||
$help = <<'HELP';
|
|
||||||
This procedure imports paths from an SVG file. SVG elements other than
|
|
||||||
paths and basic shapes are ignored.
|
|
||||||
HELP
|
|
||||||
|
|
||||||
&simon_pdb_misc('2006', '2.4');
|
|
||||||
|
|
||||||
@inargs = (
|
|
||||||
{ name => 'image', type => 'image',
|
|
||||||
desc => 'The image' },
|
|
||||||
{ name => 'file', type => 'file',
|
|
||||||
desc => 'The SVG file to import.' },
|
|
||||||
{ name => 'merge', type => 'boolean',
|
|
||||||
desc => 'Merge paths into a single path object.' },
|
|
||||||
{ name => 'scale', type => 'boolean',
|
|
||||||
desc => 'Scale the SVG to image dimensions.' }
|
|
||||||
);
|
|
||||||
|
|
||||||
@outargs = (
|
|
||||||
{ name => 'path', type => 'patharray', void_ret => 1,
|
|
||||||
desc => 'The list of newly created path',
|
|
||||||
array => { name => 'num_paths',
|
|
||||||
desc => 'The number of newly created path' } }
|
|
||||||
);
|
|
||||||
|
|
||||||
%invoke = (
|
|
||||||
headers => [ qw("vectors/gimppath-import.h") ],
|
|
||||||
code => <<'CODE'
|
|
||||||
{
|
|
||||||
GList *path_list = NULL;
|
|
||||||
|
|
||||||
/* FIXME tree */
|
|
||||||
success = gimp_path_import_file (image, file,
|
|
||||||
merge, scale, NULL, -1,
|
|
||||||
&path_list, error);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
num_paths = g_list_length (path_list);
|
|
||||||
|
|
||||||
if (num_paths)
|
|
||||||
{
|
|
||||||
GList *list;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
path = g_new (GimpPath *, num_paths);
|
|
||||||
|
|
||||||
for (i = 0, list = path_list;
|
|
||||||
i < num_paths;
|
|
||||||
i++, list = g_list_next (list))
|
|
||||||
{
|
|
||||||
path[i] = g_object_ref (list->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free (path_list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub path_import_from_string {
|
|
||||||
$blurb = 'Import paths from an SVG string.';
|
|
||||||
|
|
||||||
$help = <<'HELP';
|
|
||||||
This procedure works like gimp_path_import_from_file() but takes a string
|
|
||||||
rather than reading the SVG from a file. This allows you to write scripts that
|
|
||||||
generate SVG and feed it to GIMP.
|
|
||||||
HELP
|
|
||||||
|
|
||||||
&simon_pdb_misc('2006', '2.4');
|
|
||||||
|
|
||||||
@inargs = (
|
|
||||||
{ name => 'image', type => 'image',
|
|
||||||
desc => 'The image' },
|
|
||||||
{ name => 'string', type => 'string', allow_non_utf8 => 1,
|
|
||||||
desc => 'A string that must be a complete and valid SVG document.' },
|
|
||||||
{ name => 'length', type => 'int32',
|
|
||||||
desc => 'Number of bytes in string or -1 if the string is NULL
|
|
||||||
terminated.' },
|
|
||||||
{ name => 'merge', type => 'boolean',
|
|
||||||
desc => 'Merge paths into a single path object.' },
|
|
||||||
{ name => 'scale', type => 'boolean',
|
|
||||||
desc => 'Scale the SVG to image dimensions.' }
|
|
||||||
);
|
|
||||||
|
|
||||||
@outargs = (
|
|
||||||
{ name => 'path', type => 'patharray', void_ret => 1,
|
|
||||||
desc => 'The list of newly created path',
|
|
||||||
array => { name => 'num_paths',
|
|
||||||
desc => 'The number of newly created path' } }
|
|
||||||
);
|
|
||||||
|
|
||||||
%invoke = (
|
|
||||||
headers => [ qw("vectors/gimppath-import.h") ],
|
|
||||||
code => <<'CODE'
|
|
||||||
{
|
|
||||||
GList *path_list = NULL;
|
|
||||||
|
|
||||||
/* FIXME tree */
|
|
||||||
success = gimp_path_import_buffer (image, string, length,
|
|
||||||
merge, scale, NULL, -1,
|
|
||||||
&path_list, error);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
num_paths = g_list_length (path_list);
|
|
||||||
|
|
||||||
if (num_paths)
|
|
||||||
{
|
|
||||||
GList *list;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
path = g_new (GimpPath *, num_paths);
|
|
||||||
|
|
||||||
for (i = 0, list = path_list;
|
|
||||||
i < num_paths;
|
|
||||||
i++, list = g_list_next (list))
|
|
||||||
{
|
|
||||||
path[i] = g_object_ref (list->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_free (path_list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CODE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub path_export_to_file {
|
|
||||||
$blurb = 'save a path as an SVG file.';
|
|
||||||
|
|
||||||
$help = <<'HELP';
|
|
||||||
This procedure creates an SVG file to save a Path object, that is,
|
|
||||||
a path. The resulting file can be edited using a vector graphics
|
|
||||||
application, or later reloaded into GIMP. Pass %NULL as the 'path'
|
|
||||||
argument to export all paths in the image.
|
|
||||||
HELP
|
|
||||||
|
|
||||||
&bill_pdb_misc('2007', '2.6');
|
|
||||||
|
|
||||||
@inargs = (
|
|
||||||
{ name => 'image', type => 'image',
|
|
||||||
desc => 'The image' },
|
|
||||||
{ name => 'file', type => 'file',
|
|
||||||
desc => 'The SVG file to create.' },
|
|
||||||
{ name => 'path', type => 'path',
|
|
||||||
no_validate => 1, none_ok => 1,
|
|
||||||
desc => 'The path object to export, or %NULL for all in the image' }
|
|
||||||
);
|
|
||||||
|
|
||||||
%invoke = (
|
|
||||||
headers => [ qw("vectors/gimppath-export.h") ],
|
|
||||||
code => <<'CODE'
|
|
||||||
{
|
|
||||||
GList *path_list = NULL;
|
|
||||||
|
|
||||||
if (path != NULL)
|
|
||||||
path_list = g_list_prepend (path_list, path);
|
|
||||||
|
|
||||||
success = gimp_path_export_file (image, path_list, file, error);
|
|
||||||
|
|
||||||
g_list_free (path_list);
|
|
||||||
}
|
|
||||||
CODE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub path_export_to_string {
|
|
||||||
$blurb = 'Save a path as an SVG string.';
|
|
||||||
|
|
||||||
$help = <<'HELP';
|
|
||||||
This procedure works like gimp_path_export_to_file() but creates a string
|
|
||||||
rather than a file. The string is NULL-terminated and holds a
|
|
||||||
complete XML document. Pass %NULL as the 'path' argument to export
|
|
||||||
all paths in the image.
|
|
||||||
HELP
|
|
||||||
|
|
||||||
&bill_pdb_misc('2007', '2.6');
|
|
||||||
|
|
||||||
@inargs = (
|
|
||||||
{ name => 'image', type => 'image',
|
|
||||||
desc => 'The image' },
|
|
||||||
{ name => 'path', type => 'path',
|
|
||||||
no_validate => 1, none_ok => 1,
|
|
||||||
desc => 'The path object to export, or %NULL for all in the image' }
|
|
||||||
);
|
|
||||||
|
|
||||||
@outargs = (
|
|
||||||
{ name => 'string', type => 'string',
|
|
||||||
desc => 'A string whose contents are a complete SVG document.' }
|
|
||||||
);
|
|
||||||
|
|
||||||
%invoke = (
|
|
||||||
headers => [ qw("vectors/gimppath-export.h") ],
|
|
||||||
code => <<'CODE'
|
|
||||||
{
|
|
||||||
GList *path_list = NULL;
|
|
||||||
|
|
||||||
if (path != NULL)
|
|
||||||
path_list = g_list_prepend (path_list, path);
|
|
||||||
|
|
||||||
string = gimp_path_export_string (image, path_list);
|
|
||||||
g_list_free (path_list);
|
|
||||||
|
|
||||||
success = (string != NULL);
|
|
||||||
}
|
|
||||||
CODE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@headers = qw(<string.h>
|
@headers = qw(<string.h>
|
||||||
"core/gimplist.h"
|
"core/gimplist.h"
|
||||||
|
@ -1366,11 +1150,7 @@ CODE
|
||||||
path_bezier_stroke_lineto
|
path_bezier_stroke_lineto
|
||||||
path_bezier_stroke_conicto
|
path_bezier_stroke_conicto
|
||||||
path_bezier_stroke_cubicto
|
path_bezier_stroke_cubicto
|
||||||
path_bezier_stroke_new_ellipse
|
path_bezier_stroke_new_ellipse);
|
||||||
path_import_from_file
|
|
||||||
path_import_from_string
|
|
||||||
path_export_to_file
|
|
||||||
path_export_to_string);
|
|
||||||
|
|
||||||
%exports = (app => [@procs], lib => [@procs]);
|
%exports = (app => [@procs], lib => [@procs]);
|
||||||
|
|
||||||
|
|
|
@ -501,9 +501,9 @@ svg_load (GimpProcedure *procedure,
|
||||||
GimpPath **paths;
|
GimpPath **paths;
|
||||||
gint num_paths;
|
gint num_paths;
|
||||||
|
|
||||||
gimp_path_import_from_file (image, file,
|
gimp_image_import_paths_from_file (image, file,
|
||||||
g_strcmp0 (import_paths, "import-merged") == 0,
|
g_strcmp0 (import_paths, "import-merged") == 0,
|
||||||
TRUE, &num_paths, &paths);
|
TRUE, &num_paths, &paths);
|
||||||
if (num_paths > 0)
|
if (num_paths > 0)
|
||||||
g_free (paths);
|
g_free (paths);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
(test! "path export methods")
|
(test! "path export methods")
|
||||||
|
|
||||||
; export single path to string succeeds
|
; export single path to string succeeds
|
||||||
(assert `(gimp-path-export-to-string
|
(assert `(gimp-image-export-path-to-string
|
||||||
,testImage
|
,testImage
|
||||||
,testPath))
|
,testPath))
|
||||||
|
|
||||||
|
@ -85,18 +85,18 @@
|
||||||
; passing 0 for path means "all"
|
; passing 0 for path means "all"
|
||||||
; FIXME this is wierd, should be a separate method gimp-image-export-paths-to-string
|
; FIXME this is wierd, should be a separate method gimp-image-export-paths-to-string
|
||||||
; The name implies a single path
|
; The name implies a single path
|
||||||
(assert `(gimp-path-export-to-string
|
(assert `(gimp-image-export-path-to-string
|
||||||
,testImage
|
,testImage
|
||||||
0))
|
0))
|
||||||
|
|
||||||
; export single path to file succeeds
|
; export single path to file succeeds
|
||||||
(assert `(gimp-path-export-to-file
|
(assert `(gimp-image-export-path-to-file
|
||||||
,testImage
|
,testImage
|
||||||
"tmp.svg"
|
"tmp.svg"
|
||||||
,testPath))
|
,testPath))
|
||||||
|
|
||||||
; export all paths to file succeeds
|
; export all paths to file succeeds
|
||||||
(assert `(gimp-path-export-to-file
|
(assert `(gimp-image-export-path-to-file
|
||||||
,testImage
|
,testImage
|
||||||
"tmp2.svg"
|
"tmp2.svg"
|
||||||
0))
|
0))
|
||||||
|
|
Loading…
Reference in New Issue