tools/pdbgen/pdb/brushes.pdb (brushes_get_brush_data)

2004-10-06  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/brushes.pdb (brushes_get_brush_data)
	* tools/pdbgen/pdb/gradients.pdb (gradients_sample_uniform)
	(gradients_sample_custom) (gradients_get_gradient_data)
	* tools/pdbgen/pdb/patterns.pdb (patterns_get_pattern_data):
	deprecated.

	* tools/pdbgen/pdb/brush.pdb
	* tools/pdbgen/pdb/gradient.pdb
	* tools/pdbgen/pdb/palette.pdb
	* tools/pdbgen/pdb/pattern.pdb: added replacements for the
	deprecated functions. Removed the silly feature that passing NULL
	as name operates on the current brush, pattern etc.

	* app/pdb/brush_cmds.c
	* app/pdb/brushes_cmds.c
	* app/pdb/gradient_cmds.c
	* app/pdb/gradients_cmds.c
	* app/pdb/internal_procs.c
	* app/pdb/palette_cmds.c
	* app/pdb/pattern_cmds.c
	* app/pdb/patterns_cmds.c
	* libgimp/gimpbrush_pdb.[ch]
	* libgimp/gimpbrushes_pdb.[ch]
	* libgimp/gimpgradient_pdb.[ch]
	* libgimp/gimpgradients_pdb.[ch]
	* libgimp/gimppalette_pdb.c
	* libgimp/gimppattern_pdb.[ch]
	* libgimp/gimppatterns_pdb.[ch]: regenerated.

	* libgimp/gimpbrushmenu.c
	* libgimp/gimpgradientmenu.c
	* libgimp/gimppatternmenu.c
	* plug-ins/FractalExplorer/Dialogs.c
	* plug-ins/common/gradmap.c
	* plug-ins/common/sample_colorize.c
	* plug-ins/flame/flame.c
	* plug-ins/gfig/gfig-style.c
	* plug-ins/gflare/gflare.c
	* plug-ins/pagecurl/pagecurl.c
	* plug-ins/script-fu/scripts/spyrogimp.scm: changed accordingly.
This commit is contained in:
Michael Natterer 2004-10-05 23:28:17 +00:00 committed by Michael Natterer
parent c7e1f32a29
commit caf4786993
40 changed files with 1783 additions and 1114 deletions

View File

@ -1,3 +1,46 @@
2004-10-06 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/brushes.pdb (brushes_get_brush_data)
* tools/pdbgen/pdb/gradients.pdb (gradients_sample_uniform)
(gradients_sample_custom) (gradients_get_gradient_data)
* tools/pdbgen/pdb/patterns.pdb (patterns_get_pattern_data):
deprecated.
* tools/pdbgen/pdb/brush.pdb
* tools/pdbgen/pdb/gradient.pdb
* tools/pdbgen/pdb/palette.pdb
* tools/pdbgen/pdb/pattern.pdb: added replacements for the
deprecated functions. Removed the silly feature that passing NULL
as name operates on the current brush, pattern etc.
* app/pdb/brush_cmds.c
* app/pdb/brushes_cmds.c
* app/pdb/gradient_cmds.c
* app/pdb/gradients_cmds.c
* app/pdb/internal_procs.c
* app/pdb/palette_cmds.c
* app/pdb/pattern_cmds.c
* app/pdb/patterns_cmds.c
* libgimp/gimpbrush_pdb.[ch]
* libgimp/gimpbrushes_pdb.[ch]
* libgimp/gimpgradient_pdb.[ch]
* libgimp/gimpgradients_pdb.[ch]
* libgimp/gimppalette_pdb.c
* libgimp/gimppattern_pdb.[ch]
* libgimp/gimppatterns_pdb.[ch]: regenerated.
* libgimp/gimpbrushmenu.c
* libgimp/gimpgradientmenu.c
* libgimp/gimppatternmenu.c
* plug-ins/FractalExplorer/Dialogs.c
* plug-ins/common/gradmap.c
* plug-ins/common/sample_colorize.c
* plug-ins/flame/flame.c
* plug-ins/gfig/gfig-style.c
* plug-ins/gflare/gflare.c
* plug-ins/pagecurl/pagecurl.c
* plug-ins/script-fu/scripts/spyrogimp.scm: changed accordingly.
2004-10-06 Sven Neumann <sven@gimp.org>
* plug-ins/common/spheredesigner.c: improved the dialog a bit,

View File

@ -39,6 +39,7 @@ static ProcRecord brush_duplicate_proc;
static ProcRecord brush_rename_proc;
static ProcRecord brush_delete_proc;
static ProcRecord brush_get_info_proc;
static ProcRecord brush_get_pixels_proc;
static ProcRecord brush_get_spacing_proc;
static ProcRecord brush_set_spacing_proc;
@ -50,6 +51,7 @@ register_brush_procs (Gimp *gimp)
procedural_db_register (gimp, &brush_rename_proc);
procedural_db_register (gimp, &brush_delete_proc);
procedural_db_register (gimp, &brush_get_info_proc);
procedural_db_register (gimp, &brush_get_pixels_proc);
procedural_db_register (gimp, &brush_get_spacing_proc);
procedural_db_register (gimp, &brush_set_spacing_proc);
}
@ -132,21 +134,13 @@ brush_duplicate_invoker (Gimp *gimp,
GimpBrush *brush_copy = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (name && strlen (name))
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
name);
}
else
{
brush = gimp_context_get_brush (context);
}
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush)
{
@ -173,7 +167,7 @@ static ProcArg brush_duplicate_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The brush name (\"\" means currently active brush)"
"The brush name"
}
};
@ -215,7 +209,7 @@ brush_rename_invoker (Gimp *gimp,
GimpBrush *brush = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
new_name = (gchar *) args[1].value.pdb_pointer;
@ -224,16 +218,8 @@ brush_rename_invoker (Gimp *gimp,
if (success)
{
if (name && strlen (name))
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
name);
}
else
{
brush = gimp_context_get_brush (context);
}
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush && GIMP_DATA (brush)->writable)
gimp_object_set_name (GIMP_OBJECT (brush), new_name);
@ -254,7 +240,7 @@ static ProcArg brush_rename_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The brush name (\"\" means currently active brush)"
"The brush name"
},
{
GIMP_PDB_STRING,
@ -299,21 +285,13 @@ brush_delete_invoker (Gimp *gimp,
GimpBrush *brush = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (name && strlen (name))
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
name);
}
else
{
brush = gimp_context_get_brush (context);
}
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush && GIMP_DATA (brush)->deletable)
{
@ -341,7 +319,7 @@ static ProcArg brush_delete_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The brush name (\"\" means currently active brush)"
"The brush name"
}
};
@ -373,21 +351,13 @@ brush_get_info_invoker (Gimp *gimp,
GimpBrush *brush = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (name && strlen (name))
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
name);
}
else
{
brush = gimp_context_get_brush (context);
}
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
success = (brush != NULL);
}
@ -408,7 +378,7 @@ static ProcArg brush_get_info_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The brush name (\"\" means currently active brush)"
"The brush name"
}
};
@ -442,6 +412,99 @@ static ProcRecord brush_get_info_proc =
{ { brush_get_info_invoker } }
};
static Argument *
brush_get_pixels_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 num_mask_bytes = 0;
guint8 *mask_bytes = NULL;
GimpBrush *brush = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush)
{
num_mask_bytes = brush->mask->height * brush->mask->width;
mask_bytes = g_memdup (temp_buf_data (brush->mask), num_mask_bytes);
}
else
success = FALSE;
}
return_args = procedural_db_return_args (&brush_get_pixels_proc, success);
if (success)
{
return_args[1].value.pdb_int = brush->mask->width;
return_args[2].value.pdb_int = brush->mask->height;
return_args[3].value.pdb_int = num_mask_bytes;
return_args[4].value.pdb_pointer = mask_bytes;
}
return return_args;
}
static ProcArg brush_get_pixels_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The brush name"
}
};
static ProcArg brush_get_pixels_outargs[] =
{
{
GIMP_PDB_INT32,
"width",
"The brush width"
},
{
GIMP_PDB_INT32,
"height",
"The brush height"
},
{
GIMP_PDB_INT32,
"num_mask_bytes",
"Length of brush mask data"
},
{
GIMP_PDB_INT8ARRAY,
"mask_bytes",
"The brush mask data"
}
};
static ProcRecord brush_get_pixels_proc =
{
"gimp_brush_get_pixels",
"Retrieve information about the specified brush.",
"This procedure retrieves information about the specified brush. This includes the brush extents (width and height) and its pixels data.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004",
GIMP_INTERNAL,
1,
brush_get_pixels_inargs,
4,
brush_get_pixels_outargs,
{ { brush_get_pixels_invoker } }
};
static Argument *
brush_get_spacing_invoker (Gimp *gimp,
GimpContext *context,
@ -454,21 +517,13 @@ brush_get_spacing_invoker (Gimp *gimp,
GimpBrush *brush = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (name && strlen (name))
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
name);
}
else
{
brush = gimp_context_get_brush (context);
}
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
success = (brush != NULL);
}
@ -476,7 +531,7 @@ brush_get_spacing_invoker (Gimp *gimp,
return_args = procedural_db_return_args (&brush_get_spacing_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_brush_get_spacing (gimp_context_get_brush (context));
return_args[1].value.pdb_int = gimp_brush_get_spacing (brush);
return return_args;
}
@ -486,7 +541,7 @@ static ProcArg brush_get_spacing_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The brush name (\"\" means currently active brush)"
"The brush name"
}
};
@ -527,7 +582,7 @@ brush_set_spacing_invoker (Gimp *gimp,
GimpBrush *brush = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
spacing = args[1].value.pdb_int;
@ -536,16 +591,8 @@ brush_set_spacing_invoker (Gimp *gimp,
if (success)
{
if (name && strlen (name))
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
name);
}
else
{
brush = gimp_context_get_brush (context);
}
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush && GIMP_DATA (brush)->writable)
gimp_brush_set_spacing (brush, spacing);
@ -561,7 +608,7 @@ static ProcArg brush_set_spacing_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The brush name (\"\" means currently active brush)"
"The brush name"
},
{
GIMP_PDB_INT32,

View File

@ -408,11 +408,11 @@ static ProcArg brushes_get_brush_data_outargs[] =
static ProcRecord brushes_get_brush_data_proc =
{
"gimp_brushes_get_brush_data",
"Retrieve information about the currently active brush (including data).",
"This procedure retrieves information about the currently active brush. This includes the brush name, and the brush extents (width and height). It also returns the brush data.",
"Andy Thomas",
"Andy Thomas",
"1998",
"This procedure is deprecated! Use 'gimp_brush_get_pixels' instead.",
"This procedure is deprecated! Use 'gimp_brush_get_pixels' instead.",
"",
"",
"",
GIMP_INTERNAL,
1,
brushes_get_brush_data_inargs,

File diff suppressed because it is too large Load Diff

View File

@ -235,11 +235,11 @@ static ProcArg gradients_sample_uniform_outargs[] =
static ProcRecord gradients_sample_uniform_proc =
{
"gimp_gradients_sample_uniform",
"Sample the active gradient in uniform parts.",
"This procedure samples the active gradient in the specified number of uniform parts. It returns a list of floating-point values which correspond to the RGBA values for each sample. The minimum number of samples to take is 2, in which case the returned colors will correspond to the { 0.0, 1.0 } positions in the gradient. For example, if the number of samples is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.",
"Federico Mena Quintero",
"Federico Mena Quintero",
"1997",
"This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.",
"This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.",
"",
"",
"",
GIMP_INTERNAL,
2,
gradients_sample_uniform_inargs,
@ -341,11 +341,11 @@ static ProcArg gradients_sample_custom_outargs[] =
static ProcRecord gradients_sample_custom_proc =
{
"gimp_gradients_sample_custom",
"Sample the active gradient in custom positions.",
"This procedure samples the active gradient in the specified number of points. The procedure will sample the gradient in the specified positions from the list. The left endpoint of the gradient corresponds to position 0.0, and the right endpoint corresponds to 1.0. The procedure returns a list of floating-point values which correspond to the RGBA values for each sample.",
"Federico Mena Quintero",
"Federico Mena Quintero",
"1997",
"This procedure is deprecated! Use 'gimp_gradient_get_custom_samples' instead.",
"This procedure is deprecated! Use 'gimp_gradient_get_custom_samples' instead.",
"",
"",
"",
GIMP_INTERNAL,
3,
gradients_sample_custom_inargs,
@ -381,15 +381,15 @@ gradients_get_gradient_data_invoker (Gimp *gimp,
if (success)
{
if (name && strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
@ -473,11 +473,11 @@ static ProcArg gradients_get_gradient_data_outargs[] =
static ProcRecord gradients_get_gradient_data_proc =
{
"gimp_gradients_get_gradient_data",
"Retrieve information about the specified gradient (including data).",
"This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.",
"Federico Mena Quintero",
"Federico Mena Quintero",
"1997",
"This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.",
"This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.",
"",
"",
"",
GIMP_INTERNAL,
3,
gradients_get_gradient_data_inargs,

View File

@ -73,7 +73,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
/* 408 procedures registered total */
/* 412 procedures registered total */
void
internal_procs_init (Gimp *gimp,
@ -85,25 +85,25 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (_("Internal Procedures"), _("Brush"), 0.0);
register_brush_procs (gimp);
(* status_callback) (NULL, _("Brush UI"), 0.017);
(* status_callback) (NULL, _("Brush UI"), 0.019);
register_brush_select_procs (gimp);
(* status_callback) (NULL, _("Brushes"), 0.025);
(* status_callback) (NULL, _("Brushes"), 0.027);
register_brushes_procs (gimp);
(* status_callback) (NULL, _("Channel"), 0.039);
(* status_callback) (NULL, _("Channel"), 0.041);
register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.061);
(* status_callback) (NULL, _("Color"), 0.063);
register_color_procs (gimp);
(* status_callback) (NULL, _("Context"), 0.096);
(* status_callback) (NULL, _("Context"), 0.097);
register_context_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.15);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.157);
(* status_callback) (NULL, _("Display procedures"), 0.158);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.167);
@ -115,94 +115,94 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("File Operations"), 0.265);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.287);
(* status_callback) (NULL, _("Floating selections"), 0.286);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.301);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.309);
(* status_callback) (NULL, _("Fonts"), 0.308);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.314);
(* status_callback) (NULL, _("Gimprc procedures"), 0.313);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.328);
register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.395);
(* status_callback) (NULL, _("Gradient UI"), 0.398);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.402);
(* status_callback) (NULL, _("Gradients"), 0.405);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.414);
(* status_callback) (NULL, _("Guide procedures"), 0.417);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.429);
(* status_callback) (NULL, _("Help procedures"), 0.432);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.431);
(* status_callback) (NULL, _("Image"), 0.434);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.583);
(* status_callback) (NULL, _("Layer"), 0.585);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.647);
(* status_callback) (NULL, _("Message procedures"), 0.648);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.654);
(* status_callback) (NULL, _("Miscellaneous"), 0.655);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.659);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.66);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.696);
(* status_callback) (NULL, _("Palette"), 0.697);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.723);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.73);
(* status_callback) (NULL, _("Palettes"), 0.731);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.74);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.77);
(* status_callback) (NULL, _("Paths"), 0.769);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.806);
register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.809);
(* status_callback) (NULL, _("Pattern UI"), 0.811);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.816);
(* status_callback) (NULL, _("Patterns"), 0.818);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.826);
(* status_callback) (NULL, _("Plug-in"), 0.828);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.838);
(* status_callback) (NULL, _("Procedural database"), 0.84);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Progress"), 0.86);
(* status_callback) (NULL, _("Progress"), 0.862);
register_progress_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.873);
(* status_callback) (NULL, _("Image mask"), 0.874);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.917);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.929);
(* status_callback) (NULL, _("Text procedures"), 0.93);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.939);
register_transform_tools_procs (gimp);
(* status_callback) (NULL, _("Undo"), 0.953);
(* status_callback) (NULL, _("Undo"), 0.954);
register_undo_procs (gimp);
(* status_callback) (NULL, _("Units"), 0.971);

View File

@ -141,21 +141,13 @@ palette_duplicate_invoker (Gimp *gimp,
GimpPalette *palette_copy = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette)
{
@ -182,7 +174,7 @@ static ProcArg palette_duplicate_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
}
};
@ -224,7 +216,7 @@ palette_rename_invoker (Gimp *gimp,
GimpPalette *palette = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
new_name = (gchar *) args[1].value.pdb_pointer;
@ -233,16 +225,8 @@ palette_rename_invoker (Gimp *gimp,
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
gimp_object_set_name (GIMP_OBJECT (palette), new_name);
@ -263,7 +247,7 @@ static ProcArg palette_rename_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
},
{
GIMP_PDB_STRING,
@ -308,21 +292,13 @@ palette_delete_invoker (Gimp *gimp,
GimpPalette *palette = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->deletable)
{
@ -350,7 +326,7 @@ static ProcArg palette_delete_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
}
};
@ -382,21 +358,13 @@ palette_get_info_invoker (Gimp *gimp,
GimpPalette *palette = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
success = (palette != NULL);
}
@ -414,7 +382,7 @@ static ProcArg palette_get_info_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
}
};
@ -458,7 +426,7 @@ palette_add_entry_invoker (Gimp *gimp,
GimpPaletteEntry *entry = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_name = (gchar *) args[1].value.pdb_pointer;
@ -469,16 +437,8 @@ palette_add_entry_invoker (Gimp *gimp,
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
entry = gimp_palette_add_entry (palette, entry_name, &color);
@ -499,7 +459,7 @@ static ProcArg palette_add_entry_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
},
{
GIMP_PDB_STRING,
@ -551,23 +511,15 @@ palette_delete_entry_invoker (Gimp *gimp,
GimpPaletteEntry *entry = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
{
@ -592,7 +544,7 @@ static ProcArg palette_delete_entry_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
},
{
GIMP_PDB_INT32,
@ -632,23 +584,15 @@ palette_entry_get_color_invoker (Gimp *gimp,
GimpPaletteEntry *entry = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette)
{
@ -678,7 +622,7 @@ static ProcArg palette_entry_get_color_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
},
{
GIMP_PDB_INT32,
@ -726,7 +670,7 @@ palette_entry_set_color_invoker (Gimp *gimp,
GimpPaletteEntry *entry = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
@ -735,16 +679,8 @@ palette_entry_set_color_invoker (Gimp *gimp,
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
{
@ -771,7 +707,7 @@ static ProcArg palette_entry_set_color_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
},
{
GIMP_PDB_INT32,
@ -815,23 +751,15 @@ palette_entry_get_name_invoker (Gimp *gimp,
GimpPaletteEntry *entry = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette)
{
@ -857,7 +785,7 @@ static ProcArg palette_entry_get_name_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
},
{
GIMP_PDB_INT32,
@ -905,7 +833,7 @@ palette_entry_set_name_invoker (Gimp *gimp,
GimpPaletteEntry *entry = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
entry_num = args[1].value.pdb_int;
@ -916,16 +844,8 @@ palette_entry_set_name_invoker (Gimp *gimp,
if (success)
{
if (name && strlen (name))
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container,
name);
}
else
{
palette = gimp_context_get_palette (context);
}
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
{
@ -953,7 +873,7 @@ static ProcArg palette_entry_set_name_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The palette name (\"\" means currently active palette)"
"The palette name."
},
{
GIMP_PDB_INT32,

View File

@ -35,11 +35,13 @@
#include "core/gimppattern.h"
static ProcRecord pattern_get_info_proc;
static ProcRecord pattern_get_pixels_proc;
void
register_pattern_procs (Gimp *gimp)
{
procedural_db_register (gimp, &pattern_get_info_proc);
procedural_db_register (gimp, &pattern_get_pixels_proc);
}
static Argument *
@ -54,21 +56,13 @@ pattern_get_info_invoker (Gimp *gimp,
GimpPattern *pattern = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name && !g_utf8_validate (name, -1, NULL))
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (name && strlen (name))
{
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container,
name);
}
else
{
pattern = gimp_context_get_pattern (context);
}
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
success = (pattern != NULL);
}
@ -90,7 +84,7 @@ static ProcArg pattern_get_info_inargs[] =
{
GIMP_PDB_STRING,
"name",
"The pattern name (\"\" means currently active pattern)"
"The pattern name."
}
};
@ -128,3 +122,104 @@ static ProcRecord pattern_get_info_proc =
pattern_get_info_outargs,
{ { pattern_get_info_invoker } }
};
static Argument *
pattern_get_pixels_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 num_mask_bytes = 0;
guint8 *mask_bytes = NULL;
GimpPattern *pattern = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
if (pattern)
{
num_mask_bytes = pattern->mask->height * pattern->mask->width *
pattern->mask->bytes;
mask_bytes = g_memdup (temp_buf_data (pattern->mask),
num_mask_bytes);
}
else
success = FALSE;
}
return_args = procedural_db_return_args (&pattern_get_pixels_proc, success);
if (success)
{
return_args[1].value.pdb_int = pattern->mask->width;
return_args[2].value.pdb_int = pattern->mask->height;
return_args[3].value.pdb_int = pattern->mask->bytes;
return_args[4].value.pdb_int = num_mask_bytes;
return_args[5].value.pdb_pointer = mask_bytes;
}
return return_args;
}
static ProcArg pattern_get_pixels_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The pattern name."
}
};
static ProcArg pattern_get_pixels_outargs[] =
{
{
GIMP_PDB_INT32,
"width",
"The pattern width"
},
{
GIMP_PDB_INT32,
"height",
"The pattern height"
},
{
GIMP_PDB_INT32,
"bpp",
"The pattern bpp"
},
{
GIMP_PDB_INT32,
"num_mask_bytes",
"Length of pattern mask data"
},
{
GIMP_PDB_INT8ARRAY,
"mask_bytes",
"The pattern mask data"
}
};
static ProcRecord pattern_get_pixels_proc =
{
"gimp_pattern_get_pixels",
"Retrieve information about the specified pattern (including pixels).",
"This procedure retrieves information about the specified. This includes the pattern extents (width and height), its bpp and its pixel data.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004",
GIMP_INTERNAL,
1,
pattern_get_pixels_inargs,
5,
pattern_get_pixels_outargs,
{ { pattern_get_pixels_invoker } }
};

View File

@ -305,11 +305,11 @@ static ProcArg patterns_get_pattern_data_outargs[] =
static ProcRecord patterns_get_pattern_data_proc =
{
"gimp_patterns_get_pattern_data",
"Retrieve information about the currently active pattern (including data).",
"This procedure retrieves information about the currently active pattern. This includes the pattern name, and the pattern extents (width and height). It also returns the pattern data.",
"Andy Thomas",
"Andy Thomas",
"1998",
"This procedure is deprecated! Use 'gimp_pattern_get_data' instead.",
"This procedure is deprecated! Use 'gimp_pattern_get_data' instead.",
"",
"",
"",
GIMP_INTERNAL,
1,
patterns_get_pattern_data_inargs,

View File

@ -23,6 +23,8 @@
#include "config.h"
#include <string.h>
#include "gimp.h"
/**
@ -59,7 +61,7 @@ gimp_brush_new (const gchar *name)
/**
* gimp_brush_duplicate:
* @name: The brush name (\"\" means currently active brush).
* @name: The brush name.
*
* Duplicates a brush
*
@ -91,7 +93,7 @@ gimp_brush_duplicate (const gchar *name)
/**
* gimp_brush_rename:
* @name: The brush name (\"\" means currently active brush).
* @name: The brush name.
* @new_name: The new name of the brush.
*
* Rename a brush
@ -126,7 +128,7 @@ gimp_brush_rename (const gchar *name,
/**
* gimp_brush_delete:
* @name: The brush name (\"\" means currently active brush).
* @name: The brush name.
*
* Deletes a brush
*
@ -157,7 +159,7 @@ gimp_brush_delete (const gchar *name)
/**
* gimp_brush_get_info:
* @name: The brush name (\"\" means currently active brush).
* @name: The brush name.
* @width: The brush width.
* @height: The brush height.
*
@ -200,9 +202,64 @@ gimp_brush_get_info (const gchar *name,
return success;
}
/**
* gimp_brush_get_pixels:
* @name: The brush name.
* @width: The brush width.
* @height: The brush height.
* @num_mask_bytes: Length of brush mask data.
* @mask_bytes: The brush mask data.
*
* Retrieve information about the specified brush.
*
* This procedure retrieves information about the specified brush. This
* includes the brush extents (width and height) and its pixels data.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.2
*/
gboolean
gimp_brush_get_pixels (const gchar *name,
gint *width,
gint *height,
gint *num_mask_bytes,
guint8 **mask_bytes)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_brush_get_pixels",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
*width = 0;
*height = 0;
*num_mask_bytes = 0;
*mask_bytes = NULL;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*width = return_vals[1].data.d_int32;
*height = return_vals[2].data.d_int32;
*num_mask_bytes = return_vals[3].data.d_int32;
*mask_bytes = g_new (guint8, *num_mask_bytes);
memcpy (*mask_bytes, return_vals[4].data.d_int8array,
*num_mask_bytes * sizeof (guint8));
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_brush_get_spacing:
* @name: The brush name (\"\" means currently active brush).
* @name: The brush name.
* @spacing: The brush spacing.
*
* Get the brush spacing.
@ -242,7 +299,7 @@ gimp_brush_get_spacing (const gchar *name,
/**
* gimp_brush_set_spacing:
* @name: The brush name (\"\" means currently active brush).
* @name: The brush name.
* @spacing: The brush spacing.
*
* Set the brush spacing.

View File

@ -29,18 +29,23 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gchar* gimp_brush_new (const gchar *name);
gchar* gimp_brush_duplicate (const gchar *name);
gchar* gimp_brush_rename (const gchar *name,
const gchar *new_name);
gboolean gimp_brush_delete (const gchar *name);
gboolean gimp_brush_get_info (const gchar *name,
gint *width,
gint *height);
gboolean gimp_brush_get_spacing (const gchar *name,
gint *spacing);
gboolean gimp_brush_set_spacing (const gchar *name,
gint spacing);
gchar* gimp_brush_new (const gchar *name);
gchar* gimp_brush_duplicate (const gchar *name);
gchar* gimp_brush_rename (const gchar *name,
const gchar *new_name);
gboolean gimp_brush_delete (const gchar *name);
gboolean gimp_brush_get_info (const gchar *name,
gint *width,
gint *height);
gboolean gimp_brush_get_pixels (const gchar *name,
gint *width,
gint *height,
gint *num_mask_bytes,
guint8 **mask_bytes);
gboolean gimp_brush_get_spacing (const gchar *name,
gint *spacing);
gboolean gimp_brush_set_spacing (const gchar *name,
gint spacing);
G_END_DECLS

View File

@ -203,12 +203,9 @@ gimp_brushes_set_spacing (gint spacing)
* @length: Length of brush mask data.
* @mask_data: The brush mask data.
*
* Retrieve information about the currently active brush (including
* data).
* This procedure is deprecated! Use 'gimp_brush_get_pixels' instead.
*
* This procedure retrieves information about the currently active
* brush. This includes the brush name, and the brush extents (width
* and height). It also returns the brush data.
* This procedure is deprecated! Use 'gimp_brush_get_pixels' instead.
*
* Returns: The brush name.
*/

View File

@ -43,6 +43,7 @@ gint gimp_brushes_get_spacing (void);
#ifndef GIMP_DISABLE_DEPRECATED
gboolean gimp_brushes_set_spacing (gint spacing);
#endif /* GIMP_DISABLE_DEPRECATED */
#ifndef GIMP_DISABLE_DEPRECATED
gchar* gimp_brushes_get_brush_data (const gchar *name,
gdouble *opacity,
gint *spacing,
@ -51,6 +52,7 @@ gchar* gimp_brushes_get_brush_data (const gchar *name,
gint *height,
gint *length,
guint8 **mask_data);
#endif /* GIMP_DISABLE_DEPRECATED */
G_END_DECLS

View File

@ -22,6 +22,8 @@
#include "config.h"
#include <string.h>
#include "gimp.h"
#include "gimpui.h"
@ -115,9 +117,6 @@ gimp_brush_select_widget_new (const gchar *title,
BrushSelect *brush_sel;
GtkWidget *frame;
GtkWidget *hbox;
gint init_spacing;
GimpLayerModeEffects init_paint_mode;
gdouble init_opacity;
gint mask_data_size;
g_return_val_if_fail (callback != NULL, NULL);
@ -164,20 +163,31 @@ gimp_brush_select_widget_new (const gchar *title,
brush_sel);
/* Do initial brush setup */
brush_sel->brush_name = gimp_brushes_get_brush_data (brush_name,
&init_opacity,
&init_spacing,
&init_paint_mode,
&brush_sel->width,
&brush_sel->height,
&mask_data_size,
&brush_sel->mask_data);
if (! brush_name || ! strlen (brush_name))
brush_sel->brush_name = gimp_context_get_brush ();
else
brush_sel->brush_name = g_strdup (brush_name);
if (brush_sel->brush_name)
if (gimp_brush_get_pixels (brush_sel->brush_name,
&brush_sel->width,
&brush_sel->height,
&mask_data_size,
&brush_sel->mask_data))
{
brush_sel->opacity = (opacity == -1.0) ? init_opacity : opacity;
brush_sel->spacing = (spacing == -1) ? init_spacing : spacing;
brush_sel->paint_mode = (paint_mode == -1) ? init_paint_mode : paint_mode;
if (opacity == -1)
brush_sel->opacity = gimp_context_get_opacity ();
else
brush_sel->opacity = opacity;
if (paint_mode == -1)
brush_sel->paint_mode = gimp_context_get_paint_mode ();
else
brush_sel->paint_mode = paint_mode;
if (spacing == -1)
gimp_brush_get_spacing (brush_sel->brush_name, &brush_sel->spacing);
else
brush_sel->spacing = spacing;
}
g_object_set_data (G_OBJECT (hbox), BRUSH_SELECT_DATA_KEY, brush_sel);
@ -239,37 +249,40 @@ gimp_brush_select_widget_set (GtkWidget *widget,
}
else
{
gint width;
gint height;
gint init_spacing;
GimpLayerModeEffects init_paint_mode;
gdouble init_opacity;
gint mask_data_size;
guint8 *mask_data;
gchar *name;
gint width;
gint height;
gint mask_data_size;
guint8 *mask_data;
gchar *name;
name = gimp_brushes_get_brush_data (brush_name,
&init_opacity,
&init_spacing,
&init_paint_mode,
&width,
&height,
&mask_data_size,
&mask_data);
if (! brush_name || ! strlen (brush_name))
name = gimp_context_get_brush ();
else
name = g_strdup (brush_name);
if (name)
if (gimp_brush_get_pixels (name,
&width,
&height,
&mask_data_size,
&mask_data))
{
if (opacity == -1.0) opacity = init_opacity;
if (spacing == -1) spacing = init_spacing;
if (paint_mode == -1) paint_mode = init_paint_mode;
if (opacity == -1.0)
opacity = gimp_context_get_opacity ();
gimp_brush_select_widget_callback (brush_name, opacity, spacing,
if (paint_mode == -1)
paint_mode = gimp_context_get_paint_mode ();
if (spacing == -1)
gimp_brush_get_spacing (name, &spacing);
gimp_brush_select_widget_callback (name, opacity, spacing,
paint_mode, width, height,
mask_data, FALSE, brush_sel);
g_free (name);
g_free (mask_data);
}
g_free (name);
}
}

View File

@ -23,6 +23,8 @@
#include "config.h"
#include <string.h>
#include "gimp.h"
/**
@ -59,7 +61,7 @@ gimp_gradient_new (const gchar *name)
/**
* gimp_gradient_duplicate:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
*
* Duplicates a gradient
*
@ -91,7 +93,7 @@ gimp_gradient_duplicate (const gchar *name)
/**
* gimp_gradient_rename:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @new_name: The new name of the gradient.
*
* Rename a gradient
@ -126,7 +128,7 @@ gimp_gradient_rename (const gchar *name,
/**
* gimp_gradient_delete:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
*
* Deletes a gradient
*
@ -155,9 +157,127 @@ gimp_gradient_delete (const gchar *name)
return success;
}
/**
* gimp_gradient_get_uniform_samples:
* @name: The gradient name.
* @num_samples: The number of samples to take.
* @reverse: Use the reverse gradient.
* @num_color_samples: Length of the color_samples array (4 * num_samples).
* @color_samples: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
*
* Sample the specified in uniform parts.
*
* This procedure samples the active gradient in the specified number
* of uniform parts. It returns a list of floating-point values which
* correspond to the RGBA values for each sample. The minimum number of
* samples to take is 2, in which case the returned colors will
* correspond to the { 0.0, 1.0 } positions in the gradient. For
* example, if the number of samples is 3, the procedure will return
* the colors at positions { 0.0, 0.5, 1.0 }.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.2
*/
gboolean
gimp_gradient_get_uniform_samples (const gchar *name,
gint num_samples,
gboolean reverse,
gint *num_color_samples,
gdouble **color_samples)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_get_uniform_samples",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, num_samples,
GIMP_PDB_INT32, reverse,
GIMP_PDB_END);
*num_color_samples = 0;
*color_samples = NULL;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*num_color_samples = return_vals[1].data.d_int32;
*color_samples = g_new (gdouble, *num_color_samples);
memcpy (*color_samples, return_vals[2].data.d_floatarray,
*num_color_samples * sizeof (gdouble));
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_get_custom_samples:
* @name: The gradient name.
* @num_samples: The number of samples to take.
* @positions: The list of positions to sample along the gradient.
* @reverse: Use the reverse gradient.
* @num_color_samples: Length of the color_samples array (4 * num_samples).
* @color_samples: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
*
* Sample the spacified gradient in custom positions.
*
* This procedure samples the active gradient in the specified number
* of points. The procedure will sample the gradient in the specified
* positions from the list. The left endpoint of the gradient
* corresponds to position 0.0, and the right endpoint corresponds to
* 1.0. The procedure returns a list of floating-point values which
* correspond to the RGBA values for each sample.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.2
*/
gboolean
gimp_gradient_get_custom_samples (const gchar *name,
gint num_samples,
const gdouble *positions,
gboolean reverse,
gint *num_color_samples,
gdouble **color_samples)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_get_custom_samples",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, num_samples,
GIMP_PDB_FLOATARRAY, positions,
GIMP_PDB_INT32, reverse,
GIMP_PDB_END);
*num_color_samples = 0;
*color_samples = NULL;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*num_color_samples = return_vals[1].data.d_int32;
*color_samples = g_new (gdouble, *num_color_samples);
memcpy (*color_samples, return_vals[2].data.d_floatarray,
*num_color_samples * sizeof (gdouble));
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_get_left_color:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @color: The return color.
* @opacity: The opacity of the endpoint.
@ -205,7 +325,7 @@ gimp_gradient_segment_get_left_color (const gchar *name,
/**
* gimp_gradient_segment_set_left_color:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @color: The color to set.
* @opacity: The opacity to set for the endpoint.
@ -247,7 +367,7 @@ gimp_gradient_segment_set_left_color (const gchar *name,
/**
* gimp_gradient_segment_get_right_color:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @color: The return color.
* @opacity: The opacity of the endpoint.
@ -295,7 +415,7 @@ gimp_gradient_segment_get_right_color (const gchar *name,
/**
* gimp_gradient_segment_set_right_color:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @color: The color to set.
* @opacity: The opacity to set for the endpoint.
@ -337,7 +457,7 @@ gimp_gradient_segment_set_right_color (const gchar *name,
/**
* gimp_gradient_segment_get_left_pos:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @pos: The return position.
*
@ -380,7 +500,7 @@ gimp_gradient_segment_get_left_pos (const gchar *name,
/**
* gimp_gradient_segment_set_left_pos:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @pos: The position to set the guidepoint in.
* @final_pos: The return position.
@ -429,7 +549,7 @@ gimp_gradient_segment_set_left_pos (const gchar *name,
/**
* gimp_gradient_segment_get_middle_pos:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @pos: The return position.
*
@ -472,7 +592,7 @@ gimp_gradient_segment_get_middle_pos (const gchar *name,
/**
* gimp_gradient_segment_set_middle_pos:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @pos: The position to set the guidepoint in.
* @final_pos: The return position.
@ -519,7 +639,7 @@ gimp_gradient_segment_set_middle_pos (const gchar *name,
/**
* gimp_gradient_segment_get_right_pos:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @pos: The return position.
*
@ -562,7 +682,7 @@ gimp_gradient_segment_get_right_pos (const gchar *name,
/**
* gimp_gradient_segment_set_right_pos:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @pos: The position to set the guidepoint in.
* @final_pos: The return position.
@ -611,7 +731,7 @@ gimp_gradient_segment_set_right_pos (const gchar *name,
/**
* gimp_gradient_segment_get_blending_function:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @blend_func: The blending function of the segment.
*
@ -653,7 +773,7 @@ gimp_gradient_segment_get_blending_function (const gchar *name,
/**
* gimp_gradient_segment_get_coloring_type:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @segment: The index of the segment within the gradient.
* @coloring_type: The coloring type of the segment.
*
@ -695,7 +815,7 @@ gimp_gradient_segment_get_coloring_type (const gchar *name,
/**
* gimp_gradient_segment_range_set_blending_function:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @blending_function: The Blending Function.
@ -736,7 +856,7 @@ gimp_gradient_segment_range_set_blending_function (const gchar *name
/**
* gimp_gradient_segment_range_set_coloring_type:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @coloring_type: The Coloring Type.
@ -777,7 +897,7 @@ gimp_gradient_segment_range_set_coloring_type (const gchar *name,
/**
* gimp_gradient_segment_range_flip:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
@ -814,7 +934,7 @@ gimp_gradient_segment_range_flip (const gchar *name,
/**
* gimp_gradient_segment_range_replicate:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @replicate_times: The number of times to replicate.
@ -856,7 +976,7 @@ gimp_gradient_segment_range_replicate (const gchar *name,
/**
* gimp_gradient_segment_range_split_midpoint:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
@ -894,7 +1014,7 @@ gimp_gradient_segment_range_split_midpoint (const gchar *name,
/**
* gimp_gradient_segment_range_split_uniform:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @split_parts: The number of uniform divisions to split each segment to.
@ -935,7 +1055,7 @@ gimp_gradient_segment_range_split_uniform (const gchar *name,
/**
* gimp_gradient_segment_range_delete:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
@ -972,7 +1092,7 @@ gimp_gradient_segment_range_delete (const gchar *name,
/**
* gimp_gradient_segment_range_redistribute_handles:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
@ -1010,7 +1130,7 @@ gimp_gradient_segment_range_redistribute_handles (const gchar *name,
/**
* gimp_gradient_segment_range_blend_colors:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
@ -1049,7 +1169,7 @@ gimp_gradient_segment_range_blend_colors (const gchar *name,
/**
* gimp_gradient_segment_range_blend_opacity:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
@ -1088,7 +1208,7 @@ gimp_gradient_segment_range_blend_opacity (const gchar *name,
/**
* gimp_gradient_segment_range_move:
* @name: The gradient name (\"\" means currently active gradient).
* @name: The gradient name.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @delta: The delta to move the segment range.

View File

@ -29,93 +29,104 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gchar* gimp_gradient_new (const gchar *name);
gchar* gimp_gradient_duplicate (const gchar *name);
gchar* gimp_gradient_rename (const gchar *name,
const gchar *new_name);
gboolean gimp_gradient_delete (const gchar *name);
gboolean gimp_gradient_segment_get_left_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_left_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_right_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_right_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_left_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_left_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_middle_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_middle_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_right_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_right_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_blending_function (const gchar *name,
gint segment,
GimpGradientSegmentType *blend_func);
gboolean gimp_gradient_segment_get_coloring_type (const gchar *name,
gint segment,
GimpGradientSegmentColor *coloring_type);
gboolean gimp_gradient_segment_range_set_blending_function (const gchar *name,
gint start_segment,
gint end_segment,
GimpGradientSegmentType blending_function);
gboolean gimp_gradient_segment_range_set_coloring_type (const gchar *name,
gint start_segment,
gint end_segment,
GimpGradientSegmentColor coloring_type);
gboolean gimp_gradient_segment_range_flip (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_replicate (const gchar *name,
gint start_segment,
gint end_segment,
gint replicate_times);
gboolean gimp_gradient_segment_range_split_midpoint (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_split_uniform (const gchar *name,
gint start_segment,
gint end_segment,
gint split_parts);
gboolean gimp_gradient_segment_range_delete (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_redistribute_handles (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_colors (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_opacity (const gchar *name,
gint start_segment,
gint end_segment);
gdouble gimp_gradient_segment_range_move (const gchar *name,
gint start_segment,
gint end_segment,
gdouble delta,
gboolean control_compress);
gchar* gimp_gradient_new (const gchar *name);
gchar* gimp_gradient_duplicate (const gchar *name);
gchar* gimp_gradient_rename (const gchar *name,
const gchar *new_name);
gboolean gimp_gradient_delete (const gchar *name);
gboolean gimp_gradient_get_uniform_samples (const gchar *name,
gint num_samples,
gboolean reverse,
gint *num_color_samples,
gdouble **color_samples);
gboolean gimp_gradient_get_custom_samples (const gchar *name,
gint num_samples,
const gdouble *positions,
gboolean reverse,
gint *num_color_samples,
gdouble **color_samples);
gboolean gimp_gradient_segment_get_left_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_left_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_right_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_right_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_left_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_left_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_middle_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_middle_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_right_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_right_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_blending_function (const gchar *name,
gint segment,
GimpGradientSegmentType *blend_func);
gboolean gimp_gradient_segment_get_coloring_type (const gchar *name,
gint segment,
GimpGradientSegmentColor *coloring_type);
gboolean gimp_gradient_segment_range_set_blending_function (const gchar *name,
gint start_segment,
gint end_segment,
GimpGradientSegmentType blending_function);
gboolean gimp_gradient_segment_range_set_coloring_type (const gchar *name,
gint start_segment,
gint end_segment,
GimpGradientSegmentColor coloring_type);
gboolean gimp_gradient_segment_range_flip (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_replicate (const gchar *name,
gint start_segment,
gint end_segment,
gint replicate_times);
gboolean gimp_gradient_segment_range_split_midpoint (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_split_uniform (const gchar *name,
gint start_segment,
gint end_segment,
gint split_parts);
gboolean gimp_gradient_segment_range_delete (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_redistribute_handles (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_colors (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_opacity (const gchar *name,
gint start_segment,
gint end_segment);
gdouble gimp_gradient_segment_range_move (const gchar *name,
gint start_segment,
gint end_segment,
gdouble delta,
gboolean control_compress);
G_END_DECLS

View File

@ -22,6 +22,8 @@
#include "config.h"
#include <string.h>
#include "gimp.h"
#include "gimpui.h"
@ -110,9 +112,12 @@ gimp_gradient_select_widget_new (const gchar *title,
gradient_sel->sample_size = CELL_WIDTH;
gradient_sel->reverse = FALSE;
gradient_sel->button = gtk_button_new ();
if (! gradient_name || ! strlen (gradient_name))
gradient_sel->gradient_name = gimp_context_get_gradient ();
else
gradient_sel->gradient_name = g_strdup (gradient_name);
gradient_sel->gradient_name = g_strdup (gradient_name);
gradient_sel->button = gtk_button_new ();
g_signal_connect (gradient_sel->button, "clicked",
G_CALLBACK (gimp_gradient_select_widget_clicked),
@ -193,24 +198,28 @@ gimp_gradient_select_widget_set (GtkWidget *widget,
else
{
gchar *name;
gdouble *gradient_data;
gint width;
gint n_samples;
gdouble *samples;
name = gimp_gradients_get_gradient_data (gradient_name,
gradient_sel->sample_size,
gradient_sel->reverse,
&width,
&gradient_data);
if (! gradient_name || ! strlen (gradient_name))
name = gimp_context_get_gradient ();
else
name = g_strdup (gradient_name);
if (name)
{
if (gimp_gradient_get_uniform_samples (name,
gradient_sel->sample_size,
gradient_sel->reverse,
&n_samples,
&samples))
{
gimp_gradient_select_widget_callback (name,
width, gradient_data,
n_samples, samples,
FALSE, gradient_sel);
g_free (name);
g_free (gradient_data);
g_free (samples);
}
g_free (name);
}
}
@ -285,26 +294,20 @@ gimp_gradient_select_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
GradientSelect *gradient_sel)
{
gchar *name;
gdouble *data;
gint width;
gint n_samples;
gdouble *samples;
name = gimp_gradients_get_gradient_data (gradient_sel->gradient_name,
allocation->width,
gradient_sel->reverse,
&width,
&data);
if (name)
if (gimp_gradient_get_uniform_samples (gradient_sel->gradient_name,
allocation->width,
gradient_sel->reverse,
&n_samples,
&samples))
{
gradient_sel->sample_size = allocation->width;
gradient_sel->width = width;
g_free (gradient_sel->gradient_name);
gradient_sel->gradient_name = name;
gradient_sel->width = n_samples;
g_free (gradient_sel->gradient_data);
gradient_sel->gradient_data = data;
gradient_sel->gradient_data = samples;
}
}

View File

@ -102,15 +102,11 @@ gimp_gradients_get_list (const gchar *filter,
* @num_samples: The number of samples to take.
* @reverse: Use the reverse gradient.
*
* Sample the active gradient in uniform parts.
* This procedure is deprecated! Use
* 'gimp_gradient_get_uniform_samples' instead.
*
* This procedure samples the active gradient in the specified number
* of uniform parts. It returns a list of floating-point values which
* correspond to the RGBA values for each sample. The minimum number of
* samples to take is 2, in which case the returned colors will
* correspond to the { 0.0, 1.0 } positions in the gradient. For
* example, if the number of samples is 3, the procedure will return
* the colors at positions { 0.0, 0.5, 1.0 }.
* This procedure is deprecated! Use
* 'gimp_gradient_get_uniform_samples' instead.
*
* Returns: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
*/
@ -148,14 +144,11 @@ gimp_gradients_sample_uniform (gint num_samples,
* @positions: The list of positions to sample along the gradient.
* @reverse: Use the reverse gradient.
*
* Sample the active gradient in custom positions.
* This procedure is deprecated! Use 'gimp_gradient_get_custom_samples'
* instead.
*
* This procedure samples the active gradient in the specified number
* of points. The procedure will sample the gradient in the specified
* positions from the list. The left endpoint of the gradient
* corresponds to position 0.0, and the right endpoint corresponds to
* 1.0. The procedure returns a list of floating-point values which
* correspond to the RGBA values for each sample.
* This procedure is deprecated! Use 'gimp_gradient_get_custom_samples'
* instead.
*
* Returns: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
*/
@ -197,10 +190,11 @@ gimp_gradients_sample_custom (gint num_samples,
* @width: The gradient sample width (r,g,b,a).
* @grad_data: The gradient sample data.
*
* Retrieve information about the specified gradient (including data).
* This procedure is deprecated! Use
* 'gimp_gradient_get_uniform_samples' instead.
*
* This procedure retrieves information about the gradient. This
* includes the gradient name, and the sample data for the gradient.
* This procedure is deprecated! Use
* 'gimp_gradient_get_uniform_samples' instead.
*
* Returns: The gradient name.
*/

View File

@ -32,16 +32,22 @@ G_BEGIN_DECLS
gboolean gimp_gradients_refresh (void);
gchar** gimp_gradients_get_list (const gchar *filter,
gint *num_gradients);
#ifndef GIMP_DISABLE_DEPRECATED
gdouble* gimp_gradients_sample_uniform (gint num_samples,
gboolean reverse);
#endif /* GIMP_DISABLE_DEPRECATED */
#ifndef GIMP_DISABLE_DEPRECATED
gdouble* gimp_gradients_sample_custom (gint num_samples,
const gdouble *positions,
gboolean reverse);
#endif /* GIMP_DISABLE_DEPRECATED */
#ifndef GIMP_DISABLE_DEPRECATED
gchar* gimp_gradients_get_gradient_data (const gchar *name,
gint sample_size,
gboolean reverse,
gint *width,
gdouble **grad_data);
#endif /* GIMP_DISABLE_DEPRECATED */
G_END_DECLS

View File

@ -59,7 +59,7 @@ gimp_palette_new (const gchar *name)
/**
* gimp_palette_duplicate:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
*
* Duplicates a palette
*
@ -91,7 +91,7 @@ gimp_palette_duplicate (const gchar *name)
/**
* gimp_palette_rename:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
* @new_name: The new name of the palette.
*
* Rename a palette
@ -126,7 +126,7 @@ gimp_palette_rename (const gchar *name,
/**
* gimp_palette_delete:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
*
* Deletes a palette
*
@ -157,7 +157,7 @@ gimp_palette_delete (const gchar *name)
/**
* gimp_palette_get_info:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
* @num_colors: The number of colors in the palette.
*
* Retrieve information about the specified palette.
@ -196,7 +196,7 @@ gimp_palette_get_info (const gchar *name,
/**
* gimp_palette_add_entry:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
* @entry_name: The name of the entry.
* @color: The new entry's color color.
* @entry_num: The index of the added entry.
@ -241,7 +241,7 @@ gimp_palette_add_entry (const gchar *name,
/**
* gimp_palette_delete_entry:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
* @entry_num: The index of the added entry.
*
* Deletes a palette entry from the specified palette.
@ -276,7 +276,7 @@ gimp_palette_delete_entry (const gchar *name,
/**
* gimp_palette_entry_get_color:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
* @entry_num: The entry to retrieve.
* @color: The color requested.
*
@ -317,7 +317,7 @@ gimp_palette_entry_get_color (const gchar *name,
/**
* gimp_palette_entry_set_color:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
* @entry_num: The entry to retrieve.
* @color: The new color.
*
@ -356,7 +356,7 @@ gimp_palette_entry_set_color (const gchar *name,
/**
* gimp_palette_entry_get_name:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
* @entry_num: The entry to retrieve.
* @entry_name: The name requested.
*
@ -399,7 +399,7 @@ gimp_palette_entry_get_name (const gchar *name,
/**
* gimp_palette_entry_set_name:
* @name: The palette name (\"\" means currently active palette).
* @name: The palette name.
* @entry_num: The entry to retrieve.
* @entry_name: The new name.
*

View File

@ -23,11 +23,13 @@
#include "config.h"
#include <string.h>
#include "gimp.h"
/**
* gimp_pattern_get_info:
* @name: The pattern name (\"\" means currently active pattern).
* @name: The pattern name.
* @width: The pattern width.
* @height: The pattern height.
* @bpp: The pattern bpp.
@ -73,3 +75,63 @@ gimp_pattern_get_info (const gchar *name,
return success;
}
/**
* gimp_pattern_get_pixels:
* @name: The pattern name.
* @width: The pattern width.
* @height: The pattern height.
* @bpp: The pattern bpp.
* @num_mask_bytes: Length of pattern mask data.
* @mask_bytes: The pattern mask data.
*
* Retrieve information about the specified pattern (including pixels).
*
* This procedure retrieves information about the specified. This
* includes the pattern extents (width and height), its bpp and its
* pixel data.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.2
*/
gboolean
gimp_pattern_get_pixels (const gchar *name,
gint *width,
gint *height,
gint *bpp,
gint *num_mask_bytes,
guint8 **mask_bytes)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_pattern_get_pixels",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
*width = 0;
*height = 0;
*bpp = 0;
*num_mask_bytes = 0;
*mask_bytes = NULL;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*width = return_vals[1].data.d_int32;
*height = return_vals[2].data.d_int32;
*bpp = return_vals[3].data.d_int32;
*num_mask_bytes = return_vals[4].data.d_int32;
*mask_bytes = g_new (guint8, *num_mask_bytes);
memcpy (*mask_bytes, return_vals[5].data.d_int8array,
*num_mask_bytes * sizeof (guint8));
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}

View File

@ -29,10 +29,16 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_pattern_get_info (const gchar *name,
gint *width,
gint *height,
gint *bpp);
gboolean gimp_pattern_get_info (const gchar *name,
gint *width,
gint *height,
gint *bpp);
gboolean gimp_pattern_get_pixels (const gchar *name,
gint *width,
gint *height,
gint *bpp,
gint *num_mask_bytes,
guint8 **mask_bytes);
G_END_DECLS

View File

@ -22,6 +22,8 @@
#include "config.h"
#include <string.h>
#include "gimp.h"
#include "gimpui.h"
@ -149,13 +151,17 @@ gimp_pattern_select_widget_new (const gchar *title,
pattern_sel);
/* Do initial pattern setup */
pattern_sel->pattern_name =
gimp_patterns_get_pattern_data (pattern_name,
&pattern_sel->width,
&pattern_sel->height,
&pattern_sel->bytes,
&mask_data_size,
&pattern_sel->mask_data);
if (! pattern_name || ! strlen (pattern_name))
pattern_sel->pattern_name = gimp_context_get_pattern ();
else
pattern_sel->pattern_name = g_strdup (pattern_name);
gimp_pattern_get_pixels (pattern_sel->pattern_name,
&pattern_sel->width,
&pattern_sel->height,
&pattern_sel->bytes,
&mask_data_size,
&pattern_sel->mask_data);
g_object_set_data (G_OBJECT (hbox), PATTERN_SELECT_DATA_KEY, pattern_sel);
@ -173,6 +179,8 @@ gimp_pattern_select_widget_close (GtkWidget *widget)
{
PatternSelect *pattern_sel;
g_return_if_fail (GTK_IS_WIDGET (widget));
pattern_sel = g_object_get_data (G_OBJECT (widget), PATTERN_SELECT_DATA_KEY);
g_return_if_fail (pattern_sel != NULL);
@ -199,6 +207,8 @@ gimp_pattern_select_widget_set (GtkWidget *widget,
{
PatternSelect *pattern_sel;
g_return_if_fail (GTK_IS_WIDGET (widget));
pattern_sel = g_object_get_data (G_OBJECT (widget), PATTERN_SELECT_DATA_KEY);
g_return_if_fail (pattern_sel != NULL);
@ -217,21 +227,25 @@ gimp_pattern_select_widget_set (GtkWidget *widget,
guint8 *mask_data;
gchar *name;
name = gimp_patterns_get_pattern_data (pattern_name,
&width,
&height,
&bytes,
&mask_data_size,
&mask_data);
if (! pattern_name || ! strlen (pattern_name))
name = gimp_context_get_pattern ();
else
name = g_strdup (pattern_name);
if (name)
if (gimp_pattern_get_pixels (name,
&width,
&height,
&bytes,
&mask_data_size,
&mask_data))
{
gimp_pattern_select_widget_callback (name, width, height, bytes,
mask_data, FALSE, pattern_sel);
g_free (name);
g_free (mask_data);
}
g_free (name);
}
}

View File

@ -143,12 +143,9 @@ gimp_patterns_get_pattern (gint *width,
* @length: Length of pattern mask data.
* @mask_data: The pattern mask data.
*
* Retrieve information about the currently active pattern (including
* data).
* This procedure is deprecated! Use 'gimp_pattern_get_data' instead.
*
* This procedure retrieves information about the currently active
* pattern. This includes the pattern name, and the pattern extents
* (width and height). It also returns the pattern data.
* This procedure is deprecated! Use 'gimp_pattern_get_data' instead.
*
* Returns: The pattern name.
*/

View File

@ -36,12 +36,14 @@ gchar** gimp_patterns_get_list (const gchar *filter,
gchar* gimp_patterns_get_pattern (gint *width,
gint *height);
#endif /* GIMP_DISABLE_DEPRECATED */
#ifndef GIMP_DISABLE_DEPRECATED
gchar* gimp_patterns_get_pattern_data (const gchar *name,
gint *width,
gint *height,
gint *mask_bpp,
gint *length,
guint8 **mask_data);
#endif /* GIMP_DISABLE_DEPRECATED */
G_END_DECLS

View File

@ -20,6 +20,7 @@
#define ZOOM_UNDO_SIZE 100
static gint n_gradient_samples = 0;
static gdouble *gradient_samples = NULL;
static gchar *gradient_name = NULL;
static gboolean ready_now = FALSE;
@ -256,8 +257,6 @@ static void
explorer_number_of_colors_callback (GtkAdjustment *adjustment,
gpointer data)
{
gint dummy;
gimp_int_adjustment_update (adjustment, data);
g_free (gradient_samples);
@ -265,11 +264,11 @@ explorer_number_of_colors_callback (GtkAdjustment *adjustment,
if (! gradient_name)
gradient_name = gimp_context_get_gradient ();
gimp_gradients_get_gradient_data (gradient_name,
wvals.ncolors,
wvals.gradinvert,
&dummy,
&gradient_samples);
gimp_gradient_get_uniform_samples (gradient_name,
wvals.ncolors,
wvals.gradinvert,
&n_gradient_samples,
&gradient_samples);
set_cmap_preview ();
dialog_update_preview ();
@ -282,18 +281,16 @@ explorer_gradient_select_callback (const gchar *name,
gboolean dialog_closing,
gpointer data)
{
gint dummy;
g_free (gradient_name);
g_free (gradient_samples);
gradient_name = g_strdup (name);
gimp_gradients_get_gradient_data (gradient_name,
wvals.ncolors,
wvals.gradinvert,
&dummy,
&gradient_samples);
gimp_gradient_get_uniform_samples (gradient_name,
wvals.ncolors,
wvals.gradinvert,
&n_gradient_samples,
&gradient_samples);
if (wvals.colormode == 1)
{
@ -303,7 +300,8 @@ explorer_gradient_select_callback (const gchar *name,
}
static void
preview_draw_crosshair (gint px, gint py)
preview_draw_crosshair (gint px,
gint py)
{
gint x, y;
guchar *p_ul;
@ -1135,8 +1133,13 @@ explorer_dialog (void)
"the gradient editor"), NULL);
gradient_name = gimp_context_get_gradient ();
gradient_samples = gimp_gradients_sample_uniform (wvals.ncolors,
wvals.gradinvert);
gimp_gradient_get_uniform_samples (gradient_name,
wvals.ncolors,
wvals.gradinvert,
&n_gradient_samples,
&gradient_samples);
gradient = gimp_gradient_select_widget_new (_("FractalExplorer Gradient"),
gradient_name,
explorer_gradient_select_callback,
@ -1500,8 +1503,17 @@ make_color_map (void)
* mode for noninteractive use (bug #103470).
*/
if (gradient_samples == NULL)
gradient_samples = gimp_gradients_sample_uniform (wvals.ncolors,
wvals.gradinvert);
{
gchar *gradient_name = gimp_context_get_gradient ();
gimp_gradient_get_uniform_samples (gradient_name,
wvals.ncolors,
wvals.gradinvert,
&n_gradient_samples,
&gradient_samples);
g_free (gradient_name);
}
redstretch = wvals.redstretch * 127.5;
greenstretch = wvals.greenstretch * 127.5;

View File

@ -194,15 +194,20 @@ gradmap (GimpDrawable *drawable)
static guchar *
get_samples (GimpDrawable *drawable)
{
gchar *gradient_name;
gint n_f_samples;
gdouble *f_samples, *f_samp; /* float samples */
guchar *b_samples, *b_samp; /* byte samples */
gint bpp, color, has_alpha, alpha;
gint i, j;
gradient_name = gimp_context_get_gradient ();
#ifdef __GNUC__
#warning FIXME: "reverse" hardcoded to FALSE.
#endif
f_samples = gimp_gradients_sample_uniform (NSAMPLES, FALSE);
gimp_gradient_get_uniform_samples (gradient_name, NSAMPLES, FALSE,
&n_f_samples, &f_samples);
bpp = gimp_drawable_bpp (drawable->drawable_id);
color = gimp_drawable_is_rgb (drawable->drawable_id);

View File

@ -2428,12 +2428,21 @@ p_fill_missing_colors (void)
static void
p_get_gradient (gint mode)
{
gdouble *f_samples, *f_samp; /* float samples */
gint l_lum;
gchar *name;
gint n_f_samples;
gdouble *f_samples;
gdouble *f_samp; /* float samples */
gint l_lum;
p_free_colors();
f_samples = gimp_gradients_sample_uniform (256 /* n_samples */,
mode == SMP_INV_GRADIENT);
p_free_colors ();
name = gimp_context_get_gradient ();
gimp_gradient_get_uniform_samples (name, 256 /* n_samples */,
mode == SMP_INV_GRADIENT,
&n_f_samples, &f_samples);
g_free (name);
for (l_lum = 0; l_lum < 256; l_lum++)
{

View File

@ -272,10 +272,18 @@ drawable_to_cmap (control_point *cp)
}
else if (GRADIENT_DRAWABLE == config.cmap_drawable)
{
gchar *name = gimp_context_get_gradient ();
gint num;
gdouble *g;
#ifdef __GNUC__
#warning FIXME: "reverse" hardcoded to FALSE.
#endif
gdouble *g = gimp_gradients_sample_uniform (256, FALSE);
gimp_gradient_get_uniform_samples (name, 256, FALSE,
&num, &g);
g_free (name);
for (i = 0; i < 256; i++)
for (j = 0; j < 3; j++)
cp->cmap[i][j] = g[i*4 + j];

View File

@ -586,8 +586,9 @@ gfig_read_gimp_style (Style *style,
gimp_context_get_background (&style->background);
style->brush_name = gimp_context_get_brush ();
gimp_brush_get_info (NULL, &style->brush_width, &style->brush_height);
gimp_brush_get_spacing (NULL, &style->brush_spacing);
gimp_brush_get_info (style->brush_name,
&style->brush_width, &style->brush_height);
gimp_brush_get_spacing (style->brush_name, &style->brush_spacing);
style->gradient = gimp_context_get_gradient ();
style->pattern = gimp_context_get_pattern ();
@ -688,7 +689,9 @@ void
mygimp_brush_info (gint *width,
gint *height)
{
if (gimp_brush_get_info (NULL, width, height))
gchar *name = gimp_context_get_brush ();
if (name && gimp_brush_get_info (name, width, height))
{
*width = MAX (*width, 32);
*height = MAX (*height, 32);
@ -698,5 +701,6 @@ mygimp_brush_info (gint *width,
g_message ("Failed to get brush info");
*width = *height = 48;
}
}
g_free (name);
}

View File

@ -4668,7 +4668,7 @@ gradient_get_blend (guchar *fg,
gint j;
guchar *v = values;
for (i=0; i<nvalues; i++)
for (i = 0; i < nvalues; i++)
{
x = (double) i / nvalues;
for (j = 0; j < 4; j++)
@ -4794,24 +4794,19 @@ gradient_get_values_real_external (const gchar *gradient_name,
gint nvalues,
gboolean reverse)
{
gchar *old_name;
gint n_tmp_values;
gdouble *tmp_values;
gint i;
gint j;
old_name = gimp_context_get_gradient ();
gimp_gradient_get_uniform_samples (gradient_name, nvalues, reverse,
&n_tmp_values, &tmp_values);
gimp_context_set_gradient (gradient_name);
tmp_values = gimp_gradients_sample_uniform (nvalues, reverse);
for (i = 0; i < nvalues; i++)
for (j = 0; j < 4; j++)
values[4*i+j] = (guchar) (tmp_values[4*i+j] * 255);
gimp_context_set_gradient (old_name);
values[4 * i + j] = (guchar) (tmp_values[4 * i + j] * 255);
g_free (tmp_values);
g_free (old_name);
}
void

View File

@ -1045,13 +1045,20 @@ page_curl (gint32 drawable_id)
static guchar *
get_gradient_samples (gint32 drawable_id,
gboolean reverse)
{
gdouble *f_samples, *f_samp; /* float samples */
guchar *b_samples, *b_samp; /* byte samples */
gint bpp, color, has_alpha, alpha;
gint i, j;
{
gchar *gradient_name;
gint n_f_samples;
gdouble *f_samples, *f_samp; /* float samples */
guchar *b_samples, *b_samp; /* byte samples */
gint bpp, color, has_alpha, alpha;
gint i, j;
f_samples = gimp_gradients_sample_uniform (NGRADSAMPLES, reverse);
gradient_name = gimp_context_get_gradient ();
gimp_gradient_get_uniform_samples (gradient_name, NGRADSAMPLES, reverse,
&n_f_samples, &f_samples);
g_free (gradient_name);
bpp = gimp_drawable_bpp (drawable_id);
color = gimp_drawable_is_rgb (drawable_id);

View File

@ -61,7 +61,7 @@
(if (= color-method 1)
; option 1
; Just return the gradient
(cdr (gimp-gradients-get-gradient-data grad (min steps 50) FALSE))
(gimp-gradient-get-uniform-samples grad (min steps 50) FALSE)
; option 2
; The returned list is such that the gradient appears two times, once
@ -69,7 +69,7 @@
; jumps if we go beyond the edge
(let* (
; Sample the gradient into array "gr".
(gr (cdr (gimp-gradients-get-gradient-data grad (/ (min steps 50) 2) FALSE)))
(gr (gimp-gradient-get-uniform-samples grad (/ (min steps 50) 2) FALSE))
(grn (car gr)) ; length of sample array.
(gra (cadr gr)) ; array of color samples (R1,G1,B1,A1, R2,....)

View File

@ -27,8 +27,7 @@ sub mitch_misc {
sub brush_arg () {{
name => 'name',
type => 'string',
desc => 'The brush name ("" means currently active brush)',
null_ok => '1'
desc => 'The brush name'
}}
sub spacing_arg () {{
@ -37,19 +36,6 @@ sub spacing_arg () {{
desc => 'The brush spacing: %%desc%%'
}}
my $get_brush_from_name = <<'CODE';
if (name && strlen (name))
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container,
name);
}
else
{
brush = gimp_context_get_brush (context);
}
CODE
# The defs
@ -103,9 +89,10 @@ sub brush_duplicate {
%invoke = (
vars => [ 'GimpBrush *brush = NULL',
'GimpBrush *brush_copy = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_brush_from_name
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush)
{
@ -142,9 +129,10 @@ sub brush_rename {
%invoke = (
vars => [ 'GimpBrush *brush = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_brush_from_name
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush && GIMP_DATA (brush)->writable)
gimp_object_set_name (GIMP_OBJECT (brush), new_name);
@ -167,9 +155,10 @@ sub brush_delete {
%invoke = (
vars => [ 'GimpBrush *brush = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_brush_from_name
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush && GIMP_DATA (brush)->deletable)
{
@ -216,9 +205,10 @@ HELP
%invoke = (
vars => [ 'GimpBrush *brush = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_brush_from_name
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
success = (brush != NULL);
}
@ -244,15 +234,16 @@ HELP
@outargs = (
&spacing_arg
);
$outargs[0]->{alias} = 'gimp_brush_get_spacing (gimp_context_get_brush (context))';
$outargs[0]->{alias} = 'gimp_brush_get_spacing (brush)';
$outargs[0]->{no_declare} = 1;
$outargs[0]->{void_ret} = 1;
%invoke = (
vars => [ 'GimpBrush *brush = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_brush_from_name
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
success = (brush != NULL);
}
@ -277,9 +268,10 @@ HELP
%invoke = (
vars => [ 'GimpBrush *brush = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_brush_from_name
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush && GIMP_DATA (brush)->writable)
gimp_brush_set_spacing (brush, spacing);
@ -290,13 +282,62 @@ CODE
);
}
sub brush_get_pixels {
$blurb = <<'BLURB';
Retrieve information about the specified brush.
BLURB
$help = <<'HELP';
This procedure retrieves information about the specified brush. This
includes the brush extents (width and height) and its pixels data.
HELP
&mitch_misc;
@inargs = (
&brush_arg
);
@outargs = (
{ name => 'width', type => 'int32', no_declare => '1',
alias => 'brush->mask->width', void_ret => '1',
desc => "The brush width" },
{ name => 'height', type => 'int32', no_declare => '1',
alias => 'brush->mask->height',
desc => "The brush height" },
{ name => 'mask_bytes', type => 'int8array', init => 1,
desc => 'The brush mask data',
array => { init => 1,
desc => 'Length of brush mask data' } }
);
%invoke = (
vars => [ 'GimpBrush *brush = NULL' ],
code => <<'CODE'
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush)
{
num_mask_bytes = brush->mask->height * brush->mask->width;
mask_bytes = g_memdup (temp_buf_data (brush->mask), num_mask_bytes);
}
else
success = FALSE;
}
CODE
);
}
@headers = qw(<string.h> "base/temp-buf.h"
"core/gimp.h" "core/gimplist.h" "core/gimpbrush.h"
"core/gimpcontext.h" "core/gimpdatafactory.h");
@procs = qw(brush_new brush_duplicate brush_rename brush_delete
brush_get_info brush_get_spacing brush_set_spacing);
brush_get_info brush_get_pixels
brush_get_spacing brush_set_spacing);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Brush';

View File

@ -172,18 +172,11 @@ sub brushes_set_spacing {
}
sub brushes_get_brush_data {
$blurb = <<'BLURB';
Retrieve information about the currently active brush (including data).
BLURB
$blurb = $help = "This procedure is deprecated! Use 'gimp_brush_get_pixels' instead.";
$help = <<'HELP';
This procedure retrieves information about the currently active brush. This
includes the brush name, and the brush extents (width and height). It also
returns the brush data.
HELP
$author = $copyright = $date = '';
$author = $copyright = 'Andy Thomas';
$date = '1998';
$deprecated = 1;
@inargs = (
&brush_arg

View File

@ -21,26 +21,18 @@ sub shlomi_misc {
$since = '2.2';
}
sub federico_misc {
$author = $copyright = 'Federico Mena Quintero';
$date = '1997';
$since = '2.2';
}
sub gradient_arg () {{
name => 'name',
type => 'string',
desc => 'The gradient name ("" means currently active gradient)',
null_ok => '1'
desc => 'The gradient name'
}}
my $get_gradient_from_name = <<'CODE';
if (name && strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
CODE
sub _gen_gradient_search_for_segment_code
{
my $action_on_success = shift;
@ -54,23 +46,24 @@ sub _gen_gradient_search_for_segment_code
return <<"CODE";
{
$get_gradient_from_name
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
success = (gradient != NULL);
if (success)
if (gradient)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
if (seg)
{
$action_on_success
}
else
success = FALSE;
}
else
success = FALSE;
}
CODE
@ -306,7 +299,8 @@ sub gradient_duplicate {
'GimpGradient *gradient_copy = NULL' ],
code => <<"CODE"
{
$get_gradient_from_name
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
if (gradient)
{
@ -345,7 +339,8 @@ sub gradient_rename {
vars => [ 'GimpGradient *gradient = NULL' ],
code => <<"CODE"
{
$get_gradient_from_name
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
if (gradient && GIMP_DATA (gradient)->writable)
gimp_object_set_name (GIMP_OBJECT (gradient), new_name);
@ -370,7 +365,8 @@ sub gradient_delete {
vars => [ 'GimpGradient *gradient = NULL' ],
code => <<"CODE"
{
$get_gradient_from_name
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
if (gradient && GIMP_DATA (gradient)->deletable)
{
@ -393,6 +389,149 @@ CODE
);
}
sub sample_num_arg {
{ name => 'num_samples', type => $_[0] . 'int32',
desc => 'The number of samples to take' }
}
sub reverse_arg {
{ name => 'reverse', type => 'boolean',
desc => 'Use the reverse gradient (%%desc%%)' }
}
sub sample_outargs {
@outargs = (
{ name => 'color_samples', type => 'floatarray', init => 1,
void_ret => 1,
desc => 'Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }',
array => { init => 1,
desc => 'Length of the color_samples array (4 *
num_samples)' } }
);
}
sub gradient_get_uniform_samples {
$blurb = 'Sample the specified in uniform parts.';
$help = <<'HELP';
This procedure samples the active gradient in the
specified number of uniform parts. It returns a list of floating-point values
which correspond to the RGBA values for each sample. The minimum number of
samples to take is 2, in which case the returned colors will correspond to the
{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples
is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.
HELP
&federico_misc;
@inargs = (
&gradient_arg,
&sample_num_arg('2 <= '),
&reverse_arg
);
&sample_outargs;
%invoke = (
vars => [ 'GimpGradient *gradient' ],
code => <<'CODE'
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
if (gradient)
{
gdouble pos = 0.0;
gdouble delta = 1.0 / (num_samples - 1);
gdouble *sample;
num_color_samples = num_samples * 4;
sample = color_samples = g_new (gdouble, num_color_samples);
while (num_samples--)
{
GimpRGB color;
gimp_gradient_get_color_at (gradient, pos, reverse, &color);
*sample++ = color.r;
*sample++ = color.g;
*sample++ = color.b;
*sample++ = color.a;
pos += delta;
}
}
else
success = FALSE;
}
CODE
);
}
sub gradient_get_custom_samples {
$blurb = 'Sample the spacified gradient in custom positions.';
$help = <<'HELP';
This procedure samples the active gradient in the specified number of
points. The procedure will sample the gradient in the specified
positions from the list. The left endpoint of the gradient corresponds
to position 0.0, and the right endpoint corresponds to 1.0. The
procedure returns a list of floating-point values which correspond to
the RGBA values for each sample.
HELP
&federico_misc;
@inargs = (
&gradient_arg,
{ name => 'positions',
type => 'floatarray',
desc => 'The list of positions to sample along the gradient',
alias => 'pos',
array => &sample_num_arg("") },
&reverse_arg
);
&sample_outargs;
%invoke = (
vars => [ 'GimpGradient *gradient' ],
code => <<'CODE'
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
if (gradient)
{
gdouble *sample;
num_color_samples = num_samples * 4;
sample = color_samples = g_new (gdouble, num_color_samples);
while (num_samples--)
{
GimpRGB color;
gimp_gradient_get_color_at (gradient, *pos, reverse, &color);
*sample++ = color.r;
*sample++ = color.g;
*sample++ = color.b;
*sample++ = color.a;
pos++;
}
}
else
success = FALSE;
}
CODE
);
}
sub gradient_segment_get_left_color
{
&_gen_gradient_get_side_color("left");
@ -532,7 +671,8 @@ sub _gen_gradient_operate_on_segments_range
vars => [ 'GimpGradient *gradient = NULL' ],
code => <<"CODE",
{
$get_gradient_from_name
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
if (gradient)
{
@ -814,6 +954,7 @@ CODE
"core/gimpdatafactory.h" "core/gimplist.h");
@procs = qw(gradient_new gradient_duplicate gradient_rename gradient_delete
gradient_get_uniform_samples gradient_get_custom_samples
gradient_segment_get_left_color gradient_segment_set_left_color
gradient_segment_get_right_color gradient_segment_set_right_color
gradient_segment_get_left_pos gradient_segment_set_left_pos

View File

@ -22,19 +22,6 @@ sub federico_misc {
$date = '1997';
}
my $get_gradient_from_name = <<'CODE';
if (name && strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
CODE
# The defs
@ -110,18 +97,11 @@ sub sample_outargs {
}
sub gradients_sample_uniform {
$blurb = 'Sample the active gradient in uniform parts.';
$blurb = $help = "This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.";
$help = <<'HELP';
This procedure samples the active gradient in the
specified number of uniform parts. It returns a list of floating-point values
which correspond to the RGBA values for each sample. The minimum number of
samples to take is 2, in which case the returned colors will correspond to the
{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples
is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.
HELP
$author = $copyright = $date = '';
&federico_misc;
$deprecated = 1;
@inargs = (
&sample_num_arg('2 <= '),
@ -160,18 +140,11 @@ CODE
}
sub gradients_sample_custom {
$blurb = 'Sample the active gradient in custom positions.';
$blurb = $help = "This procedure is deprecated! Use 'gimp_gradient_get_custom_samples' instead.";
$help = <<'HELP';
This procedure samples the active gradient in the specified number of
points. The procedure will sample the gradient in the specified
positions from the list. The left endpoint of the gradient corresponds
to position 0.0, and the right endpoint corresponds to 1.0. The
procedure returns a list of floating-point values which correspond to
the RGBA values for each sample.
HELP
$author = $copyright = $date = '';
&federico_misc;
$deprecated = 1;
@inargs = (
{ name => 'positions',
@ -220,16 +193,11 @@ sub sample_size_arg {
}
sub gradients_get_gradient_data {
$blurb = <<'BLURB';
Retrieve information about the specified gradient (including data).
BLURB
$blurb = $help = "This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.";
$help = <<'HELP';
This procedure retrieves information about the gradient. This includes the
gradient name, and the sample data for the gradient.
HELP
$author = $copyright = $date = '';
&federico_misc;
$deprecated = 1;
@inargs = (
{ name => 'name', type => 'string',
@ -254,7 +222,16 @@ HELP
vars => [ 'GimpGradient *gradient = NULL' ],
code => <<"CODE"
{
$get_gradient_from_name
if (name && strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{

View File

@ -27,8 +27,7 @@ sub mitch_misc {
sub palette_arg () {{
name => 'name',
type => 'string',
desc => 'The palette name ("" means currently active palette)',
null_ok => '1'
desc => 'The palette name.'
}}
my $get_palette_from_name = <<'CODE';
@ -97,9 +96,10 @@ sub palette_duplicate {
%invoke = (
vars => [ 'GimpPalette *palette = NULL',
'GimpPalette *palette_copy = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette)
{
@ -136,9 +136,10 @@ sub palette_rename {
%invoke = (
vars => [ 'GimpPalette *palette = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
gimp_object_set_name (GIMP_OBJECT (palette), new_name);
@ -161,9 +162,10 @@ sub palette_delete {
%invoke = (
vars => [ 'GimpPalette *palette = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->deletable)
{
@ -208,9 +210,10 @@ HELP
%invoke = (
vars => [ 'GimpPalette *palette = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
success = (palette != NULL);
}
@ -245,9 +248,10 @@ HELP
%invoke = (
vars => [ 'GimpPalette *palette = NULL',
'GimpPaletteEntry *entry = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
entry = gimp_palette_add_entry (palette, entry_name, &color);
@ -277,9 +281,10 @@ HELP
%invoke = (
vars => [ 'GimpPalette *palette = NULL',
'GimpPaletteEntry *entry = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
{
@ -323,9 +328,10 @@ HELP
%invoke = (
vars => [ 'GimpPalette *palette = NULL',
'GimpPaletteEntry *entry = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette)
{
@ -366,9 +372,10 @@ HELP
%invoke = (
vars => [ 'GimpPalette *palette = NULL',
'GimpPaletteEntry *entry = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
{
@ -415,9 +422,10 @@ HELP
%invoke = (
vars => [ 'GimpPalette *palette = NULL',
'GimpPaletteEntry *entry = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette)
{
@ -454,9 +462,10 @@ HELP
%invoke = (
vars => [ 'GimpPalette *palette = NULL',
'GimpPaletteEntry *entry = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_palette_from_name
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette && GIMP_DATA (palette)->writable)
{

View File

@ -27,23 +27,9 @@ sub mitch_misc {
sub pattern_arg () {{
name => 'name',
type => 'string',
desc => 'The pattern name ("" means currently active pattern)',
null_ok => '1'
desc => 'The pattern name.'
}}
my $get_pattern_from_name = <<'CODE';
if (name && strlen (name))
{
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container,
name);
}
else
{
pattern = gimp_context_get_pattern (context);
}
CODE
# The defs
@ -74,9 +60,10 @@ HELP
%invoke = (
vars => [ 'GimpPattern *pattern = NULL' ],
code => <<"CODE"
code => <<'CODE'
{
$get_pattern_from_name
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
success = (pattern != NULL);
}
@ -84,12 +71,66 @@ CODE
);
}
sub pattern_get_pixels {
$blurb = <<'BLURB';
Retrieve information about the specified pattern (including pixels).
BLURB
$help = <<'HELP';
This procedure retrieves information about the specified. This
includes the pattern extents (width and height), its bpp and its pixel
data.
HELP
&mitch_misc;
@inargs = (
&pattern_arg
);
@outargs = (
{ name => 'width', type => 'int32', no_declare => '1',
alias => 'pattern->mask->width', void_ret => '1',
desc => "The pattern width" },
{ name => 'height', type => 'int32', no_declare => '1',
alias => 'pattern->mask->height',
desc => "The pattern height" },
{ name => 'bpp', type => 'int32', no_declare => '1',
alias => 'pattern->mask->bytes',
desc => "The pattern bpp" },
{ name => 'mask_bytes', type => 'int8array', init => 1,
desc => 'The pattern mask data',
array => { init => 1,
desc => 'Length of pattern mask data' } }
);
%invoke = (
vars => [ 'GimpPattern *pattern = NULL' ],
code => <<'CODE'
{
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
if (pattern)
{
num_mask_bytes = pattern->mask->height * pattern->mask->width *
pattern->mask->bytes;
mask_bytes = g_memdup (temp_buf_data (pattern->mask),
num_mask_bytes);
}
else
success = FALSE;
}
CODE
);
}
@headers = qw(<string.h> "base/temp-buf.h" "core/gimp.h"
"core/gimpcontext.h" "core/gimplist.h"
"core/gimpdatafactory.h" "core/gimppattern.h" );
@procs = qw(pattern_get_info);
@procs = qw(pattern_get_info pattern_get_pixels);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Pattern';

View File

@ -120,20 +120,15 @@ sub patterns_get_pattern {
}
sub patterns_get_pattern_data {
$blurb = <<'BLURB';
Retrieve information about the currently active pattern (including data).
BLURB
$blurb = $help = "This procedure is deprecated! Use 'gimp_pattern_get_data' instead.";
$help = <<'HELP';
This procedure retrieves information about the currently active pattern. This
includes the pattern name, and the pattern extents (width and height). It also
returns the pattern data.
HELP
$author = $copyright = $data = '';
$author = $copyright = 'Andy Thomas';
$date = '1998';
$deprecated = 1;
@inargs = ( &pattern_arg );
@inargs = (
&pattern_arg
);
$inargs[0]->{desc} = 'The pattern name ("" means currently active pattern)';
@outargs = (