/* LIBPIKA - The PIKA Library
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
 *
 * pikachannel_pdb.c
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <https://www.gnu.org/licenses/>.
 */

/* NOTE: This file is auto-generated by pdbgen.pl */

#include "config.h"

#include "stamp-pdbgen.h"

#include "pika.h"


/**
 * SECTION: pikachannel
 * @title: pikachannel
 * @short_description: Functions for manipulating channels.
 *
 * Functions for manipulating channels.
 **/


/**
 * _pika_channel_new:
 * @image: The image to which to add the channel.
 * @width: The channel width.
 * @height: The channel height.
 * @name: The channel name.
 * @opacity: The channel opacity.
 * @color: The channel compositing color.
 *
 * Create a new channel.
 *
 * This procedure creates a new channel with the specified width,
 * height, name, opacity and color.
 * The new channel still needs to be added to the image, as this is not
 * automatic. Add the new channel with pika_image_insert_channel().
 * Other attributes, such as channel visibility, should be set with
 * explicit procedure calls.
 * The channel's contents are undefined initially.
 *
 * Returns: (transfer none): The newly created channel.
 **/
PikaChannel *
_pika_channel_new (PikaImage     *image,
                   gint           width,
                   gint           height,
                   const gchar   *name,
                   gdouble        opacity,
                   const PikaRGB *color)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  PikaChannel *channel = NULL;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_IMAGE, image,
                                          G_TYPE_INT, width,
                                          G_TYPE_INT, height,
                                          G_TYPE_STRING, name,
                                          G_TYPE_DOUBLE, opacity,
                                          PIKA_TYPE_RGB, color,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-new",
                                               args);
  pika_value_array_unref (args);

  if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
    channel = PIKA_VALUES_GET_CHANNEL (return_vals, 1);

  pika_value_array_unref (return_vals);

  return channel;
}

/**
 * pika_channel_new_from_component:
 * @image: 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.
 * The new channel still needs to be added to the image, as this is not
 * automatic. Add the new channel with pika_image_insert_channel().
 * Other attributes, such as channel visibility, should be set with
 * explicit procedure calls.
 *
 * Returns: (transfer none): The newly created channel.
 *
 * Since: 2.4
 **/
PikaChannel *
pika_channel_new_from_component (PikaImage       *image,
                                 PikaChannelType  component,
                                 const gchar     *name)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  PikaChannel *channel = NULL;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_IMAGE, image,
                                          PIKA_TYPE_CHANNEL_TYPE, component,
                                          G_TYPE_STRING, name,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-new-from-component",
                                               args);
  pika_value_array_unref (args);

  if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
    channel = PIKA_VALUES_GET_CHANNEL (return_vals, 1);

  pika_value_array_unref (return_vals);

  return channel;
}

/**
 * pika_channel_copy:
 * @channel: The channel to copy.
 *
 * Copy a channel.
 *
 * This procedure copies the specified channel and returns the copy.
 * The new channel still needs to be added to the image, as this is not
 * automatic. Add the new channel with pika_image_insert_channel().
 *
 * Returns: (transfer none): The newly copied channel.
 **/
PikaChannel *
pika_channel_copy (PikaChannel *channel)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  PikaChannel *channel_copy = NULL;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_CHANNEL, channel,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-copy",
                                               args);
  pika_value_array_unref (args);

  if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
    channel_copy = PIKA_VALUES_GET_CHANNEL (return_vals, 1);

  pika_value_array_unref (return_vals);

  return channel_copy;
}

/**
 * pika_channel_combine_masks:
 * @channel1: The channel1.
 * @channel2: The channel2.
 * @operation: The selection operation.
 * @offx: x offset between upper left corner of channels: (second - first).
 * @offy: y offset between upper left corner of channels: (second - first).
 *
 * Combine two channel masks.
 *
 * This procedure combines two channel masks. The result is stored in
 * the first channel.
 *
 * Returns: TRUE on success.
 **/
gboolean
pika_channel_combine_masks (PikaChannel    *channel1,
                            PikaChannel    *channel2,
                            PikaChannelOps  operation,
                            gint            offx,
                            gint            offy)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  gboolean success = TRUE;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_CHANNEL, channel1,
                                          PIKA_TYPE_CHANNEL, channel2,
                                          PIKA_TYPE_CHANNEL_OPS, operation,
                                          G_TYPE_INT, offx,
                                          G_TYPE_INT, offy,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-combine-masks",
                                               args);
  pika_value_array_unref (args);

  success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;

  pika_value_array_unref (return_vals);

  return success;
}

/**
 * pika_channel_get_show_masked:
 * @channel: The channel.
 *
 * Get the composite method of the specified channel.
 *
 * This procedure returns the specified channel's composite method. If
 * it is TRUE, then the channel is composited with the image so that
 * masked regions are shown. Otherwise, selected regions are shown.
 *
 * Returns: The channel composite method.
 **/
gboolean
pika_channel_get_show_masked (PikaChannel *channel)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  gboolean show_masked = FALSE;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_CHANNEL, channel,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-get-show-masked",
                                               args);
  pika_value_array_unref (args);

  if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
    show_masked = PIKA_VALUES_GET_BOOLEAN (return_vals, 1);

  pika_value_array_unref (return_vals);

  return show_masked;
}

/**
 * pika_channel_set_show_masked:
 * @channel: The channel.
 * @show_masked: The new channel composite method.
 *
 * Set the composite method of the specified channel.
 *
 * This procedure sets the specified channel's composite method. If it
 * is TRUE, then the channel is composited with the image so that
 * masked regions are shown. Otherwise, selected regions are shown.
 *
 * Returns: TRUE on success.
 **/
gboolean
pika_channel_set_show_masked (PikaChannel *channel,
                              gboolean     show_masked)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  gboolean success = TRUE;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_CHANNEL, channel,
                                          G_TYPE_BOOLEAN, show_masked,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-set-show-masked",
                                               args);
  pika_value_array_unref (args);

  success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;

  pika_value_array_unref (return_vals);

  return success;
}

/**
 * pika_channel_get_opacity:
 * @channel: The channel.
 *
 * Get the opacity of the specified channel.
 *
 * This procedure returns the specified channel's opacity.
 *
 * Returns: The channel opacity.
 **/
gdouble
pika_channel_get_opacity (PikaChannel *channel)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  gdouble opacity = 0.0;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_CHANNEL, channel,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-get-opacity",
                                               args);
  pika_value_array_unref (args);

  if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
    opacity = PIKA_VALUES_GET_DOUBLE (return_vals, 1);

  pika_value_array_unref (return_vals);

  return opacity;
}

/**
 * pika_channel_set_opacity:
 * @channel: The channel.
 * @opacity: The new channel opacity.
 *
 * Set the opacity of the specified channel.
 *
 * This procedure sets the specified channel's opacity.
 *
 * Returns: TRUE on success.
 **/
gboolean
pika_channel_set_opacity (PikaChannel *channel,
                          gdouble      opacity)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  gboolean success = TRUE;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_CHANNEL, channel,
                                          G_TYPE_DOUBLE, opacity,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-set-opacity",
                                               args);
  pika_value_array_unref (args);

  success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;

  pika_value_array_unref (return_vals);

  return success;
}

/**
 * pika_channel_get_color:
 * @channel: The channel.
 * @color: (out caller-allocates): The channel compositing color.
 *
 * Get the compositing color of the specified channel.
 *
 * This procedure returns the specified channel's compositing color.
 *
 * Returns: TRUE on success.
 **/
gboolean
pika_channel_get_color (PikaChannel *channel,
                        PikaRGB     *color)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  gboolean success = TRUE;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_CHANNEL, channel,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-get-color",
                                               args);
  pika_value_array_unref (args);

  success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;

  if (success)
    PIKA_VALUES_GET_RGB (return_vals, 1, &*color);

  pika_value_array_unref (return_vals);

  return success;
}

/**
 * pika_channel_set_color:
 * @channel: The channel.
 * @color: The new channel compositing color.
 *
 * Set the compositing color of the specified channel.
 *
 * This procedure sets the specified channel's compositing color.
 *
 * Returns: TRUE on success.
 **/
gboolean
pika_channel_set_color (PikaChannel   *channel,
                        const PikaRGB *color)
{
  PikaValueArray *args;
  PikaValueArray *return_vals;
  gboolean success = TRUE;

  args = pika_value_array_new_from_types (NULL,
                                          PIKA_TYPE_CHANNEL, channel,
                                          PIKA_TYPE_RGB, color,
                                          G_TYPE_NONE);

  return_vals = _pika_pdb_run_procedure_array (pika_get_pdb (),
                                               "pika-channel-set-color",
                                               args);
  pika_value_array_unref (args);

  success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;

  pika_value_array_unref (return_vals);

  return success;
}
