home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gimpselection_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-25  |  15.5 KB  |  614 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpselection_pdb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * gimp_selection_bounds:
  28.  * @image_ID: The image.
  29.  * @non_empty: True if there is a selection.
  30.  * @x1: x coordinate of upper left corner of selection bounds.
  31.  * @y1: y coordinate of upper left corner of selection bounds.
  32.  * @x2: x coordinate of lower right corner of selection bounds.
  33.  * @y2: y coordinate of lower right corner of selection bounds.
  34.  *
  35.  * Find the bounding box of the current selection.
  36.  *
  37.  * This procedure returns whether there is a selection for the
  38.  * specified image. If there is one, the upper left and lower right
  39.  * corners of the bounding box are returned. These coordinates are
  40.  * relative to the image.
  41.  *
  42.  * Returns: TRUE on success.
  43.  */
  44. gboolean
  45. gimp_selection_bounds (gint32    image_ID,
  46.                gboolean *non_empty,
  47.                gint     *x1,
  48.                gint     *y1,
  49.                gint     *x2,
  50.                gint     *y2)
  51. {
  52.   GimpParam *return_vals;
  53.   gint nreturn_vals;
  54.   gboolean success = TRUE;
  55.  
  56.   return_vals = gimp_run_procedure ("gimp_selection_bounds",
  57.                     &nreturn_vals,
  58.                     GIMP_PDB_IMAGE, image_ID,
  59.                     GIMP_PDB_END);
  60.  
  61.   *non_empty = FALSE;
  62.   *x1 = 0;
  63.   *y1 = 0;
  64.   *x2 = 0;
  65.   *y2 = 0;
  66.  
  67.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  68.  
  69.   if (success)
  70.     {
  71.       *non_empty = return_vals[1].data.d_int32;
  72.       *x1 = return_vals[2].data.d_int32;
  73.       *y1 = return_vals[3].data.d_int32;
  74.       *x2 = return_vals[4].data.d_int32;
  75.       *y2 = return_vals[5].data.d_int32;
  76.     }
  77.  
  78.   gimp_destroy_params (return_vals, nreturn_vals);
  79.  
  80.   return success;
  81. }
  82.  
  83. /**
  84.  * gimp_selection_value:
  85.  * @image_ID: The image.
  86.  * @x: x coordinate of value.
  87.  * @y: y coordinate of value.
  88.  *
  89.  * Find the value of the selection at the specified coordinates.
  90.  *
  91.  * This procedure returns the value of the selection at the specified
  92.  * coordinates. If the coordinates lie out of bounds, 0 is returned.
  93.  *
  94.  * Returns: Value of the selection.
  95.  */
  96. gint
  97. gimp_selection_value (gint32 image_ID,
  98.               gint   x,
  99.               gint   y)
  100. {
  101.   GimpParam *return_vals;
  102.   gint nreturn_vals;
  103.   gint value = 0;
  104.  
  105.   return_vals = gimp_run_procedure ("gimp_selection_value",
  106.                     &nreturn_vals,
  107.                     GIMP_PDB_IMAGE, image_ID,
  108.                     GIMP_PDB_INT32, x,
  109.                     GIMP_PDB_INT32, y,
  110.                     GIMP_PDB_END);
  111.  
  112.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  113.     value = return_vals[1].data.d_int32;
  114.  
  115.   gimp_destroy_params (return_vals, nreturn_vals);
  116.  
  117.   return value;
  118. }
  119.  
  120. /**
  121.  * gimp_selection_is_empty:
  122.  * @image_ID: The image.
  123.  *
  124.  * Determine whether the selection is empty.
  125.  *
  126.  * This procedure returns non-zero if the selection for the specified
  127.  * image is not empty.
  128.  *
  129.  * Returns: Is the selection empty?
  130.  */
  131. gboolean
  132. gimp_selection_is_empty (gint32 image_ID)
  133. {
  134.   GimpParam *return_vals;
  135.   gint nreturn_vals;
  136.   gboolean is_empty = FALSE;
  137.  
  138.   return_vals = gimp_run_procedure ("gimp_selection_is_empty",
  139.                     &nreturn_vals,
  140.                     GIMP_PDB_IMAGE, image_ID,
  141.                     GIMP_PDB_END);
  142.  
  143.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  144.     is_empty = return_vals[1].data.d_int32;
  145.  
  146.   gimp_destroy_params (return_vals, nreturn_vals);
  147.  
  148.   return is_empty;
  149. }
  150.  
  151. /**
  152.  * gimp_selection_translate:
  153.  * @image_ID: The image.
  154.  * @offx: x offset for translation.
  155.  * @offy: y offset for translation.
  156.  *
  157.  * Translate the selection by the specified offsets.
  158.  *
  159.  * This procedure actually translates the selection for the specified
  160.  * image by the specified offsets. Regions that are translated from
  161.  * beyond the bounds of the image are set to empty. Valid regions of
  162.  * the selection which are translated beyond the bounds of the image
  163.  * because of this call are lost.
  164.  *
  165.  * Returns: TRUE on success.
  166.  */
  167. gboolean
  168. gimp_selection_translate (gint32 image_ID,
  169.               gint   offx,
  170.               gint   offy)
  171. {
  172.   GimpParam *return_vals;
  173.   gint nreturn_vals;
  174.   gboolean success = TRUE;
  175.  
  176.   return_vals = gimp_run_procedure ("gimp_selection_translate",
  177.                     &nreturn_vals,
  178.                     GIMP_PDB_IMAGE, image_ID,
  179.                     GIMP_PDB_INT32, offx,
  180.                     GIMP_PDB_INT32, offy,
  181.                     GIMP_PDB_END);
  182.  
  183.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  184.  
  185.   gimp_destroy_params (return_vals, nreturn_vals);
  186.  
  187.   return success;
  188. }
  189.  
  190. /**
  191.  * _gimp_selection_float:
  192.  * @drawable_ID: The drawable from which to float selection.
  193.  * @offx: x offset for translation.
  194.  * @offy: y offset for translation.
  195.  *
  196.  * Float the selection from the specified drawable with initial offsets
  197.  * as specified.
  198.  *
  199.  * This procedure determines the region of the specified drawable that
  200.  * lies beneath the current selection. The region is then cut from the
  201.  * drawable and the resulting data is made into a new layer which is
  202.  * instantiated as a floating selection. The offsets allow initial
  203.  * positioning of the new floating selection.
  204.  *
  205.  * Returns: The floated layer.
  206.  */
  207. gint32
  208. _gimp_selection_float (gint32 drawable_ID,
  209.                gint   offx,
  210.                gint   offy)
  211. {
  212.   GimpParam *return_vals;
  213.   gint nreturn_vals;
  214.   gint32 layer_ID = -1;
  215.  
  216.   return_vals = gimp_run_procedure ("gimp_selection_float",
  217.                     &nreturn_vals,
  218.                     GIMP_PDB_DRAWABLE, drawable_ID,
  219.                     GIMP_PDB_INT32, offx,
  220.                     GIMP_PDB_INT32, offy,
  221.                     GIMP_PDB_END);
  222.  
  223.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  224.     layer_ID = return_vals[1].data.d_layer;
  225.  
  226.   gimp_destroy_params (return_vals, nreturn_vals);
  227.  
  228.   return layer_ID;
  229. }
  230.  
  231. /**
  232.  * gimp_selection_clear:
  233.  * @image_ID: The image.
  234.  *
  235.  * Set the selection to none, clearing all previous content.
  236.  *
  237.  * This procedure sets the selection mask to empty, assigning the value
  238.  * 0 to every pixel in the selection channel.
  239.  *
  240.  * Returns: TRUE on success.
  241.  */
  242. gboolean
  243. gimp_selection_clear (gint32 image_ID)
  244. {
  245.   GimpParam *return_vals;
  246.   gint nreturn_vals;
  247.   gboolean success = TRUE;
  248.  
  249.   return_vals = gimp_run_procedure ("gimp_selection_clear",
  250.                     &nreturn_vals,
  251.                     GIMP_PDB_IMAGE, image_ID,
  252.                     GIMP_PDB_END);
  253.  
  254.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  255.  
  256.   gimp_destroy_params (return_vals, nreturn_vals);
  257.  
  258.   return success;
  259. }
  260.  
  261. /**
  262.  * gimp_selection_invert:
  263.  * @image_ID: The image.
  264.  *
  265.  * Invert the selection mask.
  266.  *
  267.  * This procedure inverts the selection mask. For every pixel in the
  268.  * selection channel, its new value is calculated as (255 - old_value).
  269.  *
  270.  * Returns: TRUE on success.
  271.  */
  272. gboolean
  273. gimp_selection_invert (gint32 image_ID)
  274. {
  275.   GimpParam *return_vals;
  276.   gint nreturn_vals;
  277.   gboolean success = TRUE;
  278.  
  279.   return_vals = gimp_run_procedure ("gimp_selection_invert",
  280.                     &nreturn_vals,
  281.                     GIMP_PDB_IMAGE, image_ID,
  282.                     GIMP_PDB_END);
  283.  
  284.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  285.  
  286.   gimp_destroy_params (return_vals, nreturn_vals);
  287.  
  288.   return success;
  289. }
  290.  
  291. /**
  292.  * gimp_selection_sharpen:
  293.  * @image_ID: The image.
  294.  *
  295.  * Sharpen the selection mask.
  296.  *
  297.  * This procedure sharpens the selection mask. For every pixel in the
  298.  * selection channel, if the value is > 0, the new pixel is assigned a
  299.  * value of 255. This removes any \"anti-aliasing\" that might exist in
  300.  * the selection mask's boundary.
  301.  *
  302.  * Returns: TRUE on success.
  303.  */
  304. gboolean
  305. gimp_selection_sharpen (gint32 image_ID)
  306. {
  307.   GimpParam *return_vals;
  308.   gint nreturn_vals;
  309.   gboolean success = TRUE;
  310.  
  311.   return_vals = gimp_run_procedure ("gimp_selection_sharpen",
  312.                     &nreturn_vals,
  313.                     GIMP_PDB_IMAGE, image_ID,
  314.                     GIMP_PDB_END);
  315.  
  316.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  317.  
  318.   gimp_destroy_params (return_vals, nreturn_vals);
  319.  
  320.   return success;
  321. }
  322.  
  323. /**
  324.  * gimp_selection_all:
  325.  * @image_ID: The image.
  326.  *
  327.  * Select all of the image.
  328.  *
  329.  * This procedure sets the selection mask to completely encompass the
  330.  * image. Every pixel in the selection channel is set to 255.
  331.  *
  332.  * Returns: TRUE on success.
  333.  */
  334. gboolean
  335. gimp_selection_all (gint32 image_ID)
  336. {
  337.   GimpParam *return_vals;
  338.   gint nreturn_vals;
  339.   gboolean success = TRUE;
  340.  
  341.   return_vals = gimp_run_procedure ("gimp_selection_all",
  342.                     &nreturn_vals,
  343.                     GIMP_PDB_IMAGE, image_ID,
  344.                     GIMP_PDB_END);
  345.  
  346.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  347.  
  348.   gimp_destroy_params (return_vals, nreturn_vals);
  349.  
  350.   return success;
  351. }
  352.  
  353. /**
  354.  * gimp_selection_none:
  355.  * @image_ID: The image.
  356.  *
  357.  * Deselect the entire image.
  358.  *
  359.  * This procedure deselects the entire image. Every pixel in the
  360.  * selection channel is set to 0.
  361.  *
  362.  * Returns: TRUE on success.
  363.  */
  364. gboolean
  365. gimp_selection_none (gint32 image_ID)
  366. {
  367.   GimpParam *return_vals;
  368.   gint nreturn_vals;
  369.   gboolean success = TRUE;
  370.  
  371.   return_vals = gimp_run_procedure ("gimp_selection_none",
  372.                     &nreturn_vals,
  373.                     GIMP_PDB_IMAGE, image_ID,
  374.                     GIMP_PDB_END);
  375.  
  376.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  377.  
  378.   gimp_destroy_params (return_vals, nreturn_vals);
  379.  
  380.   return success;
  381. }
  382.  
  383. /**
  384.  * gimp_selection_feather:
  385.  * @image_ID: The image.
  386.  * @radius: Radius of feather (in pixels).
  387.  *
  388.  * Feather the image's selection
  389.  *
  390.  * This procedure feathers the selection. Feathering is implemented
  391.  * using a gaussian blur.
  392.  *
  393.  * Returns: TRUE on success.
  394.  */
  395. gboolean
  396. gimp_selection_feather (gint32  image_ID,
  397.             gdouble radius)
  398. {
  399.   GimpParam *return_vals;
  400.   gint nreturn_vals;
  401.   gboolean success = TRUE;
  402.  
  403.   return_vals = gimp_run_procedure ("gimp_selection_feather",
  404.                     &nreturn_vals,
  405.                     GIMP_PDB_IMAGE, image_ID,
  406.                     GIMP_PDB_FLOAT, radius,
  407.                     GIMP_PDB_END);
  408.  
  409.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  410.  
  411.   gimp_destroy_params (return_vals, nreturn_vals);
  412.  
  413.   return success;
  414. }
  415.  
  416. /**
  417.  * gimp_selection_border:
  418.  * @image_ID: The image.
  419.  * @radius: Radius of border (in pixels).
  420.  *
  421.  * Border the image's selection
  422.  *
  423.  * This procedure borders the selection. Bordering creates a new
  424.  * selection which is defined along the boundary of the previous
  425.  * selection at every point within the specified radius.
  426.  *
  427.  * Returns: TRUE on success.
  428.  */
  429. gboolean
  430. gimp_selection_border (gint32 image_ID,
  431.                gint   radius)
  432. {
  433.   GimpParam *return_vals;
  434.   gint nreturn_vals;
  435.   gboolean success = TRUE;
  436.  
  437.   return_vals = gimp_run_procedure ("gimp_selection_border",
  438.                     &nreturn_vals,
  439.                     GIMP_PDB_IMAGE, image_ID,
  440.                     GIMP_PDB_INT32, radius,
  441.                     GIMP_PDB_END);
  442.  
  443.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  444.  
  445.   gimp_destroy_params (return_vals, nreturn_vals);
  446.  
  447.   return success;
  448. }
  449.  
  450. /**
  451.  * gimp_selection_grow:
  452.  * @image_ID: The image.
  453.  * @steps: Steps of grow (in pixels).
  454.  *
  455.  * Grow the image's selection
  456.  *
  457.  * This procedure grows the selection. Growing involves expanding the
  458.  * boundary in all directions by the specified pixel amount.
  459.  *
  460.  * Returns: TRUE on success.
  461.  */
  462. gboolean
  463. gimp_selection_grow (gint32 image_ID,
  464.              gint   steps)
  465. {
  466.   GimpParam *return_vals;
  467.   gint nreturn_vals;
  468.   gboolean success = TRUE;
  469.  
  470.   return_vals = gimp_run_procedure ("gimp_selection_grow",
  471.                     &nreturn_vals,
  472.                     GIMP_PDB_IMAGE, image_ID,
  473.                     GIMP_PDB_INT32, steps,
  474.                     GIMP_PDB_END);
  475.  
  476.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  477.  
  478.   gimp_destroy_params (return_vals, nreturn_vals);
  479.  
  480.   return success;
  481. }
  482.  
  483. /**
  484.  * gimp_selection_shrink:
  485.  * @image_ID: The image.
  486.  * @radius: Radius of shrink (in pixels).
  487.  *
  488.  * Shrink the image's selection
  489.  *
  490.  * This procedure shrinks the selection. Shrinking invovles trimming
  491.  * the existing selection boundary on all sides by the specified number
  492.  * of pixels.
  493.  *
  494.  * Returns: TRUE on success.
  495.  */
  496. gboolean
  497. gimp_selection_shrink (gint32 image_ID,
  498.                gint   radius)
  499. {
  500.   GimpParam *return_vals;
  501.   gint nreturn_vals;
  502.   gboolean success = TRUE;
  503.  
  504.   return_vals = gimp_run_procedure ("gimp_selection_shrink",
  505.                     &nreturn_vals,
  506.                     GIMP_PDB_IMAGE, image_ID,
  507.                     GIMP_PDB_INT32, radius,
  508.                     GIMP_PDB_END);
  509.  
  510.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  511.  
  512.   gimp_destroy_params (return_vals, nreturn_vals);
  513.  
  514.   return success;
  515. }
  516.  
  517. /**
  518.  * gimp_selection_layer_alpha:
  519.  * @layer_ID: Layer with alpha.
  520.  *
  521.  * Transfer the specified layer's alpha channel to the selection mask.
  522.  *
  523.  * This procedure requires a layer with an alpha channel. The alpha
  524.  * channel information is used to create a selection mask such that for
  525.  * any pixel in the image defined in the specified layer, that layer
  526.  * pixel's alpha value is transferred to the selection mask. If the
  527.  * layer is undefined at a particular image pixel, the associated
  528.  * selection mask value is set to 0.
  529.  *
  530.  * Returns: TRUE on success.
  531.  */
  532. gboolean
  533. gimp_selection_layer_alpha (gint32 layer_ID)
  534. {
  535.   GimpParam *return_vals;
  536.   gint nreturn_vals;
  537.   gboolean success = TRUE;
  538.  
  539.   return_vals = gimp_run_procedure ("gimp_selection_layer_alpha",
  540.                     &nreturn_vals,
  541.                     GIMP_PDB_LAYER, layer_ID,
  542.                     GIMP_PDB_END);
  543.  
  544.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  545.  
  546.   gimp_destroy_params (return_vals, nreturn_vals);
  547.  
  548.   return success;
  549. }
  550.  
  551. /**
  552.  * gimp_selection_load:
  553.  * @channel_ID: The channel.
  554.  *
  555.  * Transfer the specified channel to the selection mask.
  556.  *
  557.  * This procedure loads the specified channel into the selection mask.
  558.  * This essentially involves a copy of the channel's content in to the
  559.  * selection mask. Therefore, the channel must have the same width and
  560.  * height of the image, or an error is returned.
  561.  *
  562.  * Returns: TRUE on success.
  563.  */
  564. gboolean
  565. gimp_selection_load (gint32 channel_ID)
  566. {
  567.   GimpParam *return_vals;
  568.   gint nreturn_vals;
  569.   gboolean success = TRUE;
  570.  
  571.   return_vals = gimp_run_procedure ("gimp_selection_load",
  572.                     &nreturn_vals,
  573.                     GIMP_PDB_CHANNEL, channel_ID,
  574.                     GIMP_PDB_END);
  575.  
  576.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  577.  
  578.   gimp_destroy_params (return_vals, nreturn_vals);
  579.  
  580.   return success;
  581. }
  582.  
  583. /**
  584.  * gimp_selection_save:
  585.  * @image_ID: The image.
  586.  *
  587.  * Copy the selection mask to a new channel.
  588.  *
  589.  * This procedure copies the selection mask and stores the content in a
  590.  * new channel. The new channel is automatically inserted into the
  591.  * image's list of channels.
  592.  *
  593.  * Returns: The new channel.
  594.  */
  595. gint32
  596. gimp_selection_save (gint32 image_ID)
  597. {
  598.   GimpParam *return_vals;
  599.   gint nreturn_vals;
  600.   gint32 channel_ID = -1;
  601.  
  602.   return_vals = gimp_run_procedure ("gimp_selection_save",
  603.                     &nreturn_vals,
  604.                     GIMP_PDB_IMAGE, image_ID,
  605.                     GIMP_PDB_END);
  606.  
  607.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  608.     channel_ID = return_vals[1].data.d_channel;
  609.  
  610.   gimp_destroy_params (return_vals, nreturn_vals);
  611.  
  612.   return channel_ID;
  613. }
  614.