Class: GdkPixbuf::PixbufLoader
- Inherits:
-
Object
- Object
- GdkPixbuf::PixbufLoader
- Defined in:
- lib/gdk_pixbuf2/pixbuf-loader.rb
Instance Method Summary collapse
-
#animation ⇒ GdkPixbuf::PixbufAnimation
Queries the Gdk::PixbufAnimation that a pixbuf loader is currently creating.
-
#close ⇒ Boolean
Informs a pixbuf loader that no further writes with gdk_pixbuf_loader_write() will occur, so that it can free its internal loading structures.
-
#format ⇒ GdkPixbuf::PixbufFormat
Obtains the available information about the format of the currently loading image file.
-
#initialize(image_type) ⇒ GdkPixbuf::PixbufLoader
constructor
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.
- #last_write(data) ⇒ Object
-
#pixbuf ⇒ GdkPixbuf::Pixbuf
Queries the Gdk::Pixbuf that a pixbuf loader is currently creating.
-
#set_size(width, height) ⇒ nil
Causes the image to be scaled while it is loaded.
-
#write(buf, count) ⇒ Boolean
Parses the next
countbytes in the given image buffer. -
#write_bytes(buffer) ⇒ Boolean
Parses the next contents of the given image buffer.
Constructor Details
#initialize(image_type) ⇒ 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 Gdk::PixbufFormat structs returned by gdk_pixbuf_get_formats().
Instance Method Details
#animation ⇒ GdkPixbuf::PixbufAnimation
Queries the Gdk::PixbufAnimation that a pixbuf loader is currently creating.
In general it only makes sense to call this function after the [signalGdkPixbuf.PixbufLoader::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.
#close ⇒ Boolean
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.
#format ⇒ GdkPixbuf::PixbufFormat
Obtains the available information about the format of the currently loading image file.
#last_write(data) ⇒ Object
19 20 21 22 |
# File 'lib/gdk_pixbuf2/pixbuf-loader.rb', line 19 def last_write(data) write(data) close end |
#pixbuf ⇒ GdkPixbuf::Pixbuf
Queries the Gdk::Pixbuf that a pixbuf loader is currently creating.
In general it only makes sense to call this function after the [signalGdkPixbuf.PixbufLoader::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()).
#set_size(width, height) ⇒ nil
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.
#write(buf, count) ⇒ Boolean
Parses the next count bytes in the given image buffer.
#write_bytes(buffer) ⇒ Boolean
Parses the next contents of the given image buffer.