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

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpimage.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. #include "gimp.h"
  23.  
  24.  
  25. /**
  26.  * gimp_image_get_cmap:
  27.  * @image_ID: The image.
  28.  * @num_colors: Number of colors in the colormap array.
  29.  *
  30.  * Returns the image's colormap
  31.  *
  32.  * This procedure returns an actual pointer to the image's colormap, as
  33.  * well as the number of colors contained in the colormap. If the image 
  34.  * is not of base type INDEXED, this pointer will be NULL.
  35.  *
  36.  * Returns: The image's colormap.
  37.  */
  38. guchar *
  39. gimp_image_get_cmap (gint32  image_ID,
  40.              gint   *num_colors)
  41. {
  42.   gint    num_bytes;
  43.   guchar *cmap;
  44.  
  45.   cmap = _gimp_image_get_cmap (image_ID,
  46.                    &num_bytes);
  47.  
  48.   *num_colors = num_bytes / 3;
  49.  
  50.   return cmap;
  51. }
  52.  
  53. /**
  54.  * gimp_image_set_cmap:
  55.  * @image_ID: The image.
  56.  * @cmap: The new colormap values.
  57.  * @num_colors: Number of colors in the colormap array.
  58.  *
  59.  * Sets the entries in the image's colormap.
  60.  *
  61.  * This procedure sets the entries in the specified image's colormap.
  62.  * The number of colors is specified by the \"num_colors\" parameter
  63.  * and corresponds to the number of INT8 triples that must be contained
  64.  * in the \"cmap\" array.
  65.  *
  66.  * Returns: TRUE on success.
  67.  */
  68. gboolean
  69. gimp_image_set_cmap (gint32  image_ID,
  70.              guchar *cmap,
  71.              gint    num_colors)
  72. {
  73.   return _gimp_image_set_cmap (image_ID,
  74.                    num_colors * 3,
  75.                    cmap);
  76. }
  77.  
  78. guchar *
  79. gimp_image_get_thumbnail_data (gint32  image_ID,
  80.                    gint   *width,
  81.                    gint   *height,
  82.                    gint   *bpp)
  83. {
  84.   gint    ret_width;
  85.   gint    ret_height;
  86.   guchar *image_data;
  87.   gint    data_size;
  88.  
  89.   _gimp_image_thumbnail (image_ID,
  90.              *width,
  91.              *height,
  92.              &ret_width,
  93.              &ret_height,
  94.              bpp,
  95.              &data_size,
  96.              &image_data);
  97.  
  98.   *width  = ret_width;
  99.   *height = ret_height;
  100.  
  101.   return image_data;
  102. }
  103.