:right-sidebar: True PixbufLoader =================================================================== .. currentmodule:: gi.repository.GdkPixbuf .. class:: PixbufLoader(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: PixbufLoader(**properties) new() -> GdkPixbuf.PixbufLoader new_with_mime_type(mime_type:str) -> GdkPixbuf.PixbufLoader new_with_type(image_type:str) -> GdkPixbuf.PixbufLoader Constructors ------------ .. rst-class:: interim-class .. class:: PixbufLoader :no-index: .. classmethod:: new() -> ~gi.repository.GdkPixbuf.PixbufLoader Creates a new pixbuf loader object. .. classmethod:: new_with_mime_type(mime_type: str) -> ~gi.repository.GdkPixbuf.PixbufLoader 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 :func:`~gi.repository.GdkPixbuf.PixbufFormat.get_mime_types` on each of the :obj:`~gi.repository.GdkPixbuf.PixbufFormat` structs returned by :func:`~gi.repository.GdkPixbuf.Pixbuf.get_formats`. .. versionadded:: 2.4 :param mime_type: the mime type to be loaded .. classmethod:: new_with_type(image_type: str) -> ~gi.repository.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 :func:`~gi.repository.GdkPixbuf.PixbufFormat.get_name` on each of the :obj:`~gi.repository.GdkPixbuf.PixbufFormat` structs returned by :func:`~gi.repository.GdkPixbuf.Pixbuf.get_formats`. :param image_type: name of the image format to be loaded with the image Methods ------- .. rst-class:: interim-class .. class:: PixbufLoader :no-index: .. method:: close() -> bool Informs a pixbuf loader that no further writes with :func:`~gi.repository.GdkPixbuf.PixbufLoader.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. .. method:: get_animation() -> ~gi.repository.GdkPixbuf.PixbufAnimation | None Queries the :obj:`~gi.repository.GdkPixbuf.PixbufAnimation` that a pixbuf loader is currently creating. In general it only makes sense to call this function after the :obj:`~gi.repository.GdkPixbuf.PixbufLoader.signals.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``. .. method:: get_format() -> ~gi.repository.GdkPixbuf.PixbufFormat | None Obtains the available information about the format of the currently loading image file. .. versionadded:: 2.2 .. method:: get_pixbuf() -> ~gi.repository.GdkPixbuf.Pixbuf | None Queries the :obj:`~gi.repository.GdkPixbuf.Pixbuf` that a pixbuf loader is currently creating. In general it only makes sense to call this function after the :obj:`~gi.repository.GdkPixbuf.PixbufLoader.signals.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 :func:`~gi.repository.GdkPixbuf.PixbufLoader.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 :func:`~gi.repository.GdkPixbuf.PixbufAnimation.get_static_image`). .. method:: set_size(width: int, height: int) -> None 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 :func:`~gi.repository.GdkPixbuf.PixbufLoader.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. .. versionadded:: 2.2 :param width: The desired width of the image being loaded. :param height: The desired height of the image being loaded. .. method:: write(buf: ~typing.Sequence[int]) -> bool Parses the next ``count`` bytes in the given image buffer. :param buf: Pointer to image data. .. method:: write_bytes(buffer: ~gi.repository.GLib.Bytes) -> bool Parses the next contents of the given image buffer. .. versionadded:: 2.30 :param buffer: The image data as a ``GBytes`` buffer. Signals ------- .. rst-class:: interim-class .. class:: PixbufLoader.signals :no-index: .. method:: area_prepared() -> None This signal is emitted when the pixbuf loader has allocated the pixbuf in the desired size. After this signal is emitted, applications can call :func:`~gi.repository.GdkPixbuf.PixbufLoader.get_pixbuf` to fetch the partially-loaded pixbuf. .. method:: area_updated(x: int, y: int, width: int, height: int) -> None 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. :param x: X offset of upper-left corner of the updated area. :param y: Y offset of upper-left corner of the updated area. :param width: Width of updated area. :param height: Height of updated area. .. method:: closed() -> None This signal is emitted when :func:`~gi.repository.GdkPixbuf.PixbufLoader.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. .. method:: size_prepared(width: int, height: int) -> None 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 :func:`~gi.repository.GdkPixbuf.PixbufLoader.set_size` in response to this signal to set the desired size to which the image should be scaled. :param width: the original width of the image :param height: the original height of the image Virtual Methods --------------- .. rst-class:: interim-class .. class:: PixbufLoader :no-index: .. method:: do_area_prepared() -> None .. method:: do_area_updated(x: int, y: int, width: int, height: int) -> None :param x: :param y: :param width: :param height: .. method:: do_closed() -> None .. method:: do_size_prepared(width: int, height: int) -> None :param width: :param height: Fields ------ .. rst-class:: interim-class .. class:: PixbufLoader :no-index: .. attribute:: parent_instance .. attribute:: priv