Commit 6c659592 authored by Shlomi Fish's avatar Shlomi Fish Committed by Shlomi Fish

add the gimp_channel_new_from_component() PDB function.

2005-02-22  Shlomi Fish  <shlomif@iglu.org.il>

	* tools/pdbgen/pdb/channel.pdb: add the
	gimp_channel_new_from_component() PDB function.

	* libgimp/gimpchannel_pdb.c
	* app/pdb/channel_cmds.c: resultant files.

	* libgimp/gimp.def: add the new function to the def file

	* devel-docs/libgimp/libgimp-sections.txt: add the new function
	to devel-docs
parent 4d03c886
2005-02-22 Shlomi Fish <shlomif@iglu.org.il>
* tools/pdbgen/pdb/channel.pdb: add the
gimp_channel_new_from_component() PDB function.
* libgimp/gimpchannel_pdb.c
* app/pdb/channel_cmds.c: resultant files.
* libgimp/gimp.def: add the new function to the def file
* devel-docs/libgimp/libgimp-sections.txt: add the new function
to devel-docs
2005-02-22 Michael Natterer <mitch@gimp.org>
* app/tools/gimpmagnifytool.c (gimp_magnify_tool_init)
......
......@@ -33,6 +33,7 @@
#include "core/gimpimage.h"
static ProcRecord channel_new_proc;
static ProcRecord channel_new_from_component_proc;
static ProcRecord channel_copy_proc;
static ProcRecord channel_combine_masks_proc;
static ProcRecord channel_get_show_masked_proc;
......@@ -46,6 +47,7 @@ void
register_channel_procs (Gimp *gimp)
{
procedural_db_register (gimp, &channel_new_proc);
procedural_db_register (gimp, &channel_new_from_component_proc);
procedural_db_register (gimp, &channel_copy_proc);
procedural_db_register (gimp, &channel_combine_masks_proc);
procedural_db_register (gimp, &channel_get_show_masked_proc);
......@@ -171,6 +173,96 @@ static ProcRecord channel_new_proc =
{ { channel_new_invoker } }
};
static Argument *
channel_new_from_component_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpImage *gimage;
gint32 component;
gchar *name;
GimpChannel *channel = NULL;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (gimage))
success = FALSE;
component = args[1].value.pdb_int;
if (component < GIMP_RED_CHANNEL || component > GIMP_ALPHA_CHANNEL)
success = FALSE;
name = (gchar *) args[2].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
if (gimp_image_get_component_index (gimage, component) != -1)
channel = gimp_channel_new_from_component (gimage,
component, name, NULL);
if (channel)
gimp_item_set_visible (GIMP_ITEM (channel), FALSE, FALSE);
else
success = FALSE;
}
return_args = procedural_db_return_args (&channel_new_from_component_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (channel));
return return_args;
}
static ProcArg channel_new_from_component_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image to which to add the channel"
},
{
GIMP_PDB_INT32,
"component",
"The image component: { GIMP_RED_CHANNEL (0), GIMP_GREEN_CHANNEL (1), GIMP_BLUE_CHANNEL (2), GIMP_GRAY_CHANNEL (3), GIMP_INDEXED_CHANNEL (4), GIMP_ALPHA_CHANNEL (5) }"
},
{
GIMP_PDB_STRING,
"name",
"The channel name"
}
};
static ProcArg channel_new_from_component_outargs[] =
{
{
GIMP_PDB_CHANNEL,
"channel",
"The newly created channel"
}
};
static ProcRecord channel_new_from_component_proc =
{
"gimp_channel_new_from_component",
"Create a new channel from a color component",
"This procedure creates a new channel from a color component.",
"Shlomi Fish <shlomif@iglu.org.il>",
"Shlomi Fish",
"2005",
NULL,
GIMP_INTERNAL,
3,
channel_new_from_component_inargs,
1,
channel_new_from_component_outargs,
{ { channel_new_from_component_invoker } }
};
static Argument *
channel_copy_invoker (Gimp *gimp,
GimpContext *context,
......
2005-02-22 Shlomi Fish <shlomif@iglu.org.il>
* libgimp/libgimp-sections.txt: added new function
2005-02-14 Sven Neumann <sven@gimp.org>
* app/Makefile.am
......
......@@ -176,6 +176,7 @@ gimp_brushes_set_popup
<SECTION>
<FILE>gimpchannel</FILE>
gimp_channel_new
gimp_channel_new_from_component
gimp_channel_copy
gimp_channel_get_show_masked
gimp_channel_set_show_masked
......
......@@ -49,6 +49,7 @@ EXPORTS
gimp_channel_get_opacity
gimp_channel_get_show_masked
gimp_channel_new
gimp_channel_new_from_component
gimp_channel_set_color
gimp_channel_set_opacity
gimp_channel_set_show_masked
......
......@@ -76,6 +76,44 @@ _gimp_channel_new (gint32 image_ID,
return channel_ID;
}
/**
* gimp_channel_new_from_component:
* @image_ID: The image to which to add the channel.
* @component: The image component.
* @name: The channel name.
*
* Create a new channel from a color component
*
* This procedure creates a new channel from a color component.
*
* Returns: The newly created channel.
*
* Since: GIMP 2.4
*/
gint32
gimp_channel_new_from_component (gint32 image_ID,
GimpChannelType component,
const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 channel_ID = -1;
return_vals = gimp_run_procedure ("gimp_channel_new_from_component",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_INT32, component,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
channel_ID = return_vals[1].data.d_channel;
gimp_destroy_params (return_vals, nreturn_vals);
return channel_ID;
}
/**
* gimp_channel_copy:
* @channel_ID: The channel to copy.
......
......@@ -231,6 +231,48 @@ CODE
);
}
sub channel_new_from_component {
$blurb = 'Create a new channel from a color component';
$help = <<'HELP';
This procedure creates a new channel from a color component.
HELP
$author = 'Shlomi Fish <shlomif@iglu.org.il>';
$copyright = 'Shlomi Fish';
$date = '2005';
$since = '2.4';
@inargs = (
&std_image_arg,
{ name => 'component', type => 'enum GimpChannelType',
desc => 'The image component: { %%desc%% }' },
{ name => 'name', type => 'string',
desc => 'The channel name' },
);
$inargs[0]->{desc} .= ' to which to add the channel';
@outargs = (
{ name => 'channel', type => 'channel', init => 1,
desc => 'The newly created channel' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_image_get_component_index (gimage, component) != -1)
channel = gimp_channel_new_from_component (gimage,
component, name, NULL);
if (channel)
gimp_item_set_visible (GIMP_ITEM (channel), FALSE, FALSE);
else
success = FALSE;
}
CODE
);
}
&channel_accessors('show_masked', 'boolean', 'composite method', 0,
<<'CODE');
$help .= <<'HELP'
......@@ -248,7 +290,8 @@ CODE
&channel_accessors('color', 'color', 'compositing color', 0,
[ '$outargs[0]->{void_ret} = 1', '' ]);
unshift @procs, qw(channel_new channel_copy channel_combine_masks);
unshift @procs, qw(channel_new channel_new_from_component channel_copy
channel_combine_masks);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Channel';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment