Trait gdk_pixbuf::prelude::PixbufLoaderExt [−][src]
pub trait PixbufLoaderExt: 'static {
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
Required methods
Informs a pixbuf loader that no further writes with
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 None 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
true if all image data written so far was successfully
passed out via the update_area signal
fn animation(&self) -> Option<PixbufAnimation>
fn animation(&self) -> Option<PixbufAnimation>Queries the 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 None.
Returns
The PixbufAnimation that the loader is loading, or None if
not enough data has been read to determine the information.
fn format(&self) -> Option<PixbufFormat>
fn format(&self) -> Option<PixbufFormat>Obtains the available information about the format of the currently loading image file.
Returns
A PixbufFormat or
None. The return value is owned by GdkPixbuf and should not be
freed.
Queries the 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
write(), then this function returns None. 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 PixbufAnimationExt::static_image()).
Returns
The Pixbuf that the loader is creating, or None if not
enough data has been read to determine how to create the image buffer.
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 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.
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.
buf
Pointer to image data.
Returns
true if the write was successful, or false if the loader
cannot parse the buffer.
This will cause a pixbuf loader to parse a buffer inside a glib::Bytes
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: write()
buffer
The image data as a glib::Bytes
Returns
true if the write was successful, or false if the loader
cannot parse the buffer.
fn connect_area_prepared<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_area_prepared<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerIdThis signal is emitted when the pixbuf loader has allocated the
pixbuf in the desired size. After this signal is emitted,
applications can call pixbuf() to fetch
the partially-loaded pixbuf.
fn 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
) -> SignalHandlerIdThis 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.
fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerIdThis signal is emitted when 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.
fn 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
) -> SignalHandlerIdThis 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
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