gimpdrawable3LIBGIMP LibrarygimpdrawableFunctions to manipulate drawables.Synopsis
GimpDrawable;
GimpDrawable* gimp_drawable_get (gint32 drawable_ID);
void gimp_drawable_detach (GimpDrawable *drawable);
void gimp_drawable_flush (GimpDrawable *drawable);
gboolean gimp_drawable_delete (gint32 drawable_ID);
gchar* gimp_drawable_get_name (gint32 drawable_ID);
gboolean gimp_drawable_set_name (gint32 drawable_ID,
const gchar *name);
gboolean gimp_drawable_get_visible (gint32 drawable_ID);
gboolean gimp_drawable_set_visible (gint32 drawable_ID,
gboolean visible);
gboolean gimp_drawable_get_linked (gint32 drawable_ID);
gboolean gimp_drawable_set_linked (gint32 drawable_ID,
gboolean linked);
gint gimp_drawable_get_tattoo (gint32 drawable_ID);
gboolean gimp_drawable_set_tattoo (gint32 drawable_ID,
gint tattoo);
guint8* gimp_drawable_get_pixel (gint32 drawable_ID,
gint x_coord,
gint y_coord,
gint *num_channels);
gboolean gimp_drawable_set_pixel (gint32 drawable_ID,
gint x_coord,
gint y_coord,
gint num_channels,
const guint8 *pixel);
GimpTile* gimp_drawable_get_tile (GimpDrawable *drawable,
gint shadow,
gint row,
gint col);
GimpTile* gimp_drawable_get_tile2 (GimpDrawable *drawable,
gint shadow,
gint x,
gint y);
guchar* gimp_drawable_get_thumbnail_data
(gint32 drawable_ID,
gint *width,
gint *height,
gint *bpp);
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);
void gimp_drawable_get_color_uchar (gint32 drawable_ID,
const GimpRGB *color,
guchar *color_uchar);
gboolean gimp_drawable_merge_shadow (gint32 drawable_ID,
gboolean undo);
gboolean gimp_drawable_fill (gint32 drawable_ID,
GimpFillType fill_type);
gboolean gimp_drawable_update (gint32 drawable_ID,
gint x,
gint y,
gint width,
gint height);
gboolean gimp_drawable_mask_bounds (gint32 drawable_ID,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gboolean gimp_drawable_mask_intersect (gint32 drawable_ID,
gint *x,
gint *y,
gint *width,
gint *height);
gint32 gimp_drawable_get_image (gint32 drawable_ID);
gboolean gimp_drawable_set_image (gint32 drawable_ID,
gint32 image_ID);
gboolean gimp_drawable_has_alpha (gint32 drawable_ID);
GimpImageType gimp_drawable_type_with_alpha (gint32 drawable_ID);
GimpImageType gimp_drawable_type (gint32 drawable_ID);
gboolean gimp_drawable_is_rgb (gint32 drawable_ID);
gboolean gimp_drawable_is_gray (gint32 drawable_ID);
gboolean gimp_drawable_is_indexed (gint32 drawable_ID);
gint gimp_drawable_bpp (gint32 drawable_ID);
gint gimp_drawable_width (gint32 drawable_ID);
gint gimp_drawable_height (gint32 drawable_ID);
gboolean gimp_drawable_offsets (gint32 drawable_ID,
gint *offset_x,
gint *offset_y);
gboolean gimp_drawable_is_layer (gint32 drawable_ID);
gboolean gimp_drawable_is_layer_mask (gint32 drawable_ID);
gboolean gimp_drawable_is_channel (gint32 drawable_ID);
gboolean gimp_drawable_offset (gint32 drawable_ID,
gboolean wrap_around,
GimpOffsetType fill_type,
gint offset_x,
gint offset_y);
GimpParasite* gimp_drawable_parasite_find (gint32 drawable_ID,
const gchar *name);
gboolean gimp_drawable_parasite_list (gint32 drawable_ID,
gint *num_parasites,
gchar ***parasites);
gboolean gimp_drawable_parasite_attach (gint32 drawable_ID,
GimpParasite *parasite);
gboolean gimp_drawable_parasite_detach (gint32 drawable_ID,
const gchar *name);
void gimp_drawable_attach_new_parasite
(gint32 drawable_ID,
const gchar *name,
gint flags,
gint size,
gconstpointer data);
Description
Functions to manipulate drawables.
DetailsGimpDrawableGimpDrawabletypedef struct {
gint32 drawable_id; /* drawable ID */
guint width; /* width of drawble */
guint height; /* height of drawble */
guint bpp; /* bytes per pixel of drawable */
guint ntile_rows; /* # of tile rows */
guint ntile_cols; /* # of tile columns */
GimpTile *tiles; /* the normal tiles */
GimpTile *shadow_tiles; /* the shadow tiles */
} GimpDrawable;
gimp_drawable_get ()gimp_drawable_getGimpDrawable* gimp_drawable_get (gint32 drawable_ID);
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.
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.
When a plug-in has finished working with a drawable, before exiting
it should call gimp_drawable_detach() to make sure that all tile data is
transferred back to the core.drawable_ID : the ID of the drawable
Returns : a new GimpDrawable wrapper
gimp_drawable_detach ()gimp_drawable_detachvoid gimp_drawable_detach (GimpDrawable *drawable);
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
then frees all associated memory. You must not access the
drawable after having called gimp_drawable_detach().drawable : The GimpDrawable to detach from the core
gimp_drawable_flush ()gimp_drawable_flushvoid gimp_drawable_flush (GimpDrawable *drawable);
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.drawable : The GimpDrawable whose tile data is to be transferred
to the core.
gimp_drawable_delete ()gimp_drawable_deletegboolean gimp_drawable_delete (gint32 drawable_ID);
Delete a drawable.
This procedure deletes the specified drawable. This must not be done
if the gimage containing this drawable was already deleted or if the
drawable was already removed from the image. The only case in which
this procedure is useful is if you want to get rid of a drawable
which has not yet been added to an image.drawable_ID : The drawable to delete.
Returns : TRUE on success.
gimp_drawable_get_name ()gimp_drawable_get_namegchar* gimp_drawable_get_name (gint32 drawable_ID);
Get the name of the specified drawable.
This procedure returns the specified drawable's name.drawable_ID : The drawable.
Returns : The drawable name.
gimp_drawable_set_name ()gimp_drawable_set_namegboolean gimp_drawable_set_name (gint32 drawable_ID,
const gchar *name);
Set the name of the specified drawable.
This procedure sets the specified drawable's name.drawable_ID : The drawable.
name : The new drawable name.
Returns : TRUE on success.
gimp_drawable_get_visible ()gimp_drawable_get_visiblegboolean gimp_drawable_get_visible (gint32 drawable_ID);
Get the visibility of the specified drawable.
This procedure returns the specified drawable's visibility.drawable_ID : The drawable.
Returns : The drawable visibility.
gimp_drawable_set_visible ()gimp_drawable_set_visiblegboolean gimp_drawable_set_visible (gint32 drawable_ID,
gboolean visible);
Set the visibility of the specified drawable.
This procedure sets the specified drawable's visibility.drawable_ID : The drawable.
visible : The new drawable visibility.
Returns : TRUE on success.
gimp_drawable_get_linked ()gimp_drawable_get_linkedgboolean gimp_drawable_get_linked (gint32 drawable_ID);
Get the linked state of the specified drawable.
This procedure returns the specified drawable's linked state.drawable_ID : The drawable.
Returns : The drawable linked state (for moves).
gimp_drawable_set_linked ()gimp_drawable_set_linkedgboolean gimp_drawable_set_linked (gint32 drawable_ID,
gboolean linked);
Set the linked state of the specified drawable.
This procedure sets the specified drawable's linked state.drawable_ID : The drawable.
linked : The new drawable linked state.
Returns : TRUE on success.
gimp_drawable_get_tattoo ()gimp_drawable_get_tattoogint gimp_drawable_get_tattoo (gint32 drawable_ID);
Get the tattoo of the specified drawable.
This procedure returns the specified drawable's tattoo. A tattoo is
a unique and permanent identifier attached to a drawable that can be
used to uniquely identify a drawable within an image even between
sessionsdrawable_ID : The drawable.
Returns : The drawable tattoo.
gimp_drawable_set_tattoo ()gimp_drawable_set_tattoogboolean gimp_drawable_set_tattoo (gint32 drawable_ID,
gint tattoo);
Set the tattoo of the specified drawable.
This procedure sets the specified drawable's tattoo. A tattoo is a
unique and permanent identifier attached to a drawable that can be
used to uniquely identify a drawable within an image even between
sessionsdrawable_ID : The drawable.
tattoo : The new drawable tattoo.
Returns : TRUE on success.
gimp_drawable_get_pixel ()gimp_drawable_get_pixelguint8* gimp_drawable_get_pixel (gint32 drawable_ID,
gint x_coord,
gint y_coord,
gint *num_channels);
Gets the value of the pixel at the specified coordinates.
This procedure gets the pixel value at the specified coordinates.
The 'num_channels' argument must always be equal to the
bytes-per-pixel value for the specified drawable.drawable_ID : The drawable.
x_coord : The x coordinate.
y_coord : The y coordinate.
num_channels : The number of channels for the pixel.
Returns : The pixel value.
gimp_drawable_set_pixel ()gimp_drawable_set_pixelgboolean gimp_drawable_set_pixel (gint32 drawable_ID,
gint x_coord,
gint y_coord,
gint num_channels,
const guint8 *pixel);
Sets the value of the pixel at the specified coordinates.
This procedure sets the pixel value at the specified coordinates.
The 'num_channels' argument must always be equal to the
bytes-per-pixel value for the spec ified drawable. Note that this
function is not undoable, you should use it only on drawables you
just created yourself.drawable_ID : The drawable.
x_coord : The x coordinate.
y_coord : The y coordinate.
num_channels : The number of channels for the pixel.
pixel : The pixel value.
Returns : TRUE on success.
gimp_drawable_get_tile ()gimp_drawable_get_tileGimpTile* gimp_drawable_get_tile (GimpDrawable *drawable,
gint shadow,
gint row,
gint col);drawable :shadow :row :col :Returns :gimp_drawable_get_tile2 ()gimp_drawable_get_tile2GimpTile* gimp_drawable_get_tile2 (GimpDrawable *drawable,
gint shadow,
gint x,
gint y);drawable :shadow :x :y :Returns :gimp_drawable_get_thumbnail_data ()gimp_drawable_get_thumbnail_dataguchar* gimp_drawable_get_thumbnail_data
(gint32 drawable_ID,
gint *width,
gint *height,
gint *bpp);drawable_ID :width :height :bpp :Returns :gimp_drawable_get_sub_thumbnail_data ()gimp_drawable_get_sub_thumbnail_dataguchar* 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);drawable_ID :src_x :src_y :src_width :src_height :dest_width :dest_height :bpp :Returns :gimp_drawable_get_color_uchar ()gimp_drawable_get_color_ucharvoid gimp_drawable_get_color_uchar (gint32 drawable_ID,
const GimpRGB *color,
guchar *color_uchar);drawable_ID :color :color_uchar :gimp_drawable_merge_shadow ()gimp_drawable_merge_shadowgboolean gimp_drawable_merge_shadow (gint32 drawable_ID,
gboolean undo);
Merge the shadow buffer with the specified drawable.
This procedure combines the contents of the image's shadow buffer
(for temporary processing) with the specified drawable. The \"undo\"
parameter specifies whether to add an undo step for the operation.
Requesting no undo is useful for such applications as 'auto-apply'.drawable_ID : The drawable.
undo : Push merge to undo stack?
Returns : TRUE on success.
gimp_drawable_fill ()gimp_drawable_fillgboolean gimp_drawable_fill (gint32 drawable_ID,
GimpFillType fill_type);
Fill the drawable with the specified fill mode.
This procedure fills the drawable with the fill mode. If the fill
mode is foreground the current foreground color is used. If the fill
mode is background, the current background color is used. If the
fill type is white, then white is used. Transparent fill only
affects layers with an alpha channel, in which case the alpha
channel is set to transparent. If the drawable has no alpha channel,
it is filled to white. No fill leaves the drawable's contents
undefined. This procedure is unlike the bucket fill tool because it
fills regardless of a selectiondrawable_ID : The drawable.
fill_type : The type of fill.
Returns : TRUE on success.
gimp_drawable_update ()gimp_drawable_updategboolean gimp_drawable_update (gint32 drawable_ID,
gint x,
gint y,
gint width,
gint height);
Update the specified region of the drawable.
This procedure updates the specified region of the drawable. The (x,
y) coordinate pair is relative to the drawable's origin, not to the
image origin. Therefore, the entire drawable can be updated using
(0, 0, width, height).drawable_ID : The drawable.
x : x coordinate of upper left corner of update region.
y : y coordinate of upper left corner of update region.
width : Width of update region.
height : Height of update region.
Returns : TRUE on success.
gimp_drawable_mask_bounds ()gimp_drawable_mask_boundsgboolean gimp_drawable_mask_bounds (gint32 drawable_ID,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
Find the bounding box of the current selection in relation to the
specified drawable.
This procedure returns whether there is a selection. If there is
one, the upper left and lower righthand corners of its bounding box
are returned. These coordinates are specified relative to the
drawable's origin, and bounded by the drawable's extents. Please
note that the pixel specified by the lower righthand coordinate of
the bounding box is not part of the selection. The selection ends at
the upper left corner of this pixel. This means the width of the
selection can be calculated as (x2 - x1), its height as (y2 - y1).
Note that the returned boolean does NOT correspond with the returned
region being empty or not, it always returns whether the selection
is non_empty. See gimp_drawable_mask_intersect() for a boolean
return value which is more useful in most cases.drawable_ID : The drawable.
x1 : x coordinate of the upper left corner of selection bounds.
y1 : y coordinate of the upper left corner of selection bounds.
x2 : x coordinate of the lower right corner of selection bounds.
y2 : y coordinate of the lower right corner of selection bounds.
Returns : TRUE if there is a selection.
gimp_drawable_mask_intersect ()gimp_drawable_mask_intersectgboolean gimp_drawable_mask_intersect (gint32 drawable_ID,
gint *x,
gint *y,
gint *width,
gint *height);
Find the bounding box of the current selection in relation to the
specified drawable.
This procedure returns whether there is an intersection between the
drawable and the selection. Unlike gimp_drawable_mask_bounds(), the
intersection's bounds are returned as x, y, width, height. If there
is no selection this function returns TRUE and the returned bounds
are the extents of the whole drawable.drawable_ID : The drawable.
x : x coordinate of the upper left corner of the intersection.
y : y coordinate of the upper left corner of the intersection.
width : width of the intersection.
height : height of the intersection.
Returns : TRUE if the returned area is not empty.
Since GIMP 2.2
gimp_drawable_get_image ()gimp_drawable_get_imagegint32 gimp_drawable_get_image (gint32 drawable_ID);
Returns the drawable's image.
This procedure returns the drawable's image.drawable_ID : The drawable.
Returns : The drawable's image.
gimp_drawable_set_image ()gimp_drawable_set_imagegboolean gimp_drawable_set_image (gint32 drawable_ID,
gint32 image_ID);gimp_drawable_set_image is deprecated and should not be used in newly-written code.
This procedure is deprecated!drawable_ID : The drawable.
image_ID : The image.
Returns : TRUE on success.
gimp_drawable_has_alpha ()gimp_drawable_has_alphagboolean gimp_drawable_has_alpha (gint32 drawable_ID);
Returns non-zero if the drawable has an alpha channel.
This procedure returns whether the specified drawable has an alpha
channel. This can only be true for layers, and the associated type
will be one of: { RGBA , GRAYA, INDEXEDA }.drawable_ID : The drawable.
Returns : Does the drawable have an alpha channel?
gimp_drawable_type_with_alpha ()gimp_drawable_type_with_alphaGimpImageType gimp_drawable_type_with_alpha (gint32 drawable_ID);
Returns the drawable's type with alpha.
This procedure returns the drawable's type as if had an alpha
channel. If the type is currently Gray, for instance, the returned
type would be GrayA. If the drawable already has an alpha channel,
the drawable's type is simply returned.drawable_ID : The drawable.
Returns : The drawable's type with alpha.
gimp_drawable_type ()gimp_drawable_typeGimpImageType gimp_drawable_type (gint32 drawable_ID);
Returns the drawable's type.
This procedure returns the drawable's type.drawable_ID : The drawable.
Returns : The drawable's type.
gimp_drawable_is_rgb ()gimp_drawable_is_rgbgboolean gimp_drawable_is_rgb (gint32 drawable_ID);
Returns whether the drawable is an RGB type.
This procedure returns non-zero if the specified drawable is of type
{ RGB, RGBA }.drawable_ID : The drawable.
Returns : non-zero if the drawable is an RGB type.
gimp_drawable_is_gray ()gimp_drawable_is_graygboolean gimp_drawable_is_gray (gint32 drawable_ID);
Returns whether the drawable is a grayscale type.
This procedure returns non-zero if the specified drawable is of type
{ Gray, GrayA }.drawable_ID : The drawable.
Returns : non-zero if the drawable is a grayscale type.
gimp_drawable_is_indexed ()gimp_drawable_is_indexedgboolean gimp_drawable_is_indexed (gint32 drawable_ID);
Returns whether the drawable is an indexed type.
This procedure returns non-zero if the specified drawable is of type
{ Indexed, IndexedA }.drawable_ID : The drawable.
Returns : non-zero if the drawable is an indexed type.
gimp_drawable_bpp ()gimp_drawable_bppgint gimp_drawable_bpp (gint32 drawable_ID);
Returns the bytes per pixel.
This procedure returns the number of bytes per pixel (or the number
of channels) for the specified drawable.drawable_ID : The drawable.
Returns : Bytes per pixel.
gimp_drawable_width ()gimp_drawable_widthgint gimp_drawable_width (gint32 drawable_ID);
Returns the width of the drawable.
This procedure returns the specified drawable's width in pixels.drawable_ID : The drawable.
Returns : Width of drawable.
gimp_drawable_height ()gimp_drawable_heightgint gimp_drawable_height (gint32 drawable_ID);
Returns the height of the drawable.
This procedure returns the specified drawable's height in pixels.drawable_ID : The drawable.
Returns : Height of drawable.
gimp_drawable_offsets ()gimp_drawable_offsetsgboolean gimp_drawable_offsets (gint32 drawable_ID,
gint *offset_x,
gint *offset_y);
Returns the offsets for the drawable.
This procedure returns the specified drawable's offsets. This only
makes sense if the drawable is a layer since channels are anchored.
The offsets of a channel will be returned as 0.drawable_ID : The drawable.
offset_x : x offset of drawable.
offset_y : y offset of drawable.
Returns : TRUE on success.
gimp_drawable_is_layer ()gimp_drawable_is_layergboolean gimp_drawable_is_layer (gint32 drawable_ID);
Returns whether the drawable is a layer.
This procedure returns non-zero if the specified drawable is a
layer.drawable_ID : The drawable.
Returns : Non-zero if the drawable is a layer.
gimp_drawable_is_layer_mask ()gimp_drawable_is_layer_maskgboolean gimp_drawable_is_layer_mask (gint32 drawable_ID);
Returns whether the drawable is a layer mask.
This procedure returns non-zero if the specified drawable is a layer
mask.drawable_ID : The drawable.
Returns : Non-zero if the drawable is a layer mask.
gimp_drawable_is_channel ()gimp_drawable_is_channelgboolean gimp_drawable_is_channel (gint32 drawable_ID);
Returns whether the drawable is a channel.
This procedure returns non-zero if the specified drawable is a
channel.drawable_ID : The drawable.
Returns : Non-zero if the drawable is a channel.
gimp_drawable_offset ()gimp_drawable_offsetgboolean gimp_drawable_offset (gint32 drawable_ID,
gboolean wrap_around,
GimpOffsetType fill_type,
gint offset_x,
gint offset_y);
Offset the drawable by the specified amounts in the X and Y
directions
This procedure offsets the specified drawable by the amounts
specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to
TRUE, then portions of the drawable which are offset out of bounds
are wrapped around. Alternatively, the undefined regions of the
drawable can be filled with transparency or the background color, as
specified by the 'fill_type' parameter.drawable_ID : The drawable to offset.
wrap_around : wrap image around or fill vacated regions.
fill_type : fill vacated regions of drawable with background or transparent.
offset_x : offset by this amount in X direction.
offset_y : offset by this amount in Y direction.
Returns : TRUE on success.
gimp_drawable_parasite_find ()gimp_drawable_parasite_findGimpParasite* gimp_drawable_parasite_find (gint32 drawable_ID,
const gchar *name);
Finds the named parasite in a drawable
Finds and returns the named parasite that was previously attached to
a drawable.drawable_ID : The drawable.
name : The name of the parasite to find.
Returns : The found parasite.
gimp_drawable_parasite_list ()gimp_drawable_parasite_listgboolean gimp_drawable_parasite_list (gint32 drawable_ID,
gint *num_parasites,
gchar ***parasites);
List all parasites.
Returns a list of all currently attached parasites.drawable_ID : The drawable.
num_parasites : The number of attached parasites.
parasites : The names of currently attached parasites.
Returns : TRUE on success.
gimp_drawable_parasite_attach ()gimp_drawable_parasite_attachgboolean gimp_drawable_parasite_attach (gint32 drawable_ID,
GimpParasite *parasite);
Add a parasite to a drawable.
This procedure attaches a parasite to a drawable. It has no return
values.drawable_ID : The drawable.
parasite : The parasite to attach to a drawable.
Returns : TRUE on success.
gimp_drawable_parasite_detach ()gimp_drawable_parasite_detachgboolean gimp_drawable_parasite_detach (gint32 drawable_ID,
const gchar *name);
Removes a parasite from a drawable.
This procedure detaches a parasite from a drawable. It has no return
values.drawable_ID : The drawable.
name : The name of the parasite to detach from a drawable.
Returns : TRUE on success.
gimp_drawable_attach_new_parasite ()gimp_drawable_attach_new_parasitevoid gimp_drawable_attach_new_parasite
(gint32 drawable_ID,
const gchar *name,
gint flags,
gint size,
gconstpointer data);
Convenience function that creates a parasite and attaches it
to the GIMP.
See Also: gimp_drawable_parasite_attach()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.