PixbufLoaderRef
public struct PixbufLoaderRef : PixbufLoaderProtocol, GWeakCapturing
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:
- [signal
GdkPixbuf.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. - [signal
GdkPixbuf.PixbufLoader::area-prepared
] will be emitted as soon as the pixbuf of the desired has been allocated. You can obtain theGdkPixbuf
instance by calling [methodGdkPixbuf.PixbufLoader.get_pixbuf
]. If you want to use it, simply acquire a reference to it. You can also callgdk_pixbuf_loader_get_pixbuf()
later to get the same pixbuf. - [signal
GdkPixbuf.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 PixbufLoaderRef
type acts as a lightweight Swift reference to an underlying GdkPixbufLoader
instance.
It exposes methods that can operate on this data type through PixbufLoaderProtocol
conformance.
Use PixbufLoaderRef
only as an unowned
reference to an existing GdkPixbufLoader
instance.
-
Untyped pointer to the underlying `GdkPixbufLoader` instance.
For type-safe access, use the generated, typed pointer
pixbuf_loader_ptr
property instead.Declaration
Swift
public let ptr: UnsafeMutableRawPointer!
-
Designated initialiser from the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafeMutablePointer<GdkPixbufLoader>)
-
Designated initialiser from a constant pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafePointer<GdkPixbufLoader>)
-
Conditional initialiser from an optional pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafeMutablePointer<GdkPixbufLoader>?)
-
Conditional initialiser from an optional, non-mutable pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafePointer<GdkPixbufLoader>?)
-
Conditional initialiser from an optional
gpointer
Declaration
Swift
@inlinable init!(gpointer g: gpointer?)
-
Conditional initialiser from an optional, non-mutable
gconstpointer
Declaration
Swift
@inlinable init!(gconstpointer g: gconstpointer?)
-
Reference intialiser for a related type that implements
PixbufLoaderProtocol
Declaration
Swift
@inlinable init<T>(_ other: T) where T : PixbufLoaderProtocol
-
This factory is syntactic sugar for setting weak pointers wrapped in
GWeak<T>
Declaration
Swift
@inlinable static func unowned<T>(_ other: T) -> PixbufLoaderRef where T : PixbufLoaderProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PixbufLoaderProtocol
.Declaration
Swift
@inlinable init<T>(cPointer: UnsafeMutablePointer<T>)
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PixbufLoaderProtocol
.Declaration
Swift
@inlinable init<T>(constPointer: UnsafePointer<T>)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PixbufLoaderProtocol
.Declaration
Swift
@inlinable init(mutating 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 init(raw: UnsafeMutableRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
PixbufLoaderProtocol
.Declaration
Swift
@inlinable init(opaquePointer: OpaquePointer)
-
Creates a new pixbuf loader object.
Declaration
Swift
@inlinable 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 theGdkPixbufFormat
structs returned bygdk_pixbuf_get_formats()
.Declaration
Swift
@inlinable 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 theGdkPixbufFormat
structs returned bygdk_pixbuf_get_formats()
.Declaration
Swift
@inlinable 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 theGdkPixbufFormat
structs returned bygdk_pixbuf_get_formats()
.Declaration
Swift
@inlinable static func newWith(mimeType: UnsafePointer<CChar>!) throws -> GdkPixBuf.PixbufLoaderRef!
-
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 theGdkPixbufFormat
structs returned bygdk_pixbuf_get_formats()
.Declaration
Swift
@inlinable static func newWith(type imageType: UnsafePointer<CChar>!) throws -> GdkPixBuf.PixbufLoaderRef!