PixbufLoader

open class PixbufLoader : GLibObject.Object, PixbufLoaderProtocol

Incremental image loader.

GdkPixbufLoader provides a way for applications to drive the process of loading an image, by letting them send the image data directly to the loader instead of having the loader read the data from a file. Applications can use this functionality instead of gdk_pixbuf_new_from_file() or gdk_pixbuf_animation_new_from_file() when they need to parse image data in small chunks. For example, it should be used when reading an image from a (potentially) slow network connection, or when loading an extremely large file.

To use GdkPixbufLoader to load an image, create a new instance, and call [methodGdkPixbuf.PixbufLoader.write] to send the data to it. When done, [methodGdkPixbuf.PixbufLoader.close] should be called to end the stream and finalize everything.

The loader will emit three important signals throughout the process:

  • [signalGdkPixbuf.PixbufLoader::size-prepared] will be emitted as soon as the image has enough information to determine the size of the image to be used. If you want to scale the image while loading it, you can call [methodGdkPixbuf.PixbufLoader.set_size] in response to this signal.
  • [signalGdkPixbuf.PixbufLoader::area-prepared] will be emitted as soon as the pixbuf of the desired has been allocated. You can obtain the GdkPixbuf instance by calling [methodGdkPixbuf.PixbufLoader.get_pixbuf]. If you want to use it, simply acquire a reference to it. You can also call gdk_pixbuf_loader_get_pixbuf() later to get the same pixbuf.
  • [signalGdkPixbuf.PixbufLoader::area-updated] will be emitted every time a region is updated. This way you can update a partially completed image. Note that you do not know anything about the completeness of an image from the updated area. For example, in an interlaced image you will need to make several passes before the image is done loading.

Loading an animation

Loading an animation is almost as easy as loading an image. Once the first [signalGdkPixbuf.PixbufLoader::area-prepared] signal has been emitted, you can call [methodGdkPixbuf.PixbufLoader.get_animation] to get the [classGdkPixbuf.PixbufAnimation] instance, and then call and [methodGdkPixbuf.PixbufAnimation.get_iter] to get a [classGdkPixbuf.PixbufAnimationIter] to retrieve the pixbuf for the desired time stamp.

The PixbufLoader type acts as a reference-counted owner of an underlying GdkPixbufLoader instance. It provides the methods that can operate on this data type through PixbufLoaderProtocol conformance. Use PixbufLoader as a strong reference or owner of a GdkPixbufLoader instance.

  • Designated initialiser from the underlying `C` data type.
    

    This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PixbufLoader instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafeMutablePointer<GdkPixbufLoader>)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PixbufLoader instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafePointer<GdkPixbufLoader>)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a non-mutating gpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PixbufLoader instance.

    Declaration

    Swift

    @inlinable
    override public init!(gpointer op: gpointer?)

    Parameters

    op

    gpointer to the underlying object

  • Optional initialiser from a non-mutating gconstpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PixbufLoader instance.

    Declaration

    Swift

    @inlinable
    override public init!(gconstpointer op: gconstpointer?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PixbufLoader instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafePointer<GdkPixbufLoader>?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PixbufLoader instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafeMutablePointer<GdkPixbufLoader>?)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from the underlying C data type. Will retain GdkPixbufLoader. i.e., ownership is transferred to the PixbufLoader instance.

    Declaration

    Swift

    @inlinable
    public init(retaining op: UnsafeMutablePointer<GdkPixbufLoader>)

    Parameters

    op

    pointer to the underlying object

  • Reference intialiser for a related type that implements PixbufLoaderProtocol Will retain GdkPixbufLoader.

    Declaration

    Swift

    @inlinable
    public init<T>(pixbufLoader other: T) where T : PixbufLoaderProtocol

    Parameters

    other

    an instance of a related type that implements PixbufLoaderProtocol

  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PixbufLoaderProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(cPointer p: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PixbufLoaderProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PixbufLoaderProtocol.

    Declaration

    Swift

    @inlinable
    override public init(raw p: UnsafeRawPointer)

    Parameters

    p

    raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PixbufLoaderProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingRaw raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PixbufLoaderProtocol.

    Declaration

    Swift

    @inlinable
    public required init(raw p: UnsafeMutableRawPointer)

    Parameters

    p

    mutable raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PixbufLoaderProtocol.

    Declaration

    Swift

    @inlinable
    required public init(retainingRaw raw: UnsafeMutableRawPointer)

    Parameters

    raw

    mutable raw pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PixbufLoaderProtocol.

    Declaration

    Swift

    @inlinable
    override public init(opaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PixbufLoaderProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingOpaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Creates a new pixbuf loader object.

    Declaration

    Swift

    @inlinable
    public init()
  • 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.

    This function is 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 GdkPixbufFormat structs returned by gdk_pixbuf_get_formats().

    Declaration

    Swift

    @inlinable
    public init(mimeType: UnsafePointer<CChar>!) throws
  • 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.

    This function is 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 GdkPixbufFormat structs returned by gdk_pixbuf_get_formats().

    Declaration

    Swift

    @inlinable
    public init(type imageType: UnsafePointer<CChar>!) throws
  • 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.

    This function is 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 GdkPixbufFormat structs returned by gdk_pixbuf_get_formats().

    Declaration

    Swift

    @inlinable
    public static func newWith(mimeType: UnsafePointer<CChar>!) throws -> 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.

    This function is 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 GdkPixbufFormat structs returned by gdk_pixbuf_get_formats().

    Declaration

    Swift

    @inlinable
    public static func newWith(type imageType: UnsafePointer<CChar>!) throws -> GdkPixBuf.PixbufLoader!