Pixbuf
Object Hierarchy:
Description:
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).
Namespace: Gdk
Package: gdk-pixbuf-2.0
Content:
Properties:
- public int bits_per_sample { get; construct; }
The number of bits per sample.
- public Colorspace colorspace { get; construct; }
- public bool has_alpha { get; construct; }
- public int height { get; construct; }
- public int n_channels { get; construct; }
The number of samples per pixel.
- public Bytes pixel_bytes { owned get; construct; }
- public void* pixels { get; construct; }
- public int rowstride { get; construct; }
The number of bytes between the start of a row and the start of the next row.
- public int width { get; construct; }
Static methods:
- public static int calculate_rowstride (Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height)
Calculates the rowstride that an image created with those values would have.
- public static Pixbuf from_pixdata (Pixdata pixdata, bool copy_pixels = true) throws Error
- public static unowned PixbufFormat? get_file_info (string filename, out int width, out int height)
Parses an image file far enough to determine its format and size.
- public static async unowned PixbufFormat get_file_info_async (string filename, Cancellable? cancellable, out int width, out int height) throws Error
Asynchronously parses an image file far enough to determine its format and size.
- public static SList<unowned PixbufFormat> get_formats ()
Obtains the available information about the image formats supported by GdkPixbuf.
- public static bool init_modules (string path) throws Error
Initalizes the gdk-pixbuf loader modules referenced by the loaders.
Creation methods:
- public Pixbuf (Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height)
Creates a new Pixbuf structure and allocates a buffer for it.
- public Pixbuf.from_bytes (Bytes data, Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride)
Creates a new Pixbuf out of in-memory readonly image data.
- public Pixbuf.from_data (owned uint8[] data, Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, PixbufDestroyNotify? destroy_fn = free)
- public Pixbuf.from_file (string filename) throws Error
Creates a new pixbuf by loading an image from a file.
- public Pixbuf.from_file_at_scale (string filename, int width, int height, bool preserve_aspect_ratio) throws Error
Creates a new pixbuf by loading an image from a file.
- public Pixbuf.from_file_at_size (string filename, int width, int height) throws Error
Creates a new pixbuf by loading an image from a file.
- public Pixbuf.from_inline (uint8[] data, bool copy_pixels = true) throws Error
Create a Pixbuf from a flat representation that is suitable for storing as inline data in a program.
- public Pixbuf.from_resource (string resource_path) throws Error
Creates a new pixbuf by loading an image from an resource.
- public Pixbuf.from_resource_at_scale (string resource_path, int width, int height, bool preserve_aspect_ratio) throws Error
Creates a new pixbuf by loading an image from an resource.
- public Pixbuf.from_stream (InputStream stream, Cancellable? cancellable = null) throws Error
Creates a new pixbuf by loading an image from an input stream.
- public async Pixbuf.from_stream_async (InputStream stream, Cancellable? cancellable = null) throws Error
Creates a new pixbuf by asynchronously loading an image from an input stream.
- public Pixbuf.from_stream_at_scale (InputStream stream, int width, int height, bool preserve_aspect_ratio, Cancellable? cancellable = null) throws Error
Creates a new pixbuf by loading an image from an input stream.
- public async Pixbuf.from_stream_at_scale_async (InputStream stream, int width, int height, bool preserve_aspect_ratio, Cancellable? cancellable = null) throws Error
Creates a new pixbuf by asynchronously loading an image from an input stream.
- public Pixbuf.from_xpm_data (string[] data)
Creates a new pixbuf by parsing XPM data in memory.
- public Pixbuf.subpixbuf (Pixbuf src_pixbuf, int src_x, int src_y, int width, int height)
Creates a new pixbuf which represents a sub-region of this.
- public Pixbuf.with_unowned_data (uint8[] data, Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, PixbufDestroyNotify? destroy_fn = null)
Creates a new Pixbuf out of in-memory image data.
Methods:
- public Pixbuf add_alpha (bool substitute_color, uint8 r, uint8 g, uint8 b)
Takes an existing pixbuf and adds an alpha channel to it.
- public Pixbuf apply_embedded_orientation ()
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).
- public void composite (Pixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, InterpType interp_type, int overall_alpha)
Creates a transformation of the source image this by scaling by
scale_xandscale_ythen translating byoffset_xandoffset_y. - public void composite_color (Pixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, InterpType interp_type, int overall_alpha, int check_x, int check_y, int check_size, uint32 color1, uint32 color2)
Creates a transformation of the source image this by scaling by
scale_xandscale_ythen translating byoffset_xandoffset_y, then alpha blends the rectangle (dest_x,dest_y,dest_width,dest_height) of the resulting image with a checkboard of the colorscolor1andcolor2and renders it onto the destination image. - public Pixbuf? composite_color_simple (int dest_width, int dest_height, InterpType interp_type, int overall_alpha, int check_size, uint32 color1, uint32 color2)
Creates a new Pixbuf by scaling this to
dest_widthxdest_heightand alpha blending the result with a checkboard of colorscolor1andcolor2. - public Pixbuf? copy ()
Creates a new Pixbuf with a copy of the information in the specified this.
- public void copy_area (int src_x, int src_y, int width, int height, Pixbuf dest_pixbuf, int dest_x, int dest_y)
Copies a rectangular area from this to
dest_pixbuf. - public bool copy_options (Pixbuf dest_pixbuf)
Copy the key/value pair options attached to a Pixbuf to another.
- public void fill (uint32 pixel)
Clears a pixbuf to the given RGBA value, converting the RGBA value into the pixbuf's pixel format.
- public Pixbuf? flip (bool horizontal)
Flips a pixbuf horizontally or vertically and returns the result in a new pixbuf.
- public int get_bits_per_sample ()
Queries the number of bits per color sample in a pixbuf.
- public size_t get_byte_length ()
Returns the length of the pixel data, in bytes.
- public Colorspace get_colorspace ()
Queries the color space of a pixbuf.
- public bool get_has_alpha ()
Queries whether a pixbuf has an alpha channel (opacity information).
- public int get_height ()
Queries the height of a pixbuf.
- public int get_n_channels ()
Queries the number of channels of a pixbuf.
- public unowned string get_option (string key)
Looks up
keyin the list of options that may have been attached to the this when it was loaded, or that may have been attached by another function using set_option. - public HashTable<unowned string,unowned string> get_options ()
Returns a GenericSet with a list of all the options that may have been attached to the this when it was loaded, or that may have been attached by another function using set_option.
- public unowned uint8[] get_pixels ()
Queries a pointer to the pixel data of a pixbuf.
- public unowned uint8[] get_pixels_with_length ()
Queries a pointer to the pixel data of a pixbuf.
- public int get_rowstride ()
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.
- public int get_width ()
Queries the width of a pixbuf.
- public Bytes read_pixel_bytes ()
Provides a Bytes buffer containing the raw pixel data; the data must not be modified.
- public uint8 read_pixels ()
Provides a read-only pointer to the raw pixel data; must not be modified.
- public bool remove_option (string key)
Remove the key/value pair option attached to a Pixbuf .
- public Pixbuf? rotate_simple (PixbufRotation angle)
Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf.
- public void saturate_and_pixelate (Pixbuf dest, float saturation, bool pixelate)
Modifies saturation and optionally pixelates this , placing the result in
dest. - public bool save (string filename, string type, ...) throws Error
Saves pixbuf to a file in format
type. - public bool save_to_buffer (out uint8[] buffer, string type, ...) throws Error
Saves pixbuf to a new buffer in format
type, which is currently "jpeg", "png", "tiff", "ico" or "bmp". - public bool save_to_bufferv (out uint8[] buffer, string type, string[] option_keys, string[] option_values) throws Error
Saves pixbuf to a new buffer in format
type, which is currently "jpeg", "tiff", "png", "ico" or "bmp". - public bool save_to_callback (PixbufSaveFunc save_func, string type, ...) throws Error
Saves pixbuf in format
typeby feeding the produced data to a callback. - public bool save_to_callbackv (PixbufSaveFunc save_func, string type, string[] option_keys, string[] option_values) throws Error
Saves pixbuf to a callback in format
type, which is currently "jpeg", "png", "tiff", "ico" or "bmp". - public bool save_to_stream (OutputStream stream, string type, Cancellable? cancellable = null, ...) throws Error
Saves this to an output stream.
- public async void save_to_stream_async (OutputStream stream, string type, Cancellable? cancellable = null, ...) throws Error
Saves this to an output stream asynchronously.
- public bool save_to_streamv (OutputStream stream, string type, string[] option_keys, string[] option_values, Cancellable? cancellable = null) throws Error
Saves this to an output stream.
- public async void save_to_streamv_async (OutputStream stream, string type, string[] option_keys, string[] option_values, Cancellable? cancellable = null) throws Error
Saves this to an output stream asynchronously.
- public bool savev (string filename, string type, string[] option_keys, string[] option_values) throws Error
Saves pixbuf to a file in
type, which is currently "jpeg", "png", "tiff", "ico" or "bmp". - public void scale (Pixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, InterpType interp_type)
Creates a transformation of the source image this by scaling by
scale_xandscale_ythen translating byoffset_xandoffset_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. - public Pixbuf? scale_simple (int dest_width, int dest_height, InterpType interp_type)
Create a new Pixbuf containing a copy of this scaled to
dest_widthxdest_height. - public bool set_option (string key, string value)
Attaches a key/value pair as an option to a Pixbuf .
Inherited Members:
All known members inherited from class GLib.Object
All known members inherited from interface GLib.Icon
All known members inherited from interface GLib.LoadableIcon