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

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpdrawable_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_drawable_merge_shadow:
  28.  * @drawable_ID: The drawable.
  29.  * @undo: Push merge to undo stack?
  30.  *
  31.  * Merge the shadow buffer with the specified drawable.
  32.  *
  33.  * This procedure combines the contents of the image's shadow buffer
  34.  * (for temporary processing) with the specified drawable. The \"undo\"
  35.  * parameter specifies whether to add an undo step for the operation.
  36.  * Requesting no undo is useful for such applications as 'auto-apply'.
  37.  *
  38.  * Returns: TRUE on success.
  39.  */
  40. gboolean
  41. gimp_drawable_merge_shadow (gint32   drawable_ID,
  42.                 gboolean undo)
  43. {
  44.   GimpParam *return_vals;
  45.   gint nreturn_vals;
  46.   gboolean success = TRUE;
  47.  
  48.   return_vals = gimp_run_procedure ("gimp_drawable_merge_shadow",
  49.                     &nreturn_vals,
  50.                     GIMP_PDB_DRAWABLE, drawable_ID,
  51.                     GIMP_PDB_INT32, undo,
  52.                     GIMP_PDB_END);
  53.  
  54.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  55.  
  56.   gimp_destroy_params (return_vals, nreturn_vals);
  57.  
  58.   return success;
  59. }
  60.  
  61. /**
  62.  * gimp_drawable_fill:
  63.  * @drawable_ID: The drawable.
  64.  * @fill_type: The type of fill.
  65.  *
  66.  * Fill the drawable with the specified fill mode.
  67.  *
  68.  * This procedure fills the drawable with the fill mode. If the fill
  69.  * mode is foreground the current foreground color is used. If the fill
  70.  * mode is background, the current background color is used. If the
  71.  * fill type is white, then white is used. Transparent fill only
  72.  * affects layers with an alpha channel, in which case the alpha
  73.  * channel is set to transparent. If the drawable has no alpha channel,
  74.  * it is filled to white. No fill leaves the drawable's contents
  75.  * undefined. This procedure is unlike the bucket fill tool because it
  76.  * fills regardless of a selection
  77.  *
  78.  * Returns: TRUE on success.
  79.  */
  80. gboolean
  81. gimp_drawable_fill (gint32       drawable_ID,
  82.             GimpFillType fill_type)
  83. {
  84.   GimpParam *return_vals;
  85.   gint nreturn_vals;
  86.   gboolean success = TRUE;
  87.  
  88.   return_vals = gimp_run_procedure ("gimp_drawable_fill",
  89.                     &nreturn_vals,
  90.                     GIMP_PDB_DRAWABLE, drawable_ID,
  91.                     GIMP_PDB_INT32, fill_type,
  92.                     GIMP_PDB_END);
  93.  
  94.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  95.  
  96.   gimp_destroy_params (return_vals, nreturn_vals);
  97.  
  98.   return success;
  99. }
  100.  
  101. /**
  102.  * gimp_drawable_update:
  103.  * @drawable_ID: The drawable.
  104.  * @x: x coordinate of upper left corner of update region.
  105.  * @y: y coordinate of upper left corner of update region.
  106.  * @width: Width of update region.
  107.  * @height: Height of update region.
  108.  *
  109.  * Update the specified region of the drawable.
  110.  *
  111.  * This procedure updates the specified region of the drawable. The (x,
  112.  * y) coordinate pair is relative to the drawable's origin, not to the
  113.  * image origin. Therefore, the entire drawable can be updated with:
  114.  * {x->0, y->0, w->width, h->height }.
  115.  *
  116.  * Returns: TRUE on success.
  117.  */
  118. gboolean
  119. gimp_drawable_update (gint32 drawable_ID,
  120.               gint   x,
  121.               gint   y,
  122.               gint   width,
  123.               gint   height)
  124. {
  125.   GimpParam *return_vals;
  126.   gint nreturn_vals;
  127.   gboolean success = TRUE;
  128.  
  129.   return_vals = gimp_run_procedure ("gimp_drawable_update",
  130.                     &nreturn_vals,
  131.                     GIMP_PDB_DRAWABLE, drawable_ID,
  132.                     GIMP_PDB_INT32, x,
  133.                     GIMP_PDB_INT32, y,
  134.                     GIMP_PDB_INT32, width,
  135.                     GIMP_PDB_INT32, height,
  136.                     GIMP_PDB_END);
  137.  
  138.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  139.  
  140.   gimp_destroy_params (return_vals, nreturn_vals);
  141.  
  142.   return success;
  143. }
  144.  
  145. /**
  146.  * gimp_drawable_mask_bounds:
  147.  * @drawable_ID: The drawable.
  148.  * @x1: x coordinate of the upper left corner of selection bounds.
  149.  * @y1: y coordinate of the upper left corner of selection bounds.
  150.  * @x2: x coordinate of the lower right corner of selection bounds.
  151.  * @y2: y coordinate of the lower right corner of selection bounds.
  152.  *
  153.  * Find the bounding box of the current selection in relation to the
  154.  * specified drawable.
  155.  *
  156.  * This procedure returns the whether there is a selection. If there is
  157.  * one, the upper left and lower righthand corners of its bounding box
  158.  * are returned. These coordinates are specified relative to the
  159.  * drawable's origin, and bounded by the drawable's extents.
  160.  *
  161.  * Returns: TRUE if there is a selection.
  162.  */
  163. gboolean
  164. gimp_drawable_mask_bounds (gint32  drawable_ID,
  165.                gint   *x1,
  166.                gint   *y1,
  167.                gint   *x2,
  168.                gint   *y2)
  169. {
  170.   GimpParam *return_vals;
  171.   gint nreturn_vals;
  172.   gboolean non_empty = FALSE;
  173.  
  174.   return_vals = gimp_run_procedure ("gimp_drawable_mask_bounds",
  175.                     &nreturn_vals,
  176.                     GIMP_PDB_DRAWABLE, drawable_ID,
  177.                     GIMP_PDB_END);
  178.  
  179.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  180.     {
  181.       non_empty = return_vals[1].data.d_int32;
  182.       *x1 = return_vals[2].data.d_int32;
  183.       *y1 = return_vals[3].data.d_int32;
  184.       *x2 = return_vals[4].data.d_int32;
  185.       *y2 = return_vals[5].data.d_int32;
  186.     }
  187.  
  188.   gimp_destroy_params (return_vals, nreturn_vals);
  189.  
  190.   return non_empty;
  191. }
  192.  
  193. /**
  194.  * gimp_drawable_image:
  195.  * @drawable_ID: The drawable.
  196.  *
  197.  * Returns the drawable's image.
  198.  *
  199.  * This procedure returns the drawable's image.
  200.  *
  201.  * Returns: The drawable's image.
  202.  */
  203. gint32
  204. gimp_drawable_image (gint32 drawable_ID)
  205. {
  206.   GimpParam *return_vals;
  207.   gint nreturn_vals;
  208.   gint32 image_ID = -1;
  209.  
  210.   return_vals = gimp_run_procedure ("gimp_drawable_image",
  211.                     &nreturn_vals,
  212.                     GIMP_PDB_DRAWABLE, drawable_ID,
  213.                     GIMP_PDB_END);
  214.  
  215.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  216.     image_ID = return_vals[1].data.d_image;
  217.  
  218.   gimp_destroy_params (return_vals, nreturn_vals);
  219.  
  220.   return image_ID;
  221. }
  222.  
  223. /**
  224.  * gimp_drawable_type:
  225.  * @drawable_ID: The drawable.
  226.  *
  227.  * Returns the drawable's type.
  228.  *
  229.  * This procedure returns the drawable's type.
  230.  *
  231.  * Returns: The drawable's type.
  232.  */
  233. GimpImageType
  234. gimp_drawable_type (gint32 drawable_ID)
  235. {
  236.   GimpParam *return_vals;
  237.   gint nreturn_vals;
  238.   GimpImageType type = 0;
  239.  
  240.   return_vals = gimp_run_procedure ("gimp_drawable_type",
  241.                     &nreturn_vals,
  242.                     GIMP_PDB_DRAWABLE, drawable_ID,
  243.                     GIMP_PDB_END);
  244.  
  245.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  246.     type = return_vals[1].data.d_int32;
  247.  
  248.   gimp_destroy_params (return_vals, nreturn_vals);
  249.  
  250.   return type;
  251. }
  252.  
  253. /**
  254.  * gimp_drawable_has_alpha:
  255.  * @drawable_ID: The drawable.
  256.  *
  257.  * Returns non-zero if the drawable has an alpha channel.
  258.  *
  259.  * This procedure returns whether the specified drawable has an alpha
  260.  * channel. This can only be true for layers, and the associated type
  261.  * will be one of: { RGBA , GRAYA, INDEXEDA }.
  262.  *
  263.  * Returns: Does the drawable have an alpha channel?
  264.  */
  265. gboolean
  266. gimp_drawable_has_alpha (gint32 drawable_ID)
  267. {
  268.   GimpParam *return_vals;
  269.   gint nreturn_vals;
  270.   gboolean has_alpha = FALSE;
  271.  
  272.   return_vals = gimp_run_procedure ("gimp_drawable_has_alpha",
  273.                     &nreturn_vals,
  274.                     GIMP_PDB_DRAWABLE, drawable_ID,
  275.                     GIMP_PDB_END);
  276.  
  277.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  278.     has_alpha = return_vals[1].data.d_int32;
  279.  
  280.   gimp_destroy_params (return_vals, nreturn_vals);
  281.  
  282.   return has_alpha;
  283. }
  284.  
  285. /**
  286.  * gimp_drawable_type_with_alpha:
  287.  * @drawable_ID: The drawable.
  288.  *
  289.  * Returns the drawable's type with alpha.
  290.  *
  291.  * This procedure returns the drawable's type if an alpha channel were
  292.  * added. If the type is currently Gray, for instance, the returned
  293.  * type would be GrayA. If the drawable already has an alpha channel,
  294.  * the drawable's type is simply returned.
  295.  *
  296.  * Returns: The drawable's type with alpha.
  297.  */
  298. GimpImageType
  299. gimp_drawable_type_with_alpha (gint32 drawable_ID)
  300. {
  301.   GimpParam *return_vals;
  302.   gint nreturn_vals;
  303.   GimpImageType type_with_alpha = 0;
  304.  
  305.   return_vals = gimp_run_procedure ("gimp_drawable_type_with_alpha",
  306.                     &nreturn_vals,
  307.                     GIMP_PDB_DRAWABLE, drawable_ID,
  308.                     GIMP_PDB_END);
  309.  
  310.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  311.     type_with_alpha = return_vals[1].data.d_int32;
  312.  
  313.   gimp_destroy_params (return_vals, nreturn_vals);
  314.  
  315.   return type_with_alpha;
  316. }
  317.  
  318. /**
  319.  * gimp_drawable_is_rgb:
  320.  * @drawable_ID: The drawable.
  321.  *
  322.  * Returns whether the drawable is an RGB type.
  323.  *
  324.  * This procedure returns non-zero if the specified drawable is of type
  325.  * { RGB, RGBA }.
  326.  *
  327.  * Returns: non-zero if the drawable is an RGB type.
  328.  */
  329. gboolean
  330. gimp_drawable_is_rgb (gint32 drawable_ID)
  331. {
  332.   GimpParam *return_vals;
  333.   gint nreturn_vals;
  334.   gboolean color = FALSE;
  335.  
  336.   return_vals = gimp_run_procedure ("gimp_drawable_is_rgb",
  337.                     &nreturn_vals,
  338.                     GIMP_PDB_DRAWABLE, drawable_ID,
  339.                     GIMP_PDB_END);
  340.  
  341.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  342.     color = return_vals[1].data.d_int32;
  343.  
  344.   gimp_destroy_params (return_vals, nreturn_vals);
  345.  
  346.   return color;
  347. }
  348.  
  349. /**
  350.  * gimp_drawable_is_gray:
  351.  * @drawable_ID: The drawable.
  352.  *
  353.  * Returns whether the drawable is a grayscale type.
  354.  *
  355.  * This procedure returns non-zero if the specified drawable is of type
  356.  * { Gray, GrayA }.
  357.  *
  358.  * Returns: non-zero if the drawable is a grayscale type.
  359.  */
  360. gboolean
  361. gimp_drawable_is_gray (gint32 drawable_ID)
  362. {
  363.   GimpParam *return_vals;
  364.   gint nreturn_vals;
  365.   gboolean gray = FALSE;
  366.  
  367.   return_vals = gimp_run_procedure ("gimp_drawable_is_gray",
  368.                     &nreturn_vals,
  369.                     GIMP_PDB_DRAWABLE, drawable_ID,
  370.                     GIMP_PDB_END);
  371.  
  372.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  373.     gray = return_vals[1].data.d_int32;
  374.  
  375.   gimp_destroy_params (return_vals, nreturn_vals);
  376.  
  377.   return gray;
  378. }
  379.  
  380. /**
  381.  * gimp_drawable_is_indexed:
  382.  * @drawable_ID: The drawable.
  383.  *
  384.  * Returns whether the drawable is an indexed type.
  385.  *
  386.  * This procedure returns non-zero if the specified drawable is of type
  387.  * { Indexed, IndexedA }.
  388.  *
  389.  * Returns: non-zero if the drawable is an indexed type.
  390.  */
  391. gboolean
  392. gimp_drawable_is_indexed (gint32 drawable_ID)
  393. {
  394.   GimpParam *return_vals;
  395.   gint nreturn_vals;
  396.   gboolean indexed = FALSE;
  397.  
  398.   return_vals = gimp_run_procedure ("gimp_drawable_is_indexed",
  399.                     &nreturn_vals,
  400.                     GIMP_PDB_DRAWABLE, drawable_ID,
  401.                     GIMP_PDB_END);
  402.  
  403.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  404.     indexed = return_vals[1].data.d_int32;
  405.  
  406.   gimp_destroy_params (return_vals, nreturn_vals);
  407.  
  408.   return indexed;
  409. }
  410.  
  411. /**
  412.  * gimp_drawable_bytes:
  413.  * @drawable_ID: The drawable.
  414.  *
  415.  * Returns the bytes per pixel.
  416.  *
  417.  * This procedure returns the number of bytes per pixel (or the number
  418.  * of channels) for the specified drawable.
  419.  *
  420.  * Returns: Bytes per pixel.
  421.  */
  422. gint
  423. gimp_drawable_bytes (gint32 drawable_ID)
  424. {
  425.   GimpParam *return_vals;
  426.   gint nreturn_vals;
  427.   gint bytes = 0;
  428.  
  429.   return_vals = gimp_run_procedure ("gimp_drawable_bytes",
  430.                     &nreturn_vals,
  431.                     GIMP_PDB_DRAWABLE, drawable_ID,
  432.                     GIMP_PDB_END);
  433.  
  434.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  435.     bytes = return_vals[1].data.d_int32;
  436.  
  437.   gimp_destroy_params (return_vals, nreturn_vals);
  438.  
  439.   return bytes;
  440. }
  441.  
  442. /**
  443.  * gimp_drawable_width:
  444.  * @drawable_ID: The drawable.
  445.  *
  446.  * Returns the width of the drawable.
  447.  *
  448.  * This procedure returns the specified drawable's width in pixels.
  449.  *
  450.  * Returns: Width of drawable.
  451.  */
  452. gint
  453. gimp_drawable_width (gint32 drawable_ID)
  454. {
  455.   GimpParam *return_vals;
  456.   gint nreturn_vals;
  457.   gint width = 0;
  458.  
  459.   return_vals = gimp_run_procedure ("gimp_drawable_width",
  460.                     &nreturn_vals,
  461.                     GIMP_PDB_DRAWABLE, drawable_ID,
  462.                     GIMP_PDB_END);
  463.  
  464.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  465.     width = return_vals[1].data.d_int32;
  466.  
  467.   gimp_destroy_params (return_vals, nreturn_vals);
  468.  
  469.   return width;
  470. }
  471.  
  472. /**
  473.  * gimp_drawable_height:
  474.  * @drawable_ID: The drawable.
  475.  *
  476.  * Returns the height of the drawable.
  477.  *
  478.  * This procedure returns the specified drawable's height in pixels.
  479.  *
  480.  * Returns: Height of drawable.
  481.  */
  482. gint
  483. gimp_drawable_height (gint32 drawable_ID)
  484. {
  485.   GimpParam *return_vals;
  486.   gint nreturn_vals;
  487.   gint height = 0;
  488.  
  489.   return_vals = gimp_run_procedure ("gimp_drawable_height",
  490.                     &nreturn_vals,
  491.                     GIMP_PDB_DRAWABLE, drawable_ID,
  492.                     GIMP_PDB_END);
  493.  
  494.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  495.     height = return_vals[1].data.d_int32;
  496.  
  497.   gimp_destroy_params (return_vals, nreturn_vals);
  498.  
  499.   return height;
  500. }
  501.  
  502. /**
  503.  * gimp_drawable_offsets:
  504.  * @drawable_ID: The drawable.
  505.  * @offset_x: x offset of drawable.
  506.  * @offset_y: y offset of drawable.
  507.  *
  508.  * Returns the offsets for the drawable.
  509.  *
  510.  * This procedure returns the specified drawable's offsets. This only
  511.  * makes sense if the drawable is a layer since channels are anchored.
  512.  * The offsets of a channel will be returned as 0.
  513.  *
  514.  * Returns: TRUE on success.
  515.  */
  516. gboolean
  517. gimp_drawable_offsets (gint32  drawable_ID,
  518.                gint   *offset_x,
  519.                gint   *offset_y)
  520. {
  521.   GimpParam *return_vals;
  522.   gint nreturn_vals;
  523.   gboolean success = TRUE;
  524.  
  525.   return_vals = gimp_run_procedure ("gimp_drawable_offsets",
  526.                     &nreturn_vals,
  527.                     GIMP_PDB_DRAWABLE, drawable_ID,
  528.                     GIMP_PDB_END);
  529.  
  530.   *offset_x = 0;
  531.   *offset_y = 0;
  532.  
  533.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  534.  
  535.   if (success)
  536.     {
  537.       *offset_x = return_vals[1].data.d_int32;
  538.       *offset_y = return_vals[2].data.d_int32;
  539.     }
  540.  
  541.   gimp_destroy_params (return_vals, nreturn_vals);
  542.  
  543.   return success;
  544. }
  545.  
  546. /**
  547.  * gimp_drawable_is_layer:
  548.  * @drawable_ID: The drawable.
  549.  *
  550.  * Returns whether the drawable is a layer.
  551.  *
  552.  * This procedure returns non-zero if the specified drawable is a
  553.  * layer.
  554.  *
  555.  * Returns: Non-zero if the drawable is a layer.
  556.  */
  557. gboolean
  558. gimp_drawable_is_layer (gint32 drawable_ID)
  559. {
  560.   GimpParam *return_vals;
  561.   gint nreturn_vals;
  562.   gboolean layer = FALSE;
  563.  
  564.   return_vals = gimp_run_procedure ("gimp_drawable_is_layer",
  565.                     &nreturn_vals,
  566.                     GIMP_PDB_DRAWABLE, drawable_ID,
  567.                     GIMP_PDB_END);
  568.  
  569.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  570.     layer = return_vals[1].data.d_int32;
  571.  
  572.   gimp_destroy_params (return_vals, nreturn_vals);
  573.  
  574.   return layer;
  575. }
  576.  
  577. /**
  578.  * gimp_drawable_is_layer_mask:
  579.  * @drawable_ID: The drawable.
  580.  *
  581.  * Returns whether the drawable is a layer mask.
  582.  *
  583.  * This procedure returns non-zero if the specified drawable is a layer
  584.  * mask.
  585.  *
  586.  * Returns: Non-zero if the drawable is a layer mask.
  587.  */
  588. gboolean
  589. gimp_drawable_is_layer_mask (gint32 drawable_ID)
  590. {
  591.   GimpParam *return_vals;
  592.   gint nreturn_vals;
  593.   gboolean layer_mask = FALSE;
  594.  
  595.   return_vals = gimp_run_procedure ("gimp_drawable_is_layer_mask",
  596.                     &nreturn_vals,
  597.                     GIMP_PDB_DRAWABLE, drawable_ID,
  598.                     GIMP_PDB_END);
  599.  
  600.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  601.     layer_mask = return_vals[1].data.d_int32;
  602.  
  603.   gimp_destroy_params (return_vals, nreturn_vals);
  604.  
  605.   return layer_mask;
  606. }
  607.  
  608. /**
  609.  * gimp_drawable_is_channel:
  610.  * @drawable_ID: The drawable.
  611.  *
  612.  * Returns whether the drawable is a channel.
  613.  *
  614.  * This procedure returns non-zero if the specified drawable is a
  615.  * channel.
  616.  *
  617.  * Returns: Non-zero if the drawable is a channel.
  618.  */
  619. gboolean
  620. gimp_drawable_is_channel (gint32 drawable_ID)
  621. {
  622.   GimpParam *return_vals;
  623.   gint nreturn_vals;
  624.   gboolean channel = FALSE;
  625.  
  626.   return_vals = gimp_run_procedure ("gimp_drawable_is_channel",
  627.                     &nreturn_vals,
  628.                     GIMP_PDB_DRAWABLE, drawable_ID,
  629.                     GIMP_PDB_END);
  630.  
  631.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  632.     channel = return_vals[1].data.d_int32;
  633.  
  634.   gimp_destroy_params (return_vals, nreturn_vals);
  635.  
  636.   return channel;
  637. }
  638.  
  639. /**
  640.  * _gimp_drawable_thumbnail:
  641.  * @drawable_ID: The drawable.
  642.  * @width: The thumbnail width.
  643.  * @height: The thumbnail height.
  644.  * @ret_width: The previews width.
  645.  * @ret_height: The previews height.
  646.  * @bpp: The previews bpp.
  647.  * @thumbnail_data_count: The number of pixels in thumbnail data.
  648.  * @thumbnail_data: The thumbnail data.
  649.  *
  650.  * Get a thumbnail of a drawable.
  651.  *
  652.  * This function gets data from which a thumbnail of a drawable preview
  653.  * can be created. Maximum x or y dimension is 128 pixels. The pixels
  654.  * are returned in the RGB[A] format. The bpp return value gives the
  655.  * number of bytes in the image. The alpha channel also returned if the
  656.  * drawable has one.
  657.  *
  658.  * Returns: TRUE on success.
  659.  */
  660. gboolean
  661. _gimp_drawable_thumbnail (gint32   drawable_ID,
  662.               gint     width,
  663.               gint     height,
  664.               gint    *ret_width,
  665.               gint    *ret_height,
  666.               gint    *bpp,
  667.               gint    *thumbnail_data_count,
  668.               guint8 **thumbnail_data)
  669. {
  670.   GimpParam *return_vals;
  671.   gint nreturn_vals;
  672.   gboolean success = TRUE;
  673.  
  674.   return_vals = gimp_run_procedure ("gimp_drawable_thumbnail",
  675.                     &nreturn_vals,
  676.                     GIMP_PDB_DRAWABLE, drawable_ID,
  677.                     GIMP_PDB_INT32, width,
  678.                     GIMP_PDB_INT32, height,
  679.                     GIMP_PDB_END);
  680.  
  681.   *ret_width = 0;
  682.   *ret_height = 0;
  683.   *bpp = 0;
  684.   *thumbnail_data_count = 0;
  685.   *thumbnail_data = NULL;
  686.  
  687.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  688.  
  689.   if (success)
  690.     {
  691.       *ret_width = return_vals[1].data.d_int32;
  692.       *ret_height = return_vals[2].data.d_int32;
  693.       *bpp = return_vals[3].data.d_int32;
  694.       *thumbnail_data_count = return_vals[4].data.d_int32;
  695.       *thumbnail_data = g_new (guint8, *thumbnail_data_count);
  696.       memcpy (*thumbnail_data, return_vals[5].data.d_int8array,
  697.           *thumbnail_data_count * sizeof (guint8));
  698.     }
  699.  
  700.   gimp_destroy_params (return_vals, nreturn_vals);
  701.  
  702.   return success;
  703. }
  704.