Creates a new gdkpixbuf.pixbuf.Pixbuf structure and allocates a buffer for it.
Takes an existing pixbuf and adds an alpha channel to it.
Takes an existing pixbuf and checks for the presence of an associated "orientation" option.
Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y.
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.
Creates a new pixbuf by scaling src to dest_width x dest_height and alpha blending the result with a checkboard of colors color1 and color2.
Creates a new gdkpixbuf.pixbuf.Pixbuf with a copy of the information in the specified pixbuf.
Copies a rectangular area from src_pixbuf to dest_pixbuf.
Copies the key/value pair options attached to a gdkpixbuf.pixbuf.Pixbuf to another gdkpixbuf.pixbuf.Pixbuf.
Clears a pixbuf to the given RGBA value, converting the RGBA value into the pixbuf's pixel format.
Flips a pixbuf horizontally or vertically and returns the result in a new pixbuf.
Queries the number of bits per color sample in a pixbuf.
Returns the length of the pixel data, in bytes.
Queries the color space of a pixbuf.
Queries whether a pixbuf has an alpha channel (opacity information).
Queries the height of a pixbuf.
Queries the number of channels of a pixbuf.
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 gdkpixbuf.pixbuf.Pixbuf.setOption.
Returns a glib.hash_table.HashTable 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 gdkpixbuf.pixbuf.Pixbuf.setOption.
Queries a pointer to the pixel data of a pixbuf.
Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row and the start of the next row.
Queries the width of a pixbuf.
Creates a new pixbuf which represents a sub-region of src_pixbuf.
Provides a #GBytes buffer containing the raw pixel data; the data must not be modified.
Provides a read-only pointer to the raw pixel data.
Removes the key/value pair option attached to a gdkpixbuf.pixbuf.Pixbuf.
Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf.
Modifies saturation and optionally pixelates src, placing the result in dest.
Vector version of [gdkpixbuf.pixbuf.Pixbuf.saveToBuffer].
Vector version of [gdkpixbuf.pixbuf.Pixbuf.saveToCallback].
Saves pixbuf to an output stream.
Saves pixbuf to an output stream asynchronously.
Vector version of [gdkpixbuf.pixbuf.Pixbuf.save].
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.
Create a new pixbuf containing a copy of src scaled to dest_width x dest_height.
Attaches a key/value pair as an option to a gdkpixbuf.pixbuf.Pixbuf.
Calculates the rowstride that an image created with those values would have.
Parses an image file far enough to determine its format and size.
Asynchronously parses an image file far enough to determine its format and size.
Finishes an asynchronous pixbuf parsing operation started with gdkpixbuf.pixbuf.Pixbuf.getFileInfoAsync.
Obtains the available information about the image formats supported by GdkPixbuf.
Initalizes the gdk-pixbuf loader modules referenced by the loaders.cache file present inside that directory.
Creates a new #GdkPixbuf out of in-memory readonly image data.
Creates a new pixbuf by loading an image from a file.
Creates a new pixbuf by loading an image from a file.
Creates a new pixbuf by loading an image from a file.
Creates a gdkpixbuf.pixbuf.Pixbuf from a flat representation that is suitable for storing as inline data in a program.
Creates a new pixbuf by loading an image from an resource.
Creates a new pixbuf by loading an image from an resource.
Creates a new pixbuf by loading an image from an input stream.
Creates a new pixbuf by asynchronously loading an image from an input stream.
Creates a new pixbuf by loading an image from an input stream.
Creates a new pixbuf by asynchronously loading an image from an input stream.
Finishes an asynchronous pixbuf creation operation started with gdkpixbuf.pixbuf.Pixbuf.newFromStreamAsync.
Creates a new pixbuf by parsing XPM data in memory.
Finishes an asynchronous pixbuf save operation started with gdkpixbuf.pixbuf.Pixbuf.saveToStreamAsync.
Checks if two icons are equal.
Gets a hash for an icon.
Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved back by calling gio.icon.Icon.deserialize on the returned value. As serialization will avoid using raw icon data when possible, it only makes sense to transfer the #GVariant between processes on the same machine, (as opposed to over the network), and within the same file system namespace.
Generates a textual representation of icon that can be used for serialization such as when passing icon to a different process or saving it to persistent storage. Use gio.icon.Icon.newForString to get icon back from the returned string.
Loads a loadable icon. For the asynchronous version of this function, see gio.loadable_icon.LoadableIcon.loadAsync.
Loads an icon asynchronously. To finish this function, see gio.loadable_icon.LoadableIcon.loadFinish. For the synchronous, blocking version of this function, see gio.loadable_icon.LoadableIcon.load.
Finishes an asynchronous icon load started in gio.loadable_icon.LoadableIcon.loadAsync.
Set the GObject of a D ObjectG wrapper.
Get a pointer to the underlying C object.
Calls g_object_ref() on a GObject.
Calls g_object_unref() on a GObject.
Get the GType of an object.
GObject GType property.
Convenience method to return this cast to a type. For use in D with statements.
Template to get the D object from a C GObject and cast it to the given D object type.
Connect a D closure to an object signal.
Template for setting a GObject property.
Template for getting a GObject property.
Creates a binding between source_property on source and target_property on target.
Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.
This function is intended for #GObject implementations to re-enforce a floating[floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling gobject.object.ObjectG.refSink.
Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.
Gets a named field from the objects table of associations (see gobject.object.ObjectG.setData).
Gets a property of an object.
This function gets back user data pointers stored via gobject.object.ObjectG.setQdata.
Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.
Checks whether object has a floating[floating-ref] reference.
Emits a "notify" signal for the property property_name on object.
Emits a "notify" signal for the property specified by pspec on object.
Increase the reference count of object, and possibly remove the floating[floating-ref] reference, if object has a floating reference.
Releases all references to other objects. This can be used to break reference cycles.
Each object carries around a table of associations from strings to pointers. This function lets you set an association.
Sets a property on an object.
Remove a specified datum from the object's data associations, without invoking the association's destroy handler.
This function gets back user data pointers stored via gobject.object.ObjectG.setQdata and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:
Reverts the effect of a previous call to gobject.object.ObjectG.freezeNotify. The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.
This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling gobject.closure.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, gobject.object.ObjectG.ref_ and gobject.object.ObjectG.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.
Connect to Notify signal.
Deserializes a #GIcon previously serialized using gio.icon.Icon.serialize.
Generate a #GIcon instance from str. This function can fail if str is not valid - see gio.icon.Icon.toString_ for discussion.
Checks if two icons are equal.
Gets a hash for an icon.
Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved back by calling gio.icon.Icon.deserialize on the returned value. As serialization will avoid using raw icon data when possible, it only makes sense to transfer the #GVariant between processes on the same machine, (as opposed to over the network), and within the same file system namespace.
Generates a textual representation of icon that can be used for serialization such as when passing icon to a different process or saving it to persistent storage. Use gio.icon.Icon.newForString to get icon back from the returned string.
Loads a loadable icon. For the asynchronous version of this function, see gio.loadable_icon.LoadableIcon.loadAsync.
Loads an icon asynchronously. To finish this function, see gio.loadable_icon.LoadableIcon.loadFinish. For the synchronous, blocking version of this function, see gio.loadable_icon.LoadableIcon.load.
Finishes an asynchronous icon load started in gio.loadable_icon.LoadableIcon.loadAsync.
A pixel buffer.
gdkpixbuf.pixbuf.Pixbuf contains information about an 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).
Creating new gdkpixbuf.pixbuf.Pixbuf
The most basic way to create a pixbuf is to wrap an existing pixel buffer with a gdkpixbuf.pixbuf.Pixbuf instance. You can use the gdkpixbuf.pixbuf.Pixbuf.newFromData function to do this.
Every time you create a new gdkpixbuf.pixbuf.Pixbuf instance for some data, you will need to specify the destroy notification function that will be called when the data buffer needs to be freed; this will happen when a gdkpixbuf.pixbuf.Pixbuf is finalized by the reference counting functions. If you have a chunk of static data compiled into your application, you can pass in NULL as the destroy notification function so that the data will not be freed.
The gdkpixbuf.pixbuf.Pixbuf.new_ constructor function can be used as a convenience to create a pixbuf with an empty buffer; this is equivalent to allocating a data buffer using malloc() and then wrapping it with [gdkpixbuf.pixbuf.Pixbuf.newFromData]. The [gdkpixbuf.pixbuf.Pixbuf.new_] function will compute an optimal rowstride so that rendering can be performed with an efficient algorithm.
As a special case, you can use the gdkpixbuf.pixbuf.Pixbuf.newFromXpmData function to create a pixbuf from inline XPM image data.
You can also copy an existing pixbuf with the gdkpixbuf.pixbuf.Pixbuf.copy function. This is not the same as just acquiring a reference to the old pixbuf instance: the copy function will actually duplicate the pixel data in memory and create a new class@Pixbuf instance for it.
Reference counting
gdkpixbuf.pixbuf.Pixbuf structures are reference counted. This means that an application can share a single pixbuf among many parts of the code. When a piece of the program needs to use a pixbuf, it should acquire a reference to it by calling [gobject.object.ObjectG.ref_]; when it no longer needs the pixbuf, it should release the reference it acquired by calling [gobject.object.ObjectG.unref]. The resources associated with a gdkpixbuf.pixbuf.Pixbuf will be freed when its reference count drops to zero. Newly-created gdkpixbuf.pixbuf.Pixbuf instances start with a reference count of one.
Image Data
Image data in a pixbuf is stored in memory in an uncompressed, packed format. Rows in the image are stored top to bottom, and in each row pixels are stored from left to right.
There may be padding at the end of a row.
The "rowstride" value of a pixbuf, as returned by gdkpixbuf.pixbuf.Pixbuf.getRowstride, indicates the number of bytes between rows.
**NOTE**: If you are copying raw pixbuf data with memcpy() note that the last row in the pixbuf may not be as wide as the full rowstride, but rather just as wide as the pixel data needs to be; that is: it is unsafe to do memcpy (dest, pixels, rowstride * height) to copy a whole pixbuf. Use gdkpixbuf.pixbuf.Pixbuf.copy instead, or compute the width in bytes of the last row as:
The same rule applies when iterating over each row of a gdkpixbuf.pixbuf.Pixbuf pixels array.
The following code illustrates a simple put_pixel() function for RGB pixbufs with 8 bits per channel with an alpha channel.
Loading images
The GdkPixBuf class provides a simple mechanism for loading an image from a file in synchronous and asynchronous fashion.
For GUI applications, it is recommended to use the asynchronous stream API to avoid blocking the control flow of the application.
Additionally, gdkpixbuf.pixbuf.Pixbuf provides the gdkpixbuf.pixbuf_loader.PixbufLoader API for progressive image loading.
Saving images
The gdkpixbuf.pixbuf.Pixbuf class provides methods for saving image data in a number of file formats. The formatted data can be written to a file or to a memory buffer. gdkpixbuf.pixbuf.Pixbuf can also call a user-defined callback on the data, which allows to e.g. write the image to a socket or store it in a database.