Class: GdkPixbuf::PixbufLoader

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#animationGdkPixbuf::PixbufAnimation

Queries the Gdk::PixbufAnimation that a pixbuf loader is currently creating. In general it only makes sense to call this function after the “area-prepared” signal has been emitted by the loader. If the loader doesn’t have enough bytes yet (hasn’t emitted the “area-prepared” signal) this function will return nil. not enough data has been read to determine the information.

Returns:

#closeTrueClass

Informs a pixbuf loader that no further writes with gdk_pixbuf_loader_write() will occur, so that it can free its internal loading structures. Also, tries to parse any data that hasn’t yet been parsed; if the remaining data is partial or corrupt, an error will be returned. If false is returned, error will be set to an error from the #GDK_PIXBUF_ERROR or #G_FILE_ERROR domains. If you’re just cancelling a load rather than expecting it to be finished, passing nil for error to ignore it is reasonable.

Remember that this does not unref the loader, so if you plan not to use it anymore, please g_object_unref() it.

Returns:

  • (TrueClass)

    true if all image data written so far was successfully passed out via the update_area signal

#formatGdkPixbuf::PixbufFormat

Obtains the available information about the format of the currently loading image file. nil. The return value is owned by GdkPixbuf and should not be freed.

Returns:

  • (GdkPixbuf::PixbufFormat)

    A Gdk::PixbufFormat or

#newGdkPixbuf::PixbufLoader

Creates a new pixbuf loader object.

Returns:

#new_with_mime_type(mime_type) ⇒ GdkPixbuf::PixbufLoader

Creates a new pixbuf loader object that always attempts to parse image data as if it were an image of mime type mime_type, instead of identifying the type automatically. Useful if you want an error if the image isn’t the expected mime type, for loading image formats that can’t be reliably identified by looking at the data, or if the user manually forces a specific mime type.

The list of supported mime types depends on what image loaders are installed, but typically “image/png”, “image/jpeg”, “image/gif”, “image/tiff” and “image/x-xpixmap” are among the supported mime types. To obtain the full list of supported mime types, call gdk_pixbuf_format_get_mime_types() on each of the Gdk::PixbufFormat structs returned by gdk_pixbuf_get_formats().

Parameters:

  • mime_type (String)

    the mime type to be loaded

Returns:

#new_with_type(image_type) ⇒ GdkPixbuf::PixbufLoader

Creates a new pixbuf loader object that always attempts to parse image data as if it were an image of type image_type, instead of identifying the type automatically. Useful if you want an error if the image isn’t the expected type, for loading image formats that can’t be reliably identified by looking at the data, or if the user manually forces a specific type.

The list of supported image formats depends on what image loaders are installed, but typically “png”, “jpeg”, “gif”, “tiff” and “xpm” are among the supported formats. To obtain the full list of supported image formats, call gdk_pixbuf_format_get_name() on each of the Gdk::PixbufFormat structs returned by gdk_pixbuf_get_formats().

Parameters:

  • image_type (String)

    name of the image format to be loaded with the image

Returns:

#pixbufGdkPixbuf::Pixbuf

Queries the Gdk::Pixbuf that a pixbuf loader is currently creating. In general it only makes sense to call this function after the “area-prepared” signal has been emitted by the loader; this means that enough data has been read to know the size of the image that will be allocated. If the loader has not received enough data via gdk_pixbuf_loader_write(), then this function returns nil. The returned pixbuf will be the same in all future calls to the loader, so simply calling g_object_ref() should be sufficient to continue using it. Additionally, if the loader is an animation, it will return the “static image” of the animation (see gdk_pixbuf_animation_get_static_image()). enough data has been read to determine how to create the image buffer.

Returns:

#set_size(width, height) ⇒ nil

Causes the image to be scaled while it is loaded. The desired image size can be determined relative to the original size of the image by calling gdk_pixbuf_loader_set_size() from a signal handler for the ::size-prepared signal.

Attempts to set the desired image size are ignored after the emission of the ::size-prepared signal.

Parameters:

  • width (Integer)

    The desired width of the image being loaded.

  • height (Integer)

    The desired height of the image being loaded.

Returns:

  • (nil)

#write(buf, count) ⇒ TrueClass

This will cause a pixbuf loader to parse the next count bytes of an image. It will return true if the data was loaded successfully, and false if an error occurred. In the latter case, the loader will be closed, and will not accept further writes. If false is returned, error will be set to an error from the #GDK_PIXBUF_ERROR or #G_FILE_ERROR domains. cannot parse the buffer.

Parameters:

  • buf (Array<Integer>)

    Pointer to image data.

  • count (Integer)

    Length of the buf buffer in bytes.

Returns:

  • (TrueClass)

    true if the write was successful, or false if the loader

#write_bytes(buffer) ⇒ TrueClass

This will cause a pixbuf loader to parse a buffer inside a #GBytes for an image. It will return true if the data was loaded successfully, and false if an error occurred. In the latter case, the loader will be closed, and will not accept further writes. If false is returned, error will be set to an error from the #GDK_PIXBUF_ERROR or #G_FILE_ERROR domains.

See also: gdk_pixbuf_loader_write() cannot parse the buffer.

Parameters:

  • buffer (GLib::Bytes)

    The image data as a #GBytes

Returns:

  • (TrueClass)

    true if the write was successful, or false if the loader