Trait gdk_pixbuf::prelude::PixbufLoaderExt
source · pub trait PixbufLoaderExt: IsA<PixbufLoader> + Sealed + 'static {
// Provided methods
fn close(&self) -> Result<(), Error> { ... }
fn animation(&self) -> Option<PixbufAnimation> { ... }
fn format(&self) -> Option<PixbufFormat> { ... }
fn pixbuf(&self) -> Option<Pixbuf> { ... }
fn set_size(&self, width: i32, height: i32) { ... }
fn write(&self, buf: &[u8]) -> Result<(), Error> { ... }
fn write_bytes(&self, buffer: &Bytes) -> Result<(), Error> { ... }
fn connect_area_prepared<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_area_updated<F: Fn(&Self, i32, i32, i32, i32) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
fn connect_size_prepared<F: Fn(&Self, i32, i32) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
}
Expand description
Provided Methods§
sourcefn close(&self) -> Result<(), Error>
fn close(&self) -> Result<(), Error>
Informs a pixbuf loader that no further writes with gdk_pixbuf_loader_write() will occur, so that it can free its internal loading structures.
This function 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 NULL
for error
to ignore it is reasonable.
Remember that this function does not release a reference on the loader, so you will need to explicitly release any reference you hold.
Returns
TRUE
if all image data written so far was successfully
passed out via the update_area signal
sourcefn animation(&self) -> Option<PixbufAnimation>
fn animation(&self) -> Option<PixbufAnimation>
Queries the #GdkPixbufAnimation 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, and hasn’t emitted the area-prepared
signal, this function will return NULL
.
Returns
The animation that the loader is currently loading
sourcefn format(&self) -> Option<PixbufFormat>
fn format(&self) -> Option<PixbufFormat>
Obtains the available information about the format of the currently loading image file.
Returns
A #GdkPixbufFormat
sourcefn pixbuf(&self) -> Option<Pixbuf>
fn pixbuf(&self) -> Option<Pixbuf>
Queries the #GdkPixbuf 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 NULL
.
The returned pixbuf will be the same in all future calls to the loader, so if you want to keep using it, you should acquire a reference to it.
Additionally, if the loader is an animation, it will return the “static image” of the animation (see gdk_pixbuf_animation_get_static_image()).
Returns
The pixbuf that the loader is creating
sourcefn set_size(&self, width: i32, height: i32)
fn set_size(&self, width: i32, height: i32)
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.
width
The desired width of the image being loaded.
height
The desired height of the image being loaded.
sourcefn connect_area_prepared<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_area_prepared<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
This signal is emitted when the pixbuf loader has allocated the pixbuf in the desired size.
After this signal is emitted, applications can call gdk_pixbuf_loader_get_pixbuf() to fetch the partially-loaded pixbuf.
sourcefn connect_area_updated<F: Fn(&Self, i32, i32, i32, i32) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_area_updated<F: Fn(&Self, i32, i32, i32, i32) + 'static>( &self, f: F ) -> SignalHandlerId
This signal is emitted when a significant area of the image being loaded has been updated.
Normally it means that a complete scanline has been read in, but it could be a different area as well.
Applications can use this signal to know when to repaint areas of an image that is being loaded.
x
X offset of upper-left corner of the updated area.
y
Y offset of upper-left corner of the updated area.
width
Width of updated area.
height
Height of updated area.
sourcefn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
This signal is emitted when gdk_pixbuf_loader_close() is called.
It can be used by different parts of an application to receive notification when an image loader is closed by the code that drives it.
sourcefn connect_size_prepared<F: Fn(&Self, i32, i32) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_size_prepared<F: Fn(&Self, i32, i32) + 'static>( &self, f: F ) -> SignalHandlerId
This signal is emitted when the pixbuf loader has been fed the initial amount of data that is required to figure out the size of the image that it will create.
Applications can call gdk_pixbuf_loader_set_size() in response to this signal to set the desired size to which the image should be scaled.
width
the original width of the image
height
the original height of the image