Class: GdkPixbuf::Pixbuf
- Inherits:
-
Object
- Object
- GdkPixbuf::Pixbuf
- Defined in:
- (unknown)
Overview
This is the main structure in the gdk-pixbuf library. It is used to represent images. It contains information about the image’s pixel data, its color space, bits per sample, width and height, and the rowstride (the number of bytes between the start of one row and the start of the next).
Instance Method Summary collapse
-
#add_alpha(substitute_color, r, g, b) ⇒ GdkPixbuf::Pixbuf
Takes an existing pixbuf and adds an alpha channel to it.
-
#apply_embedded_orientation ⇒ GdkPixbuf::Pixbuf
Takes an existing pixbuf and checks for the presence of an associated “orientation” option, which may be provided by the jpeg loader (which reads the exif orientation tag) or the tiff loader (which reads the tiff orientation tag, and compensates it for the partial transforms performed by libtiff).
-
#bits_per_sample ⇒ Integer
The number of bits per sample.
-
#bits_per_sample=(bits_per_sample) ⇒ Integer
The number of bits per sample.
-
#byte_length ⇒ Integer
Returns the length of the pixel data, in bytes.
-
#colorspace ⇒ GdkPixbuf::Colorspace
Colorspace.
- #colorspace=(colorspace) ⇒ GdkPixbuf::Colorspace
-
#composite(dest, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type, overall_alpha) ⇒ nil
Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y.
-
#composite_color(dest, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type, overall_alpha, check_x, check_y, check_size, color1, color2) ⇒ nil
Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then alpha blends the rectangle (dest_x ,dest_y, dest_width, dest_height) of the resulting image with a checkboard of the colors color1 and color2 and renders it onto the destination image.
-
#composite_color_simple(dest_width, dest_height, interp_type, overall_alpha, check_size, color1, color2) ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf by scaling src to dest_width x dest_height and alpha blending the result with a checkboard of colors color1 and color2.
-
#copy ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf with a copy of the information in the specified pixbuf.
-
#copy_area(src_x, src_y, width, height, dest_pixbuf, dest_x, dest_y) ⇒ nil
Copies a rectangular area from src_pixbuf to dest_pixbuf.
-
#copy_options(dest_pixbuf) ⇒ TrueClass
Copy the key/value pair options attached to a Gdk::Pixbuf to another.
-
#fill(pixel) ⇒ nil
Clears a pixbuf to the given RGBA value, converting the RGBA value into the pixbuf’s pixel format.
-
#flip(horizontal) ⇒ GdkPixbuf::Pixbuf
Flips a pixbuf horizontally or vertically and returns the result in a new pixbuf.
-
#get_option(key) ⇒ String
Looks up key in the list of options that may have been attached to the pixbuf when it was loaded, or that may have been attached by another function using gdk_pixbuf_set_option().
-
#get_pixels_with_length(length) ⇒ Array<Integer>
Queries a pointer to the pixel data of a pixbuf.
-
#has_alpha ⇒ TrueClass
Queries whether a pixbuf has an alpha channel (opacity information).
- #has_alpha=(has_alpha) ⇒ TrueClass
-
#has_alpha? ⇒ TrueClass
Has-alpha.
-
#height ⇒ Integer
Height.
- #height=(height) ⇒ Integer
-
#n_channels ⇒ Integer
The number of samples per pixel.
-
#n_channels=(n_channels) ⇒ Integer
The number of samples per pixel.
-
#new(colorspace, has_alpha, bits_per_sample, width, height) ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf structure and allocates a buffer for it.
-
#new_from_bytes(data, colorspace, has_alpha, bits_per_sample, width, height, rowstride) ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf out of in-memory readonly image data.
-
#new_from_data(data, colorspace, has_alpha, bits_per_sample, width, height, rowstride, destroy_fn, destroy_fn_data) ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf out of in-memory image data.
-
#new_from_file(filename) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from a file.
-
#new_from_file_at_scale(filename, width, height, preserve_aspect_ratio) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from a file.
-
#new_from_file_at_size(filename, width, height) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from a file.
-
#new_from_inline(data_length, data, copy_pixels) ⇒ GdkPixbuf::Pixbuf
Create a Gdk::Pixbuf from a flat representation that is suitable for storing as inline data in a program.
-
#new_from_resource(resource_path) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from an resource.
-
#new_from_resource_at_scale(resource_path, width, height, preserve_aspect_ratio) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from an resource.
-
#new_from_stream(stream, cancellable) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from an input stream.
-
#new_from_stream_at_scale(stream, width, height, preserve_aspect_ratio, cancellable) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from an input stream.
-
#new_from_stream_finish(async_result) ⇒ GdkPixbuf::Pixbuf
Finishes an asynchronous pixbuf creation operation started with gdk_pixbuf_new_from_stream_async().
-
#new_from_xpm_data(data) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by parsing XPM data in memory.
-
#new_subpixbuf(src_x, src_y, width, height) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf which represents a sub-region of src_pixbuf.
-
#options ⇒ GLib::HashTable
Returns a GHash::Table with a list of all the options that may have been attached to the pixbuf when it was loaded, or that may have been attached by another function using gdk_pixbuf_set_option().
-
#pixel_bytes ⇒ GLib::Bytes
Pixel-bytes.
- #pixel_bytes=(pixel_bytes) ⇒ GLib::Bytes
-
#pixels ⇒ GObject
Pixels.
- #pixels=(pixels) ⇒ GObject
-
#read_pixel_bytes ⇒ GLib::Bytes
Provides a #GBytes buffer containing the raw pixel data; the data must not be modified.
-
#read_pixels ⇒ Integer
Provides a read-only pointer to the raw pixel data; must not be modified.
-
#ref ⇒ GdkPixbuf::Pixbuf
Adds a reference to a pixbuf.
-
#remove_option(key) ⇒ TrueClass
Remove the key/value pair option attached to a Gdk::Pixbuf.
-
#rotate_simple(angle) ⇒ GdkPixbuf::Pixbuf
Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf.
-
#rowstride ⇒ Integer
The number of bytes between the start of a row and the start of the next row.
-
#rowstride=(rowstride) ⇒ Integer
The number of bytes between the start of a row and the start of the next row.
-
#saturate_and_pixelate(dest, saturation, pixelate) ⇒ nil
Modifies saturation and optionally pixelates src, placing the result in dest.
-
#save(filename, type, error, array) ⇒ TrueClass
Saves pixbuf to a file in format type.
-
#save_to_buffer(buffer, buffer_size, type, error, array) ⇒ TrueClass
Saves pixbuf to a new buffer in format type, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”.
-
#save_to_bufferv(buffer, buffer_size, type, option_keys, option_values) ⇒ TrueClass
Saves pixbuf to a new buffer in format type, which is currently “jpeg”, “tiff”, “png”, “ico” or “bmp”.
-
#save_to_callback(save_func, user_data, type, error, array) ⇒ TrueClass
Saves pixbuf in format type by feeding the produced data to a callback.
-
#save_to_callbackv(save_func, user_data, type, option_keys, option_values) ⇒ TrueClass
Saves pixbuf to a callback in format type, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”.
-
#save_to_stream(stream, type, cancellable, error, array) ⇒ TrueClass
Saves pixbuf to an output stream.
-
#save_to_stream_async(stream, type, cancellable, callback, user_data, array) ⇒ nil
Saves pixbuf to an output stream asynchronously.
-
#save_to_streamv(stream, type, option_keys, option_values, cancellable) ⇒ TrueClass
Saves pixbuf to an output stream.
-
#save_to_streamv_async(stream, type, option_keys, option_values, cancellable, callback, user_data) ⇒ nil
Saves pixbuf to an output stream asynchronously.
-
#savev(filename, type, option_keys, option_values) ⇒ TrueClass
Saves pixbuf to a file in type, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”.
-
#scale(dest, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type) ⇒ nil
Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then renders the rectangle (dest_x, dest_y, dest_width, dest_height) of the resulting image onto the destination image replacing the previous contents.
-
#scale_simple(dest_width, dest_height, interp_type) ⇒ GdkPixbuf::Pixbuf
Create a new Gdk::Pixbuf containing a copy of src scaled to dest_width x dest_height.
-
#set_option(key, value) ⇒ TrueClass
Attaches a key/value pair as an option to a Gdk::Pixbuf.
-
#unref ⇒ nil
Removes a reference from a pixbuf.
-
#width ⇒ Integer
Width.
- #width=(width) ⇒ Integer
Instance Method Details
#add_alpha(substitute_color, r, g, b) ⇒ GdkPixbuf::Pixbuf
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 true, 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. is false, then the (r, g, b) arguments will be ignored.
#apply_embedded_orientation ⇒ GdkPixbuf::Pixbuf
Takes an existing pixbuf and checks for the presence of an associated “orientation” option, which may be provided by the jpeg loader (which reads the exif orientation tag) or the tiff loader (which reads the tiff orientation tag, and compensates it for the partial transforms performed by libtiff). If an orientation option/tag is present, the appropriate transform will be performed so that the pixbuf is oriented correctly. not enough memory could be allocated for it, or a reference to the input pixbuf (with an increased reference count).
#bits_per_sample ⇒ Integer
The number of bits per sample. Currently only 8 bit per sample are supported.
#bits_per_sample=(bits_per_sample) ⇒ Integer
The number of bits per sample. Currently only 8 bit per sample are supported.
#byte_length ⇒ Integer
Returns the length of the pixel data, in bytes.
#colorspace ⇒ GdkPixbuf::Colorspace
Returns colorspace.
#colorspace=(colorspace) ⇒ GdkPixbuf::Colorspace
#composite(dest, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type, overall_alpha) ⇒ nil
Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y. This gives an image in the coordinates of the destination pixbuf. The rectangle (dest_x, dest_y, dest_width, dest_height) is then alpha blended onto the corresponding rectangle of the original destination image.
When the destination rectangle contains parts not in the source image, the data at the edges of the source image is replicated to infinity.

#composite_color(dest, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type, overall_alpha, check_x, check_y, check_size, color1, color2) ⇒ nil
Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then alpha blends the rectangle (dest_x ,dest_y, dest_width, dest_height) of the resulting image with a checkboard of the colors color1 and color2 and renders it onto the destination image.
If the source image has no alpha channel, and overall_alpha is 255, a fast path is used which omits the alpha blending and just performs the scaling.
See gdk_pixbuf_composite_color_simple() for a simpler variant of this function suitable for many tasks.
#composite_color_simple(dest_width, dest_height, interp_type, overall_alpha, check_size, color1, color2) ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf by scaling src to dest_width x dest_height and alpha blending the result with a checkboard of colors color1 and color2. allocated for it.
#copy ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf with a copy of the information in the specified pixbuf. Note that this does not copy the options set on the original Gdk::Pixbuf, use gdk_pixbuf_copy_options() for this. not enough memory could be allocated.
#copy_area(src_x, src_y, width, height, dest_pixbuf, dest_x, dest_y) ⇒ nil
Copies a rectangular area from src_pixbuf to dest_pixbuf. Conversion of pixbuf formats is done automatically.
If the source rectangle overlaps the destination rectangle on the same pixbuf, it will be overwritten during the copy operation. Therefore, you can not use this function to scroll a pixbuf.
#copy_options(dest_pixbuf) ⇒ TrueClass
Copy the key/value pair options attached to a Gdk::Pixbuf to another. This is useful to keep original metadata after having manipulated a file. However be careful to remove metadata which you’ve already applied, such as the “orientation” option after rotating the image.
#fill(pixel) ⇒ nil
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.
#flip(horizontal) ⇒ GdkPixbuf::Pixbuf
Flips a pixbuf horizontally or vertically and returns the result in a new pixbuf. if not enough memory could be allocated for it.
#get_option(key) ⇒ String
Looks up key in the list of options that may have been attached to the pixbuf when it was loaded, or that may have been attached by another function using gdk_pixbuf_set_option().
For instance, the ANI loader provides “Title” and “Artist” options. The ICO, XBM, and XPM loaders provide “x_hot” and “y_hot” hot-spot options for cursor definitions. The PNG loader provides the tEXt ancillary chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders return an “orientation” option string that corresponds to the embedded TIFF/Exif orientation tag (if present). Since 2.32, the TIFF loader sets the “multipage” option string to “yes” when a multi-page TIFF is loaded. Since 2.32 the JPEG and PNG loaders set “x-dpi” and “y-dpi” if the file contains image density information in dots per inch. Since 2.36.6, the JPEG loader sets the “comment” option with the comment EXIF tag. string that should not be freed or nil if key was not found.
#get_pixels_with_length(length) ⇒ Array<Integer>
Queries a pointer to the pixel data of a pixbuf. pixel data. Please see the section on [image data] for information about how the pixel data is stored in memory.
This function will cause an implicit copy of the pixbuf data if the pixbuf was created from read-only data.
#has_alpha ⇒ TrueClass
Queries whether a pixbuf has an alpha channel (opacity information).
#has_alpha=(has_alpha) ⇒ TrueClass
#has_alpha? ⇒ TrueClass
Returns has-alpha.
#height ⇒ Integer
Returns height.
#height=(height) ⇒ Integer
#n_channels ⇒ Integer
The number of samples per pixel. Currently, only 3 or 4 samples per pixel are supported.
#n_channels=(n_channels) ⇒ Integer
The number of samples per pixel. Currently, only 3 or 4 samples per pixel are supported.
#new(colorspace, has_alpha, bits_per_sample, width, height) ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf structure and allocates a buffer for it. The buffer has an optimal rowstride. Note that the buffer is not cleared; you will have to fill it completely yourself. nil if not enough memory could be allocated for the image buffer.
#new_from_bytes(data, colorspace, has_alpha, bits_per_sample, width, height, rowstride) ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf out of in-memory readonly image data. Currently only RGB images with 8 bits per sample are supported. This is the #GBytes variant of gdk_pixbuf_new_from_data().
#new_from_data(data, colorspace, has_alpha, bits_per_sample, width, height, rowstride, destroy_fn, destroy_fn_data) ⇒ GdkPixbuf::Pixbuf
Creates a new Gdk::Pixbuf out of in-memory image data. Currently only RGB images with 8 bits per sample are supported.
Since you are providing a pre-allocated pixel buffer, you must also specify a way to free that data. This is done with a function of type Gdk::PixbufDestroyNotify. When a pixbuf created with is finalized, your destroy notification function will be called, and it is its responsibility to free the pixel array.
See also gdk_pixbuf_new_from_bytes(). drops to zero, or nil if the data should not be freed
#new_from_file(filename) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from a file. The file format is detected automatically. If nil is returned, then error will be set. Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains. any of several error conditions occurred: the file could not be opened, there was no loader for the file’s format, there was not enough memory to allocate the image buffer, or the image file contained invalid data.
#new_from_file_at_scale(filename, width, height, preserve_aspect_ratio) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from a file. The file format is detected automatically. If nil is returned, then error will be set. Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains. The image will be scaled to fit in the requested size, optionally preserving the image’s aspect ratio.
When preserving the aspect ratio, a width of -1 will cause the image to be scaled to the exact given height, and a height of -1 will cause the image to be scaled to the exact given width. When not preserving aspect ratio, a width or height of -1 means to not scale the image at all in that dimension. Negative values for width and height are allowed since 2.8. if any of several error conditions occurred: the file could not be opened, there was no loader for the file’s format, there was not enough memory to allocate the image buffer, or the image file contained invalid data.
#new_from_file_at_size(filename, width, height) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from a file. The file format is detected automatically. If nil is returned, then error will be set. Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
The image will be scaled to fit in the requested size, preserving the image’s aspect ratio. Note that the returned pixbuf may be smaller than width x height, if the aspect ratio requires it. To load and image at the requested size, regardless of aspect ratio, use gdk_pixbuf_new_from_file_at_scale(). nil if any of several error conditions occurred: the file could not be opened, there was no loader for the file’s format, there was not enough memory to allocate the image buffer, or the image file contained invalid data.
#new_from_inline(data_length, data, copy_pixels) ⇒ GdkPixbuf::Pixbuf
Create a Gdk::Pixbuf from a flat representation that is suitable for storing as inline data in a program. This is useful if you want to ship a program with images, but don’t want to depend on any external files.
gdk-pixbuf ships with a program called [gdk-pixbuf-csource], which allows for conversion of Gdk::Pixbufs into such a inline representation. In almost all cases, you should pass the ‘–raw` option to `gdk-pixbuf-csource`. A sample invocation would be:
|[
gdk-pixbuf-csource --raw --name=myimage_inline myimage.png
]|
For the typical case where the inline pixbuf is read-only static data, you don’t need to copy the pixel data unless you intend to write to it, so you can pass false for copy_pixels. (If you pass ‘–rle` to `gdk-pixbuf-csource`, a copy will be made even if copy_pixels is false, so using this option is generally a bad idea.)
If you create a pixbuf from const inline data compiled into your program, it’s probably safe to ignore errors and disable length checks, since things will always succeed: |[ pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL); ]|
For non-const inline data, you could get out of memory. For untrusted inline data located at runtime, you could have corrupt inline data in addition.
#new_from_resource(resource_path) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from an resource.
The file format is detected automatically. If nil is returned, then error will be set. conditions occurred: the file could not be opened, the image format is not supported, there was not enough memory to allocate the image buffer, the stream contained invalid data, or the operation was cancelled.
#new_from_resource_at_scale(resource_path, width, height, preserve_aspect_ratio) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from an resource.
The file format is detected automatically. If nil is returned, then error will be set.
The image will be scaled to fit in the requested size, optionally preserving the image’s aspect ratio. When preserving the aspect ratio, a width of -1 will cause the image to be scaled to the exact given height, and a height of -1 will cause the image to be scaled to the exact given width. When not preserving aspect ratio, a width or height of -1 means to not scale the image at all in that dimension.
The stream is not closed. conditions occurred: the file could not be opened, the image format is not supported, there was not enough memory to allocate the image buffer, the stream contained invalid data, or the operation was cancelled.
#new_from_stream(stream, cancellable) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from an input stream.
The file format is detected automatically. If nil is returned, then error will be set. The cancellable can be used to abort the operation from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. Other possible errors are in the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains.
The stream is not closed. conditions occurred: the file could not be opened, the image format is not supported, there was not enough memory to allocate the image buffer, the stream contained invalid data, or the operation was cancelled.
#new_from_stream_at_scale(stream, width, height, preserve_aspect_ratio, cancellable) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by loading an image from an input stream.
The file format is detected automatically. If nil is returned, then error will be set. The cancellable can be used to abort the operation from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. Other possible errors are in the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains.
The image will be scaled to fit in the requested size, optionally preserving the image’s aspect ratio.
When preserving the aspect ratio, a width of -1 will cause the image to be scaled to the exact given height, and a height of -1 will cause the image to be scaled to the exact given width. If both width and height are given, this function will behave as if the smaller of the two values is passed as -1.
When not preserving aspect ratio, a width or height of -1 means to not scale the image at all in that dimension.
The stream is not closed. conditions occurred: the file could not be opened, the image format is not supported, there was not enough memory to allocate the image buffer, the stream contained invalid data, or the operation was cancelled.
#new_from_stream_finish(async_result) ⇒ GdkPixbuf::Pixbuf
Finishes an asynchronous pixbuf creation operation started with gdk_pixbuf_new_from_stream_async(). object with g_object_unref().
#new_from_xpm_data(data) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf by parsing XPM data in memory. This data is commonly the result of including an XPM file into a program’s C source.
#new_subpixbuf(src_x, src_y, width, height) ⇒ GdkPixbuf::Pixbuf
Creates a new pixbuf which represents a sub-region of src_pixbuf. The new pixbuf shares its pixels with the original pixbuf, so writing to one affects both. The new pixbuf holds a reference to src_pixbuf, so src_pixbuf will not be finalized until the new pixbuf is finalized.
Note that if src_pixbuf is read-only, this function will force it to be mutable.
#options ⇒ GLib::HashTable
Returns a GHash::Table with a list of all the options that may have been attached to the pixbuf when it was loaded, or that may have been attached by another function using gdk_pixbuf_set_option().
See gdk_pixbuf_get_option() for more details.
#pixel_bytes ⇒ GLib::Bytes
Returns pixel-bytes.
#pixel_bytes=(pixel_bytes) ⇒ GLib::Bytes
#pixels ⇒ GObject
Returns pixels.
#pixels=(pixels) ⇒ GObject
#read_pixel_bytes ⇒ GLib::Bytes
Provides a #GBytes buffer containing the raw pixel data; the data must not be modified. This function allows skipping the implicit copy that must be made if gdk_pixbuf_get_pixels() is called on a read-only pixbuf.
#read_pixels ⇒ Integer
Provides a read-only pointer to the raw pixel data; must not be modified. This function allows skipping the implicit copy that must be made if gdk_pixbuf_get_pixels() is called on a read-only pixbuf.
#ref ⇒ GdkPixbuf::Pixbuf
Adds a reference to a pixbuf.
#remove_option(key) ⇒ TrueClass
Remove the key/value pair option attached to a Gdk::Pixbuf.
#rotate_simple(angle) ⇒ GdkPixbuf::Pixbuf
Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf.
If angle is 0, a copy of src is returned, avoiding any rotation. if not enough memory could be allocated for it.
#rowstride ⇒ Integer
The number of bytes between the start of a row and the start of the next row. This number must (obviously) be at least as large as the width of the pixbuf.
#rowstride=(rowstride) ⇒ Integer
The number of bytes between the start of a row and the start of the next row. This number must (obviously) be at least as large as the width of the pixbuf.
#saturate_and_pixelate(dest, saturation, pixelate) ⇒ nil
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 true, 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.
#save(filename, type, error, array) ⇒ TrueClass
Saves pixbuf to a file in format type. By default, “jpeg”, “png”, “ico” and “bmp” are possible file formats to save in, but more formats may be installed. The list of all writable formats can be determined in the following way:
|[ void add_if_writable (GdkPixbufFormat *data, GSList **list)
if (gdk_pixbuf_format_is_writable (data))
*list = g_slist_prepend (*list, data);
GSList *formats = gdk_pixbuf_get_formats (); GSList *writable_formats = NULL; g_slist_foreach (formats, add_if_writable, &writable_formats); g_slist_free (formats); ]|
If error is set, false will be returned. Possible errors include those in the #GDK_PIXBUF_ERROR domain and those in the #G_FILE_ERROR domain.
The variable argument list should be nil-terminated; if not empty, it should contain pairs of strings that modify the save parameters. For example: |[ gdk_pixbuf_save (pixbuf, handle, “jpeg”, &error, “quality”, “100”, NULL); ]|
Currently only few parameters exist. JPEG images can be saved with a “quality” parameter; its value should be in the range [0,100]. JPEG and PNG density can be set by setting the “x-dpi” and “y-dpi” parameters to the appropriate values in dots per inch.
Text chunks can be attached to PNG images by specifying parameters of the form “tEXt::key”, where key is an ASCII string of length 1-79. The values are UTF-8 encoded strings. The PNG compression level can be specified using the “compression” parameter; it’s value is in an integer in the range of [0,9].
ICC color profiles can also be embedded into PNG, JPEG and TIFF images. The “icc-profile” value should be the complete ICC profile encoded into base64.
|[ gchar *contents; gchar *contents_encode; gsize length; g_file_get_contents (“/home/hughsie/.color/icc/L225W.icm”, &contents, &length, NULL); contents_encode = g_base64_encode ((const guchar *) contents, length); gdk_pixbuf_save (pixbuf, handle, “png”, &error, “icc-profile”, contents_encode, NULL); ]|
TIFF images recognize: (1) a “bits-per-sample” option (integer) which can be either 1 for saving bi-level CCITTFAX4 images, or 8 for saving 8-bits per sample; (2) a “compression” option (integer) which can be 1 for no compression, 2 for Huffman, 5 for LZW, 7 for JPEG and 8 for DEFLATE (see the libtiff documentation and tiff.h for all supported codec values); (3) an “icc-profile” option (zero-terminated string) containing a base64 encoded ICC color profile.
ICO images can be saved in depth 16, 24, or 32, by using the “depth” parameter. When the ICO saver is given “x_hot” and “y_hot” parameters, it produces a CUR instead of an ICO.
#save_to_buffer(buffer, buffer_size, type, error, array) ⇒ TrueClass
Saves pixbuf to a new buffer in format type, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”. This is a convenience function that uses gdk_pixbuf_save_to_callback() to do the real work. Note that the buffer is not nul-terminated and may contain embedded nuls. If error is set, false will be returned and buffer will be set to nil. Possible errors include those in the #GDK_PIXBUF_ERROR domain.
See gdk_pixbuf_save() for more details.
#save_to_bufferv(buffer, buffer_size, type, option_keys, option_values) ⇒ TrueClass
Saves pixbuf to a new buffer in format type, which is currently “jpeg”, “tiff”, “png”, “ico” or “bmp”. See gdk_pixbuf_save_to_buffer() for more details.
#save_to_callback(save_func, user_data, type, error, array) ⇒ TrueClass
Saves pixbuf in format type by feeding the produced data to a callback. Can be used when you want to store the image to something other than a file, such as an in-memory buffer or a socket. If error is set, false will be returned. Possible errors include those in the #GDK_PIXBUF_ERROR domain and whatever the save function generates.
See gdk_pixbuf_save() for more details.
#save_to_callbackv(save_func, user_data, type, option_keys, option_values) ⇒ TrueClass
Saves pixbuf to a callback in format type, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”. If error is set, false will be returned. See gdk_pixbuf_save_to_callback () for more details.
#save_to_stream(stream, type, cancellable, error, array) ⇒ TrueClass
Saves pixbuf to an output stream.
Supported file formats are currently “jpeg”, “tiff”, “png”, “ico” or “bmp”. See gdk_pixbuf_save_to_buffer() for more details.
The cancellable can be used to abort the operation from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. Other possible errors are in the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains.
The stream is not closed.
#save_to_stream_async(stream, type, cancellable, callback, user_data, array) ⇒ nil
Saves pixbuf to an output stream asynchronously.
For more details see gdk_pixbuf_save_to_stream(), which is the synchronous version of this function.
When the operation is finished, callback will be called in the main thread. You can then call gdk_pixbuf_save_to_stream_finish() to get the result of the operation.
#save_to_streamv(stream, type, option_keys, option_values, cancellable) ⇒ TrueClass
Saves pixbuf to an output stream.
Supported file formats are currently “jpeg”, “tiff”, “png”, “ico” or “bmp”. See gdk_pixbuf_save_to_stream() for more details.
#save_to_streamv_async(stream, type, option_keys, option_values, cancellable, callback, user_data) ⇒ nil
Saves pixbuf to an output stream asynchronously.
For more details see gdk_pixbuf_save_to_streamv(), which is the synchronous version of this function.
When the operation is finished, callback will be called in the main thread. You can then call gdk_pixbuf_save_to_stream_finish() to get the result of the operation.
#savev(filename, type, option_keys, option_values) ⇒ TrueClass
Saves pixbuf to a file in type, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”. If error is set, false will be returned. See gdk_pixbuf_save () for more details.
#scale(dest, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type) ⇒ nil
Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then renders the rectangle (dest_x, dest_y, dest_width, dest_height) of the resulting image onto the destination image replacing the previous contents.
Try to use gdk_pixbuf_scale_simple() first, this function is the industrial-strength power tool you can fall back to if gdk_pixbuf_scale_simple() isn’t powerful enough.
If the source rectangle overlaps the destination rectangle on the same pixbuf, it will be overwritten during the scaling which results in rendering artifacts.
#scale_simple(dest_width, dest_height, interp_type) ⇒ GdkPixbuf::Pixbuf
Create a new Gdk::Pixbuf containing a copy of src scaled to dest_width x dest_height. Leaves src unaffected. interp_type should be #GDK_INTERP_NEAREST if you want maximum speed (but when scaling down #GDK_INTERP_NEAREST is usually unusably ugly). The default interp_type should be #GDK_INTERP_BILINEAR which offers reasonable quality and speed.
You can scale a sub-portion of src by creating a sub-pixbuf pointing into src; see gdk_pixbuf_new_subpixbuf().
If dest_width and dest_height are equal to the src width and height, a copy of src is returned, avoiding any scaling.
For more complicated scaling/alpha blending see gdk_pixbuf_scale() and gdk_pixbuf_composite(). allocated for it.
#set_option(key, value) ⇒ TrueClass
Attaches a key/value pair as an option to a Gdk::Pixbuf. If key already exists in the list of options attached to pixbuf, the new value is ignored and false is returned.
#unref ⇒ nil
Removes a reference from a pixbuf.
#width ⇒ Integer
Returns width.