gdk_pixbuf::prelude

Trait PixbufLoaderExt

Source
pub trait PixbufLoaderExt: IsA<PixbufLoader> + '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

Trait containing all PixbufLoader methods.

§Implementors

PixbufLoader

Provided Methods§

Source

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

Source

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

Source

fn format(&self) -> Option<PixbufFormat>

Obtains the available information about the format of the currently loading image file.

§Returns

A #GdkPixbufFormat

Source

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

Source

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.

Source

fn write(&self, buf: &[u8]) -> Result<(), Error>

Parses the next count bytes in the given image buffer.

§buf

Pointer to image data.

§Returns

TRUE if the write was successful, or FALSE if the loader cannot parse the buffer

Source

fn write_bytes(&self, buffer: &Bytes) -> Result<(), Error>

Parses the next contents of the given image buffer.

§buffer

The image data as a GBytes buffer.

§Returns

TRUE if the write was successful, or FALSE if the loader cannot parse the buffer

Source

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.

Source

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.

Source

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.

Source

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§