gimpdrawable

gimpdrawable — Functions to manipulate drawables.

Functions

Object Hierarchy

    GObject
    ╰── GimpItem
        ╰── GimpDrawable
            ├── GimpChannel
            ╰── GimpLayer

Description

Functions to manipulate drawables.

Functions

gimp_drawable_get_by_id ()

GimpDrawable *
gimp_drawable_get_by_id (gint32 drawable_id);

Returns a GimpDrawable representing drawable_id . This function calls gimp_item_get_by_id() and returns the item if it is drawable or NULL otherwise.

Parameters

drawable_id

The drawable id.

 

Returns

a GimpDrawable for drawable_id or NULL if drawable_id does not represent a valid drawable. The object belongs to libgimp and you must not modify or unref it.

[nullable][transfer none]

Since: 3.0


gimp_drawable_get_buffer ()

GeglBuffer *
gimp_drawable_get_buffer (GimpDrawable *drawable);

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.

Parameters

drawable

the ID of the GimpDrawable to get the buffer for.

 

Returns

The GeglBuffer.

See Also: gimp_drawable_get_shadow_buffer().

[transfer full]

Since: 2.10


gimp_drawable_get_shadow_buffer ()

GeglBuffer *
gimp_drawable_get_shadow_buffer (GimpDrawable *drawable);

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.

Parameters

drawable

the ID of the GimpDrawable to get the buffer for.

 

Returns

The GeglBuffer.

[transfer full]

Since: 2.10


gimp_drawable_get_format ()

const Babl *
gimp_drawable_get_format (GimpDrawable *drawable);

Returns the Babl format of the drawable.

Parameters

drawable

the ID of the GimpDrawable to get the format for.

 

Returns

The Babl format.

Since: 2.10


gimp_drawable_get_thumbnail_format ()

const Babl *
gimp_drawable_get_thumbnail_format (GimpDrawable *drawable);

Returns the Babl thumbnail format of the drawable.

Parameters

drawable

the ID of the GimpDrawable to get the thumbnail format for.

 

Returns

The Babl thumbnail format.

Since: 2.10.14


gimp_drawable_get_thumbnail_data ()

guchar *
gimp_drawable_get_thumbnail_data (GimpDrawable *drawable,
                                  gint *width,
                                  gint *height,
                                  gint *bpp);

Retrieves thumbnail data for the drawable identified by drawable . The thumbnail will be not larger than the requested size.

Parameters

drawable

the drawable

 

width

the requested thumbnail width (<= 1024 pixels).

[inout]

height

the requested thumbnail height (<= 1024 pixels).

[inout]

bpp

the bytes per pixel of the returned thubmnail data.

[out]

Returns

thumbnail data or NULL if drawable is invalid.

[transfer full][array][nullable]


gimp_drawable_get_thumbnail ()

GdkPixbuf *
gimp_drawable_get_thumbnail (GimpDrawable *drawable,
                             gint width,
                             gint height,
                             GimpPixbufTransparency alpha);

Retrieves a thumbnail pixbuf for the drawable identified by drawable . The thumbnail will be not larger than the requested size.

Parameters

drawable

the drawable

 

width

the requested thumbnail width (<= 1024 pixels)

 

height

the requested thumbnail height (<= 1024 pixels)

 

alpha

how to handle an alpha channel

 

Returns

a new GdkPixbuf.

[transfer full]

Since: 2.2


gimp_drawable_get_pixel ()

guint8 *
gimp_drawable_get_pixel (GimpDrawable *drawable,
                         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.

Parameters

drawable

The drawable.

 

x_coord

The x coordinate.

 

y_coord

The y coordinate.

 

num_channels

The number of channels for the pixel.

[out]

Returns

The pixel value. The returned value must be freed with g_free().

[array length=num_channels][element-type guint8][transfer full]


gimp_drawable_set_pixel ()

gboolean
gimp_drawable_set_pixel (GimpDrawable *drawable,
                         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 specified drawable. Note that this function is not undoable, you should use it only on drawables you just created yourself.

Parameters

drawable

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.

[array length=num_channels][element-type guint8]

Returns

TRUE on success.


gimp_drawable_get_sub_thumbnail_data ()

guchar *
gimp_drawable_get_sub_thumbnail_data (GimpDrawable *drawable,
                                      gint src_x,
                                      gint src_y,
                                      gint src_width,
                                      gint src_height,
                                      gint *dest_width,
                                      gint *dest_height,
                                      gint *bpp);

Retrieves thumbnail data for the drawable identified by drawable . The thumbnail will be not larger than the requested size.

Parameters

drawable

the drawable ID

 

src_x

the x coordinate of the area

 

src_y

the y coordinate of the area

 

src_width

the width of the area

 

src_height

the height of the area

 

dest_width

the requested thumbnail width (<= 1024 pixels).

[inout]

dest_height

the requested thumbnail height (<= 1024 pixels).

[inout]

bpp

the bytes per pixel of the returned thumbnail data.

[out]

Returns

thumbnail data or NULL if drawable is invalid.

[transfer full][array][nullable]


gimp_drawable_get_sub_thumbnail ()

GdkPixbuf *
gimp_drawable_get_sub_thumbnail (GimpDrawable *drawable,
                                 gint src_x,
                                 gint src_y,
                                 gint src_width,
                                 gint src_height,
                                 gint dest_width,
                                 gint dest_height,
                                 GimpPixbufTransparency alpha);

Retrieves a thumbnail pixbuf for the drawable identified by drawable . The thumbnail will be not larger than the requested size.

Parameters

drawable

the drawable ID

 

src_x

the x coordinate of the area

 

src_y

the y coordinate of the area

 

src_width

the width of the area

 

src_height

the height of the area

 

dest_width

the requested thumbnail width (<= 1024 pixels)

 

dest_height

the requested thumbnail height (<= 1024 pixels)

 

alpha

how to handle an alpha channel

 

Returns

a new GdkPixbuf.

[transfer full]

Since: 2.2


gimp_drawable_merge_shadow ()

gboolean
gimp_drawable_merge_shadow (GimpDrawable *drawable,
                            gboolean undo);

Merge the shadow buffer with the specified drawable.

This procedure combines the contents of the drawable'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'.

Parameters

drawable

The drawable.

 

undo

Push merge to undo stack?

 

Returns

TRUE on success.


gimp_drawable_free_shadow ()

gboolean
gimp_drawable_free_shadow (GimpDrawable *drawable);

Free the specified drawable's shadow data (if it exists).

This procedure is intended as a memory saving device. If any shadow memory has been allocated, it will be freed automatically when the drawable is removed from the image, or when the plug-in procedure which allocated it returns.

Parameters

drawable

The drawable.

 

Returns

TRUE on success.

Since: 2.6


gimp_drawable_fill ()

gboolean
gimp_drawable_fill (GimpDrawable *drawable,
                    GimpFillType fill_type);

Fill the drawable with the specified fill mode.

This procedure fills the drawable. 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 gimp_edit_fill() or the bucket fill tool because it fills regardless of a selection. Its main purpose is to fill a newly created drawable before adding it to the image. This operation cannot be undone.

Parameters

drawable

The drawable.

 

fill_type

The type of fill.

 

Returns

TRUE on success.


gimp_drawable_update ()

gboolean
gimp_drawable_update (GimpDrawable *drawable,
                      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).

Parameters

drawable

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 ()

gboolean
gimp_drawable_mask_bounds (GimpDrawable *drawable,
                           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 right-hand 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 right-hand 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.

Parameters

drawable

The drawable.

 

x1

x coordinate of the upper left corner of selection bounds.

[out]

y1

y coordinate of the upper left corner of selection bounds.

[out]

x2

x coordinate of the lower right corner of selection bounds.

[out]

y2

y coordinate of the lower right corner of selection bounds.

[out]

Returns

TRUE if there is a selection.


gimp_drawable_mask_intersect ()

gboolean
gimp_drawable_mask_intersect (GimpDrawable *drawable,
                              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.

Parameters

drawable

The drawable.

 

x

x coordinate of the upper left corner of the intersection.

[out]

y

y coordinate of the upper left corner of the intersection.

[out]

width

width of the intersection.

[out]

height

height of the intersection.

[out]

Returns

TRUE if the returned area is not empty.

Since: 2.2


gimp_drawable_has_alpha ()

gboolean
gimp_drawable_has_alpha (GimpDrawable *drawable);

Returns TRUE 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 }.

Parameters

drawable

The drawable.

 

Returns

Does the drawable have an alpha channel?


gimp_drawable_type_with_alpha ()

GimpImageType
gimp_drawable_type_with_alpha (GimpDrawable *drawable);

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.

Parameters

drawable

The drawable.

 

Returns

The drawable's type with alpha.


gimp_drawable_type ()

GimpImageType
gimp_drawable_type (GimpDrawable *drawable);

Returns the drawable's type.

This procedure returns the drawable's type.

Parameters

drawable

The drawable.

 

Returns

The drawable's type.


gimp_drawable_is_rgb ()

gboolean
gimp_drawable_is_rgb (GimpDrawable *drawable);

Returns whether the drawable is an RGB type.

This procedure returns TRUE if the specified drawable is of type { RGB, RGBA }.

Parameters

drawable

The drawable.

 

Returns

TRUE if the drawable is an RGB type.


gimp_drawable_is_gray ()

gboolean
gimp_drawable_is_gray (GimpDrawable *drawable);

Returns whether the drawable is a grayscale type.

This procedure returns TRUE if the specified drawable is of type { Gray, GrayA }.

Parameters

drawable

The drawable.

 

Returns

TRUE if the drawable is a grayscale type.


gimp_drawable_is_indexed ()

gboolean
gimp_drawable_is_indexed (GimpDrawable *drawable);

Returns whether the drawable is an indexed type.

This procedure returns TRUE if the specified drawable is of type { Indexed, IndexedA }.

Parameters

drawable

The drawable.

 

Returns

TRUE if the drawable is an indexed type.


gimp_drawable_bpp ()

gint
gimp_drawable_bpp (GimpDrawable *drawable);

Returns the bytes per pixel.

This procedure returns the number of bytes per pixel.

Parameters

drawable

The drawable.

 

Returns

Bytes per pixel.


gimp_drawable_width ()

gint
gimp_drawable_width (GimpDrawable *drawable);

Returns the width of the drawable.

This procedure returns the specified drawable's width in pixels.

Parameters

drawable

The drawable.

 

Returns

Width of drawable.


gimp_drawable_height ()

gint
gimp_drawable_height (GimpDrawable *drawable);

Returns the height of the drawable.

This procedure returns the specified drawable's height in pixels.

Parameters

drawable

The drawable.

 

Returns

Height of drawable.


gimp_drawable_offsets ()

gboolean
gimp_drawable_offsets (GimpDrawable *drawable,
                       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.

Parameters

drawable

The drawable.

 

offset_x

x offset of drawable.

[out]

offset_y

y offset of drawable.

[out]

Returns

TRUE on success.


gimp_drawable_offset ()

gboolean
gimp_drawable_offset (GimpDrawable *drawable,
                      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.

Parameters

drawable

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_foreground_extract ()

gboolean
gimp_drawable_foreground_extract (GimpDrawable *drawable,
                                  GimpForegroundExtractMode mode,
                                  GimpDrawable *mask);

Extract the foreground of a drawable using a given trimap.

Image Segmentation by Uniform Color Clustering, see https://www.inf.fu-berlin.de/inst/pubs/tr-b-05-07.pdf

Parameters

drawable

The drawable.

 

mode

The algorithm to use.

 

mask

Tri-Map.

 

Returns

TRUE on success.

Since: 2.4

Types and Values