Next: , Previous: Scaling, Up: Top


33 Utilities

Utility and miscellaneous convenience functions.

33.1 Overview

These functions provide miscellaneous utilities for manipulating pixbufs. The pixel data in pixbufs may of course be manipulated directly by applications, but several common operations can be performed by these functions instead.

33.2 Usage

— Function: gdk-pixbuf-add-alpha (self <gdk-pixbuf>) (substitute_color bool) (unsigned-char) (unsigned-char) (unsigned-char) ⇒  (ret <gdk-pixbuf>)
— Method: add-alpha

Takes an existing pixbuf and adds an alpha channel to it. If the existing pixbuf already had an alpha channel, the channel values are copied from the original; otherwise, the alpha channel is initialized to 255 (full opacity).

If substitute-color is ‘#t’, then the color specified by (r, g, b) will be assigned zero opacity. That is, if you pass (255, 255, 255) for the substitute color, all white pixels will become fully transparent.

pixbuf
A <gdk-pixbuf>.
substitute-color
Whether to set a color to zero opacity. If this is ‘#f’, then the (r, g, b) arguments will be ignored.
r
Red value to substitute.
g
Green value to substitute.
b
Blue value to substitute.
ret
A newly-created pixbuf with a reference count of 1.
— Function: gdk-pixbuf-copy-area (self <gdk-pixbuf>) (src_x int) (src_y int) (width int) (height int) (dest_pixbuf <gdk-pixbuf>) (dest_x int) (dest_y int)
— Method: copy-area

Copies a rectangular area from src-pixbuf to dest-pixbuf. Conversion of pixbuf formats is done automatically.

src-pixbuf
Source pixbuf.
src-x
Source X coordinate within src-pixbuf.
src-y
Source Y coordinate within src-pixbuf.
width
Width of the area to copy.
height
Height of the area to copy.
dest-pixbuf
Destination pixbuf.
dest-x
X coordinate within dest-pixbuf.
dest-y
Y coordinate within dest-pixbuf.
— Function: gdk-pixbuf-saturate-and-pixelate (self <gdk-pixbuf>) (dest <gdk-pixbuf>) (saturation float) (pixelate bool)
— Method: saturate-and-pixelate

Modifies saturation and optionally pixelates src, placing the result in dest. src and dest may be the same pixbuf with no ill effects. If saturation is 1.0 then saturation is not changed. If it's less than 1.0, saturation is reduced (the image turns toward grayscale); if greater than 1.0, saturation is increased (the image gets more vivid colors). If pixelate is ‘#t’, then pixels are faded in a checkerboard pattern to create a pixelated image. src and dest must have the same image format, size, and rowstride.

src
source image
dest
place to write modified version of src
saturation
saturation factor
pixelate
whether to pixelate
— Function: gdk-pixbuf-fill (self <gdk-pixbuf>) (pixel unsigned-int32)
— Method: fill

Clears a pixbuf to the given RGBA value, converting the RGBA value into the pixbuf's pixel format. The alpha will be ignored if the pixbuf doesn't have an alpha channel.

pixbuf
a <gdk-pixbuf>
pixel
RGBA pixel to clear to (0xffffffff is opaque white, 0x00000000 transparent black)