2000-05-31 14:15:06 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpdrawable.c
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2000-05-31 14:15:06 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2000-05-31 14:15:06 +08:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2000-05-31 14:15:06 +08:00
|
|
|
*/
|
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
2000-05-31 14:15:06 +08:00
|
|
|
|
2012-05-03 07:50:14 +08:00
|
|
|
#define GIMP_DISABLE_DEPRECATION_WARNINGS
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
#include "gimp.h"
|
|
|
|
|
2012-03-22 08:10:43 +08:00
|
|
|
#include "gimptilebackendplugin.h"
|
2000-05-31 21:24:14 +08:00
|
|
|
|
2012-03-22 18:24:03 +08:00
|
|
|
|
Changed the semantics of GIMP_EXTENSION and (to some extent) of
2003-06-19 Michael Natterer <mitch@gimp.org>
Changed the semantics of GIMP_EXTENSION and (to some extent)
of GIMP_PLUGIN:
The old meaning of EXTENSION was "I live in the toolbox" and
PLUGIN meant "I take RUN-MODE,IMAGE,DRAWABLE args (but only if I
am invoked interactively)". This is completely useless, since
living in the toolbox means having "<Toolbox>" in the menu_path
and taking RUN-MODE,IMAGE,DRAWABLE means just that, regardless of
what type of procedure we are.
The new meaning of GIMP_PLUGIN is just "I am an ordinary procedure,
I am invoked, do my job and finish", while GIMP_EXTENSION means
"I will install temporary procedures and I will keep running to
keep them available".
(A GIMP_EXTENSION *must* call gimp_extension_ack() now to tell the
core that it's ready to run, or the core will block waiting for
the message !!!).
* configure.in: bumped version number to 1.3.16.
* libgimpbase/gimpprotocol.h: increased protocol version number so
old extensions will refuse to load.
* app/gui/plug-in-commands.c (plug_in_run_cmd_callback): don't
blindly pass RUN-MODE,IMAGE,DRAWABLE to GIMP_PLUGIN procedures but
look at their parameters and pass them either RUN-MODE, or
RUN-MODE,IMAGE, or RUN-MODE,IMAGE,DRAWABLE.
* app/pdb/procedural_db.c: cleaned up, better error reporting,
replaced an impossible error message by g_return_if_fail()
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install):
better error messages.
* app/plug-in/plug-in-params.c: allocate parameter arrays using
g_new0() so we don't have to worry about uninitialized stuff
later.
* app/plug-in/plug-in-run.c (plug_in_run): wait for
gimp_extension_ack() installation confirmation for ALL extensions,
not just for automatically started ones.
* app/plug-in/plug-ins.c: cleanup.
* libgimp/gimp.[ch]: cleaned up and API-documented massively. Made
all magic values given in the GPConfig message static and added
accessor functions for them. Added gimp_tile_width()/height().
Added new function gimp_extension_enable() which turns on
asynchronous processing of temp_proc run requests without having
to enter an endless gimp_extension_process() loop. Moved all
private functions to the end of the file. Added tons of
g_return_if_fail() all over the place. Call gimp_run_procedure2()
from gimp_run_procedure() instead of duplicating the
code. Indentation, spacing, stuff...
* libgimp/gimptile.[ch]: removed gimp_tile_width()/height().
* libgimp/gimpdrawable.c
* libgimp/gimppixelrgn.c
* libgimp/gimptile.c: use the gimp_tile_width()/height() accessor
functions.
* libgimp/gimp.def: added gimp_extension_enable.
* libgimp/gimpmenu.c: removed evil code which connected to
_readchannel manually and use gimp_extension_enable() for watching
temp_procs.
* plug-ins/helpbrowser/helpbrowser.c: removed the same evil code
here and call gimp_extension_enable(). Call gimp_extension_ack()
to let the core know that the temp_proc is installed.
* plug-ins/script-fu/script-fu.c: made all procedures except the
permanently running "extension_script_fu" ordinary GIMP_PLUGIN
procedures.
* plug-ins/common/curve_bend.c
* plug-ins/common/plugindetails.c
* plug-ins/common/screenshot.c
* plug-ins/common/uniteditor.c
* plug-ins/common/winclipboard.c
* plug-ins/dbbrowser/dbbrowser.c
* plug-ins/gfli/gfli.c
* plug-ins/twain/twain.c
* plug-ins/webbrowser/webbrowser.c
* plug-ins/winsnap/winsnap.c: made them all ordinary GIMP_PLUGIN
procedures and renamed them from "extension_*" to "plug_in_*".
Random cleanups.
* app/widgets/gimphelp.c
* plug-ins/maze/maze_face.c: call "plug_in_web_browser" now.
2003-06-20 01:12:00 +08:00
|
|
|
#define TILE_WIDTH gimp_tile_width()
|
|
|
|
#define TILE_HEIGHT gimp_tile_height()
|
2000-05-31 14:15:06 +08:00
|
|
|
|
|
|
|
|
2004-06-24 10:00:32 +08:00
|
|
|
/**
|
|
|
|
* gimp_drawable_get:
|
2004-07-29 20:05:45 +08:00
|
|
|
* @drawable_ID: the ID of the drawable
|
2004-06-24 10:00:32 +08:00
|
|
|
*
|
2004-07-29 20:05:45 +08:00
|
|
|
* This function creates a #GimpDrawable structure for the core
|
|
|
|
* drawable identified by @drawable_ID. The returned structure
|
|
|
|
* contains some basic information about the drawable and can also
|
|
|
|
* hold tile data for transfer to and from the core.
|
2004-06-24 10:00:32 +08:00
|
|
|
*
|
2004-07-29 20:05:45 +08:00
|
|
|
* Note that the name of this function is somewhat misleading, because
|
|
|
|
* it suggests that it simply returns a handle. This is not the case:
|
|
|
|
* if the function is called multiple times, it creates separate tile
|
|
|
|
* lists each time, which will usually produce undesired results.
|
2004-06-24 10:00:32 +08:00
|
|
|
*
|
|
|
|
* When a plug-in has finished working with a drawable, before exiting
|
2004-06-28 16:58:56 +08:00
|
|
|
* it should call gimp_drawable_detach() to make sure that all tile data is
|
2004-06-24 10:00:32 +08:00
|
|
|
* transferred back to the core.
|
2004-07-29 20:05:45 +08:00
|
|
|
*
|
|
|
|
* Return value: a new #GimpDrawable wrapper
|
|
|
|
**/
|
2000-05-31 14:15:06 +08:00
|
|
|
GimpDrawable *
|
|
|
|
gimp_drawable_get (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable;
|
2004-02-16 06:18:17 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint bpp;
|
|
|
|
|
|
|
|
width = gimp_drawable_width (drawable_ID);
|
|
|
|
height = gimp_drawable_height (drawable_ID);
|
|
|
|
bpp = gimp_drawable_bpp (drawable_ID);
|
|
|
|
|
|
|
|
g_return_val_if_fail (width > 0 && height > 0 && bpp > 0, NULL);
|
|
|
|
|
2007-05-22 22:04:35 +08:00
|
|
|
drawable = g_slice_new0 (GimpDrawable);
|
2000-05-31 14:15:06 +08:00
|
|
|
|
2001-06-15 04:07:38 +08:00
|
|
|
drawable->drawable_id = drawable_ID;
|
2004-02-16 06:18:17 +08:00
|
|
|
drawable->width = width;
|
|
|
|
drawable->height = height;
|
|
|
|
drawable->bpp = bpp;
|
|
|
|
drawable->ntile_rows = (height + TILE_HEIGHT - 1) / TILE_HEIGHT;
|
|
|
|
drawable->ntile_cols = (width + TILE_WIDTH - 1) / TILE_WIDTH;
|
2000-05-31 14:15:06 +08:00
|
|
|
|
|
|
|
return drawable;
|
|
|
|
}
|
|
|
|
|
2004-07-29 20:05:45 +08:00
|
|
|
/**
|
2004-06-24 10:00:32 +08:00
|
|
|
* gimp_drawable_detach:
|
|
|
|
* @drawable: The #GimpDrawable to detach from the core
|
|
|
|
*
|
|
|
|
* This function is called when a plug-in is finished working
|
|
|
|
* with a drawable. It forces all tile data held in the tile
|
|
|
|
* list of the #GimpDrawable to be transferred to the core, and
|
2004-06-28 16:58:56 +08:00
|
|
|
* then frees all associated memory. You must not access the
|
|
|
|
* @drawable after having called gimp_drawable_detach().
|
2004-07-29 20:05:45 +08:00
|
|
|
**/
|
2000-05-31 14:15:06 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_detach (GimpDrawable *drawable)
|
|
|
|
{
|
2004-02-16 06:18:17 +08:00
|
|
|
g_return_if_fail (drawable != NULL);
|
2003-12-04 01:47:15 +08:00
|
|
|
|
2004-02-16 06:18:17 +08:00
|
|
|
gimp_drawable_flush (drawable);
|
2003-12-04 01:47:15 +08:00
|
|
|
|
2004-02-16 06:18:17 +08:00
|
|
|
if (drawable->tiles)
|
|
|
|
g_free (drawable->tiles);
|
2007-05-22 22:04:35 +08:00
|
|
|
|
2004-02-16 06:18:17 +08:00
|
|
|
if (drawable->shadow_tiles)
|
|
|
|
g_free (drawable->shadow_tiles);
|
|
|
|
|
2007-05-22 22:04:35 +08:00
|
|
|
g_slice_free (GimpDrawable, drawable);
|
2000-05-31 14:15:06 +08:00
|
|
|
}
|
|
|
|
|
2004-07-29 20:05:45 +08:00
|
|
|
/**
|
2004-06-24 10:00:32 +08:00
|
|
|
* gimp_drawable_flush:
|
2004-06-28 16:58:56 +08:00
|
|
|
* @drawable: The #GimpDrawable whose tile data is to be transferred
|
|
|
|
* to the core.
|
2004-06-24 10:00:32 +08:00
|
|
|
*
|
|
|
|
* This function causes all tile data in the tile list of @drawable to be
|
|
|
|
* transferred to the core. It is usually called in situations where a
|
|
|
|
* plug-in acts on a drawable, and then needs to read the results of its
|
|
|
|
* actions. Data transferred back from the core will not generally be valid
|
|
|
|
* unless gimp_drawable_flush() has been called beforehand.
|
2004-07-29 20:05:45 +08:00
|
|
|
**/
|
2000-05-31 14:15:06 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_flush (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GimpTile *tiles;
|
2003-12-04 01:47:15 +08:00
|
|
|
gint n_tiles;
|
|
|
|
gint i;
|
2000-05-31 14:15:06 +08:00
|
|
|
|
2004-02-16 06:18:17 +08:00
|
|
|
g_return_if_fail (drawable != NULL);
|
|
|
|
|
|
|
|
if (drawable->tiles)
|
2000-05-31 14:15:06 +08:00
|
|
|
{
|
2004-02-16 06:18:17 +08:00
|
|
|
tiles = drawable->tiles;
|
|
|
|
n_tiles = drawable->ntile_rows * drawable->ntile_cols;
|
|
|
|
|
|
|
|
for (i = 0; i < n_tiles; i++)
|
|
|
|
if ((tiles[i].ref_count > 0) && tiles[i].dirty)
|
|
|
|
gimp_tile_flush (&tiles[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drawable->shadow_tiles)
|
|
|
|
{
|
|
|
|
tiles = drawable->shadow_tiles;
|
|
|
|
n_tiles = drawable->ntile_rows * drawable->ntile_cols;
|
|
|
|
|
|
|
|
for (i = 0; i < n_tiles; i++)
|
|
|
|
if ((tiles[i].ref_count > 0) && tiles[i].dirty)
|
|
|
|
gimp_tile_flush (&tiles[i]);
|
2000-05-31 14:15:06 +08:00
|
|
|
}
|
2004-07-01 04:28:30 +08:00
|
|
|
|
|
|
|
/* nuke all references to this drawable from the cache */
|
|
|
|
_gimp_tile_cache_flush_drawable (drawable);
|
2000-05-31 14:15:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GimpTile *
|
|
|
|
gimp_drawable_get_tile (GimpDrawable *drawable,
|
2006-04-12 18:53:28 +08:00
|
|
|
gboolean shadow,
|
|
|
|
gint row,
|
|
|
|
gint col)
|
2000-05-31 14:15:06 +08:00
|
|
|
{
|
|
|
|
GimpTile *tiles;
|
2003-12-04 01:47:15 +08:00
|
|
|
guint right_tile;
|
|
|
|
guint bottom_tile;
|
|
|
|
gint n_tiles;
|
|
|
|
gint tile_num;
|
|
|
|
gint i, j, k;
|
2000-05-31 14:15:06 +08:00
|
|
|
|
2004-02-16 06:18:17 +08:00
|
|
|
g_return_val_if_fail (drawable != NULL, NULL);
|
|
|
|
|
|
|
|
if (shadow)
|
|
|
|
tiles = drawable->shadow_tiles;
|
|
|
|
else
|
|
|
|
tiles = drawable->tiles;
|
|
|
|
|
|
|
|
if (! tiles)
|
2000-05-31 14:15:06 +08:00
|
|
|
{
|
2004-02-16 06:18:17 +08:00
|
|
|
n_tiles = drawable->ntile_rows * drawable->ntile_cols;
|
|
|
|
tiles = g_new (GimpTile, n_tiles);
|
|
|
|
|
2004-08-31 06:49:06 +08:00
|
|
|
right_tile = (drawable->width -
|
|
|
|
((drawable->ntile_cols - 1) * TILE_WIDTH));
|
|
|
|
bottom_tile = (drawable->height -
|
|
|
|
((drawable->ntile_rows - 1) * TILE_HEIGHT));
|
2004-02-16 06:18:17 +08:00
|
|
|
|
|
|
|
for (i = 0, k = 0; i < drawable->ntile_rows; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < drawable->ntile_cols; j++, k++)
|
|
|
|
{
|
|
|
|
tiles[k].bpp = drawable->bpp;
|
|
|
|
tiles[k].tile_num = k;
|
|
|
|
tiles[k].ref_count = 0;
|
|
|
|
tiles[k].dirty = FALSE;
|
|
|
|
tiles[k].shadow = shadow;
|
|
|
|
tiles[k].data = NULL;
|
|
|
|
tiles[k].drawable = drawable;
|
|
|
|
|
|
|
|
if (j == (drawable->ntile_cols - 1))
|
|
|
|
tiles[k].ewidth = right_tile;
|
|
|
|
else
|
|
|
|
tiles[k].ewidth = TILE_WIDTH;
|
|
|
|
|
|
|
|
if (i == (drawable->ntile_rows - 1))
|
|
|
|
tiles[k].eheight = bottom_tile;
|
|
|
|
else
|
|
|
|
tiles[k].eheight = TILE_HEIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
if (shadow)
|
2004-02-16 06:18:17 +08:00
|
|
|
drawable->shadow_tiles = tiles;
|
2000-05-31 14:15:06 +08:00
|
|
|
else
|
2004-02-16 06:18:17 +08:00
|
|
|
drawable->tiles = tiles;
|
2000-05-31 14:15:06 +08:00
|
|
|
}
|
|
|
|
|
2004-02-16 06:18:17 +08:00
|
|
|
tile_num = row * drawable->ntile_cols + col;
|
|
|
|
|
|
|
|
return &tiles[tile_num];
|
2000-05-31 14:15:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GimpTile *
|
|
|
|
gimp_drawable_get_tile2 (GimpDrawable *drawable,
|
2006-04-12 18:53:28 +08:00
|
|
|
gboolean shadow,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
2000-05-31 14:15:06 +08:00
|
|
|
{
|
|
|
|
gint row;
|
|
|
|
gint col;
|
|
|
|
|
2004-02-16 06:18:17 +08:00
|
|
|
g_return_val_if_fail (drawable != NULL, NULL);
|
|
|
|
|
2000-05-31 14:15:06 +08:00
|
|
|
col = x / TILE_WIDTH;
|
|
|
|
row = y / TILE_HEIGHT;
|
|
|
|
|
|
|
|
return gimp_drawable_get_tile (drawable, shadow, row, col);
|
|
|
|
}
|
2000-06-01 22:59:22 +08:00
|
|
|
|
2004-03-13 06:46:25 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_get_color_uchar (gint32 drawable_ID,
|
|
|
|
const GimpRGB *color,
|
|
|
|
guchar *color_uchar)
|
|
|
|
{
|
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
g_return_if_fail (color_uchar != NULL);
|
|
|
|
|
|
|
|
switch (gimp_drawable_type (drawable_ID))
|
|
|
|
{
|
|
|
|
case GIMP_RGB_IMAGE:
|
|
|
|
gimp_rgb_get_uchar (color,
|
|
|
|
&color_uchar[0], &color_uchar[1], &color_uchar[2]);
|
|
|
|
color_uchar[3] = 255;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_RGBA_IMAGE:
|
|
|
|
gimp_rgba_get_uchar (color,
|
|
|
|
&color_uchar[0], &color_uchar[1], &color_uchar[2],
|
|
|
|
&color_uchar[3]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_GRAY_IMAGE:
|
2005-08-03 08:36:41 +08:00
|
|
|
color_uchar[0] = gimp_rgb_luminance_uchar (color);
|
2004-03-13 06:46:25 +08:00
|
|
|
color_uchar[1] = 255;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_GRAYA_IMAGE:
|
2005-08-03 08:36:41 +08:00
|
|
|
color_uchar[0] = gimp_rgb_luminance_uchar (color);
|
2004-03-13 06:46:25 +08:00
|
|
|
gimp_rgba_get_uchar (color, NULL, NULL, NULL, &color_uchar[1]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-01 22:59:22 +08:00
|
|
|
guchar *
|
|
|
|
gimp_drawable_get_thumbnail_data (gint32 drawable_ID,
|
2006-04-12 18:53:28 +08:00
|
|
|
gint *width,
|
|
|
|
gint *height,
|
|
|
|
gint *bpp)
|
2000-06-01 22:59:22 +08:00
|
|
|
{
|
|
|
|
gint ret_width;
|
|
|
|
gint ret_height;
|
|
|
|
guchar *image_data;
|
|
|
|
gint data_size;
|
|
|
|
|
|
|
|
_gimp_drawable_thumbnail (drawable_ID,
|
2006-04-12 18:53:28 +08:00
|
|
|
*width,
|
|
|
|
*height,
|
|
|
|
&ret_width,
|
|
|
|
&ret_height,
|
|
|
|
bpp,
|
|
|
|
&data_size,
|
|
|
|
&image_data);
|
2000-06-01 22:59:22 +08:00
|
|
|
|
|
|
|
*width = ret_width;
|
|
|
|
*height = ret_height;
|
|
|
|
|
|
|
|
return image_data;
|
|
|
|
}
|
2001-05-21 21:58:46 +08:00
|
|
|
|
2004-12-14 07:36:17 +08:00
|
|
|
guchar *
|
|
|
|
gimp_drawable_get_sub_thumbnail_data (gint32 drawable_ID,
|
|
|
|
gint src_x,
|
|
|
|
gint src_y,
|
|
|
|
gint src_width,
|
|
|
|
gint src_height,
|
|
|
|
gint *dest_width,
|
|
|
|
gint *dest_height,
|
|
|
|
gint *bpp)
|
|
|
|
{
|
|
|
|
gint ret_width;
|
|
|
|
gint ret_height;
|
|
|
|
guchar *image_data;
|
|
|
|
gint data_size;
|
|
|
|
|
|
|
|
_gimp_drawable_sub_thumbnail (drawable_ID,
|
|
|
|
src_x, src_y,
|
|
|
|
src_width, src_height,
|
|
|
|
*dest_width,
|
|
|
|
*dest_height,
|
|
|
|
&ret_width,
|
|
|
|
&ret_height,
|
|
|
|
bpp,
|
|
|
|
&data_size,
|
|
|
|
&image_data);
|
|
|
|
|
|
|
|
*dest_width = ret_width;
|
|
|
|
*dest_height = ret_height;
|
|
|
|
|
|
|
|
return image_data;
|
|
|
|
}
|
|
|
|
|
2010-09-16 03:43:03 +08:00
|
|
|
/**
|
|
|
|
* gimp_drawable_is_valid:
|
|
|
|
* @drawable_ID: The drawable to check.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_is_valid() instead.
|
|
|
|
*
|
|
|
|
* Returns: Whether the drawable ID is valid.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.4
|
2010-09-16 03:43:03 +08:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_valid (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_is_valid (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_is_layer:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_is_layer() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the drawable is a layer, FALSE otherwise.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_layer (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_is_layer (drawable_ID);
|
|
|
|
}
|
|
|
|
|
2010-09-16 03:51:53 +08:00
|
|
|
/**
|
|
|
|
* gimp_drawable_is_text_layer:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_is_text_layer() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the drawable is a text layer, FALSE otherwise.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.6
|
2010-09-16 03:51:53 +08:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_text_layer (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_is_text_layer (drawable_ID);
|
|
|
|
}
|
|
|
|
|
2010-09-16 03:43:03 +08:00
|
|
|
/**
|
|
|
|
* gimp_drawable_is_layer_mask:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_is_layer_mask() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the drawable is a layer mask, FALSE otherwise.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_layer_mask (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_is_layer_mask (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_is_channel:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_is_channel() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the drawable is a channel, FALSE otherwise.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_channel (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_is_channel (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_delete:
|
|
|
|
* @drawable_ID: The drawable to delete.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_delete() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_delete (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_delete (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_get_image:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_get_image() instead.
|
|
|
|
*
|
|
|
|
* Returns: The drawable's image.
|
|
|
|
*/
|
|
|
|
gint32
|
|
|
|
gimp_drawable_get_image (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_get_image (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_get_name:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_get_name() instead.
|
|
|
|
*
|
|
|
|
* Returns: The drawable name.
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
gimp_drawable_get_name (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_get_name (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_set_name:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
* @name: The new drawable name.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_set_name() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_set_name (gint32 drawable_ID,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
return gimp_item_set_name (drawable_ID, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_get_visible:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_get_visible() instead.
|
|
|
|
*
|
|
|
|
* Returns: The drawable visibility.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_get_visible (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_get_visible (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_set_visible:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
* @visible: The new drawable visibility.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_set_visible() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_set_visible (gint32 drawable_ID,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
return gimp_item_set_visible (drawable_ID, visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_get_linked:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_get_linked() instead.
|
|
|
|
*
|
|
|
|
* Returns: The drawable linked state (for moves).
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_get_linked (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_get_linked (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_set_linked:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
* @linked: The new drawable linked state.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_set_linked() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_set_linked (gint32 drawable_ID,
|
|
|
|
gboolean linked)
|
|
|
|
{
|
|
|
|
return gimp_item_set_linked (drawable_ID, linked);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_get_tattoo:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_get_tattoo() instead.
|
|
|
|
*
|
|
|
|
* Returns: The drawable tattoo.
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gimp_drawable_get_tattoo (gint32 drawable_ID)
|
|
|
|
{
|
|
|
|
return gimp_item_get_tattoo (drawable_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_set_tattoo:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
* @tattoo: The new drawable tattoo.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_set_tattoo() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_set_tattoo (gint32 drawable_ID,
|
|
|
|
gint tattoo)
|
|
|
|
{
|
|
|
|
return gimp_item_set_tattoo (drawable_ID, tattoo);
|
|
|
|
}
|
|
|
|
|
2011-02-14 00:39:44 +08:00
|
|
|
/**
|
|
|
|
* gimp_drawable_parasite_find:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
* @name: The name of the parasite to find.
|
|
|
|
*
|
2011-03-02 05:19:48 +08:00
|
|
|
* Deprecated: Use gimp_item_get_parasite() instead.
|
2011-02-14 00:39:44 +08:00
|
|
|
*
|
|
|
|
* Returns: The found parasite.
|
|
|
|
**/
|
|
|
|
GimpParasite *
|
|
|
|
gimp_drawable_parasite_find (gint32 drawable_ID,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
2011-03-02 05:19:48 +08:00
|
|
|
return gimp_item_get_parasite (drawable_ID, name);
|
2011-02-14 00:39:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_parasite_attach:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
* @parasite: The parasite to attach to a drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_attach_parasite() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_parasite_attach (gint32 drawable_ID,
|
|
|
|
const GimpParasite *parasite)
|
|
|
|
{
|
|
|
|
return gimp_item_attach_parasite (drawable_ID, parasite);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_parasite_detach:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
* @name: The name of the parasite to detach from a drawable.
|
|
|
|
*
|
|
|
|
* Deprecated: Use gimp_item_detach_parasite() instead.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_parasite_detach (gint32 drawable_ID,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
return gimp_item_detach_parasite (drawable_ID, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_parasite_list:
|
|
|
|
* @drawable_ID: The drawable.
|
|
|
|
* @num_parasites: The number of attached parasites.
|
|
|
|
* @parasites: The names of currently attached parasites.
|
|
|
|
*
|
2011-11-26 04:39:55 +08:00
|
|
|
* Deprecated: Use gimp_item_get_parasite_list() instead.
|
2011-02-14 00:39:44 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_parasite_list (gint32 drawable_ID,
|
|
|
|
gint *num_parasites,
|
|
|
|
gchar ***parasites)
|
|
|
|
{
|
2011-03-02 05:19:48 +08:00
|
|
|
*parasites = gimp_item_get_parasite_list (drawable_ID, num_parasites);
|
|
|
|
|
|
|
|
return *parasites != NULL;
|
2011-02-14 00:39:44 +08:00
|
|
|
}
|
|
|
|
|
2002-12-18 01:30:34 +08:00
|
|
|
/**
|
|
|
|
* gimp_drawable_attach_new_parasite:
|
|
|
|
* @drawable_ID: the ID of the #GimpDrawable to attach the #GimpParasite to.
|
|
|
|
* @name: the name of the #GimpParasite to create and attach.
|
|
|
|
* @flags: the flags set on the #GimpParasite.
|
|
|
|
* @size: the size of the parasite data in bytes.
|
|
|
|
* @data: a pointer to the data attached with the #GimpParasite.
|
|
|
|
*
|
|
|
|
* Convenience function that creates a parasite and attaches it
|
2007-06-06 16:44:52 +08:00
|
|
|
* to GIMP.
|
2002-12-18 01:30:34 +08:00
|
|
|
*
|
2012-05-03 06:25:08 +08:00
|
|
|
* Deprecated: use gimp_item_attach_parasite() instead.
|
2010-07-09 19:30:31 +08:00
|
|
|
*
|
2005-03-03 07:26:16 +08:00
|
|
|
* Return value: TRUE on successful creation and attachment of
|
|
|
|
* the new parasite.
|
|
|
|
*
|
2002-12-18 01:30:34 +08:00
|
|
|
* See Also: gimp_drawable_parasite_attach()
|
|
|
|
*/
|
2005-03-03 07:26:16 +08:00
|
|
|
gboolean
|
2002-12-19 20:01:52 +08:00
|
|
|
gimp_drawable_attach_new_parasite (gint32 drawable_ID,
|
2006-04-12 18:53:28 +08:00
|
|
|
const gchar *name,
|
|
|
|
gint flags,
|
|
|
|
gint size,
|
|
|
|
gconstpointer data)
|
2001-05-21 21:58:46 +08:00
|
|
|
{
|
|
|
|
GimpParasite *parasite = gimp_parasite_new (name, flags, size, data);
|
2005-03-03 07:26:16 +08:00
|
|
|
gboolean success;
|
2001-05-21 21:58:46 +08:00
|
|
|
|
2011-02-14 00:28:30 +08:00
|
|
|
success = gimp_item_attach_parasite (drawable_ID, parasite);
|
2001-05-21 21:58:46 +08:00
|
|
|
|
|
|
|
gimp_parasite_free (parasite);
|
2005-03-03 07:26:16 +08:00
|
|
|
|
|
|
|
return success;
|
2001-05-21 21:58:46 +08:00
|
|
|
}
|
2012-03-22 08:10:43 +08:00
|
|
|
|
2012-03-22 18:24:03 +08:00
|
|
|
/**
|
|
|
|
* gimp_drawable_get_buffer:
|
2012-04-03 02:43:38 +08:00
|
|
|
* @drawable_ID: the ID of the #GimpDrawable to get the buffer for.
|
2012-03-22 18:24:03 +08:00
|
|
|
*
|
|
|
|
* Returns a #GeglBuffer of a specified drawable. The buffer can be used
|
|
|
|
* like any other GEGL buffer. Its data will we synced back with the core
|
|
|
|
* drawable when the buffer gets destroyed, or when gegl_buffer_flush()
|
|
|
|
* is called.
|
|
|
|
*
|
|
|
|
* Return value: The #GeglBuffer.
|
|
|
|
*
|
|
|
|
* See Also: gimp_drawable_get_shadow_buffer()
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.10
|
2012-03-22 18:24:03 +08:00
|
|
|
*/
|
2012-03-22 08:10:43 +08:00
|
|
|
GeglBuffer *
|
|
|
|
gimp_drawable_get_buffer (gint32 drawable_ID)
|
|
|
|
{
|
2012-04-25 03:45:35 +08:00
|
|
|
gimp_plugin_enable_precision ();
|
|
|
|
|
2012-09-23 02:33:03 +08:00
|
|
|
if (gimp_item_is_valid (drawable_ID))
|
2012-03-22 18:24:03 +08:00
|
|
|
{
|
2012-09-23 02:33:03 +08:00
|
|
|
GimpDrawable *drawable;
|
2012-03-22 18:24:03 +08:00
|
|
|
|
2012-09-23 02:33:03 +08:00
|
|
|
drawable = gimp_drawable_get (drawable_ID);
|
2012-03-22 18:24:03 +08:00
|
|
|
|
2012-09-23 02:33:03 +08:00
|
|
|
if (drawable)
|
|
|
|
{
|
|
|
|
GeglTileBackend *backend;
|
|
|
|
GeglBuffer *buffer;
|
|
|
|
|
|
|
|
backend = _gimp_tile_backend_plugin_new (drawable, FALSE);
|
|
|
|
buffer = gegl_buffer_new_for_backend (NULL, backend);
|
|
|
|
g_object_unref (backend);
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
2012-03-22 18:24:03 +08:00
|
|
|
}
|
2012-03-22 08:10:43 +08:00
|
|
|
|
2012-03-22 18:24:03 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_get_shadow_buffer:
|
2012-04-03 02:43:38 +08:00
|
|
|
* @drawable_ID: the ID of the #GimpDrawable to get the buffer for.
|
2012-03-22 18:24:03 +08:00
|
|
|
*
|
|
|
|
* Returns a #GeglBuffer of a specified drawable's shadow tiles. The
|
|
|
|
* buffer can be used like any other GEGL buffer. Its data will we
|
|
|
|
* synced back with the core drawable's shadow tiles when the buffer
|
|
|
|
* gets destroyed, or when gegl_buffer_flush() is called.
|
|
|
|
*
|
|
|
|
* Return value: The #GeglBuffer.
|
|
|
|
*
|
|
|
|
* See Also: gimp_drawable_get_shadow_buffer()
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.10
|
2012-03-22 18:24:03 +08:00
|
|
|
*/
|
2012-03-22 08:10:43 +08:00
|
|
|
GeglBuffer *
|
|
|
|
gimp_drawable_get_shadow_buffer (gint32 drawable_ID)
|
|
|
|
{
|
2012-03-22 18:24:03 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
2012-04-25 03:45:35 +08:00
|
|
|
gimp_plugin_enable_precision ();
|
|
|
|
|
2012-03-22 08:10:43 +08:00
|
|
|
drawable = gimp_drawable_get (drawable_ID);
|
2012-03-22 18:24:03 +08:00
|
|
|
|
|
|
|
if (drawable)
|
|
|
|
{
|
|
|
|
GeglTileBackend *backend;
|
|
|
|
GeglBuffer *buffer;
|
|
|
|
|
|
|
|
backend = _gimp_tile_backend_plugin_new (drawable, TRUE);
|
|
|
|
buffer = gegl_buffer_new_for_backend (NULL, backend);
|
|
|
|
g_object_unref (backend);
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2012-03-22 08:10:43 +08:00
|
|
|
}
|
2012-04-03 02:43:38 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_drawable_get_format:
|
|
|
|
* @drawable_ID: the ID of the #GimpDrawable to get the format for.
|
|
|
|
*
|
|
|
|
* Returns the #Babl format of the drawable.
|
|
|
|
*
|
|
|
|
* Return value: The #Babl format.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.10
|
2012-04-03 02:43:38 +08:00
|
|
|
*/
|
|
|
|
const Babl *
|
|
|
|
gimp_drawable_get_format (gint32 drawable_ID)
|
|
|
|
{
|
2012-04-29 07:22:20 +08:00
|
|
|
static GHashTable *palette_formats = NULL;
|
2012-04-25 03:45:35 +08:00
|
|
|
const Babl *format = NULL;
|
|
|
|
gchar *format_str = _gimp_drawable_get_format (drawable_ID);
|
|
|
|
|
|
|
|
if (format_str)
|
2012-04-03 02:43:38 +08:00
|
|
|
{
|
2012-04-25 03:45:35 +08:00
|
|
|
if (gimp_drawable_is_indexed (drawable_ID))
|
|
|
|
{
|
|
|
|
gint32 image_ID = gimp_item_get_image (drawable_ID);
|
|
|
|
guchar *colormap;
|
|
|
|
gint n_colors;
|
2012-04-03 02:43:38 +08:00
|
|
|
|
2012-04-25 03:45:35 +08:00
|
|
|
colormap = gimp_image_get_colormap (image_ID, &n_colors);
|
2012-04-03 02:43:38 +08:00
|
|
|
|
2012-04-29 07:22:20 +08:00
|
|
|
if (!palette_formats)
|
|
|
|
palette_formats = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
|
|
|
format = g_hash_table_lookup (palette_formats, format_str);
|
|
|
|
|
|
|
|
if (!format)
|
|
|
|
{
|
|
|
|
const Babl *palette;
|
|
|
|
const Babl *palette_alpha;
|
|
|
|
|
|
|
|
babl_new_palette (format_str, &palette, &palette_alpha);
|
|
|
|
g_hash_table_insert (palette_formats,
|
|
|
|
(gpointer) babl_get_name (palette),
|
|
|
|
(gpointer) palette);
|
|
|
|
g_hash_table_insert (palette_formats,
|
|
|
|
(gpointer) babl_get_name (palette_alpha),
|
|
|
|
(gpointer) palette_alpha);
|
|
|
|
|
|
|
|
if (gimp_drawable_has_alpha (drawable_ID))
|
|
|
|
format = palette_alpha;
|
|
|
|
else
|
|
|
|
format = palette;
|
|
|
|
}
|
|
|
|
|
2012-04-30 08:24:14 +08:00
|
|
|
if (colormap)
|
|
|
|
{
|
|
|
|
babl_palette_set_palette (format,
|
|
|
|
babl_format ("R'G'B' u8"),
|
|
|
|
colormap, n_colors);
|
|
|
|
g_free (colormap);
|
|
|
|
}
|
2012-04-25 03:45:35 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
format = babl_format (format_str);
|
|
|
|
}
|
2012-04-03 02:43:38 +08:00
|
|
|
|
2012-04-25 03:45:35 +08:00
|
|
|
g_free (format_str);
|
2012-04-03 02:43:38 +08:00
|
|
|
}
|
|
|
|
|
2012-04-25 03:45:35 +08:00
|
|
|
return format;
|
2012-04-03 02:43:38 +08:00
|
|
|
}
|