:right-sidebar: True Pixdata =================================================================== .. currentmodule:: gi.repository.GdkPixdata .. deprecated:: 2.32 ``GdkPixdata`` should not be used any more. ``GResource`` should be used to save the original compressed images inside the program's binary .. class:: Pixdata(*args, **kwargs) :no-contents-entry: A pixel buffer suitable for serialization and streaming. Using ``GdkPixdata``\, images can be compiled into an application, making it unnecessary to refer to external image files at runtime. ``GdkPixbuf`` includes a utility named ``gdk-pixbuf-csource``\, which can be used to convert image files into ``GdkPixdata`` structures suitable for inclusion in C sources. To convert the ``GdkPixdata`` structures back into a ``GdkPixbuf``\, use ``gdk_pixbuf_from_pixdata()``\. Methods ------- .. rst-class:: interim-class .. class:: Pixdata :no-index: .. method:: deserialize(stream: list[int]) -> bool Deserializes (reconstruct) a :obj:`~gi.repository.GdkPixdata.Pixdata` structure from a byte stream. The byte stream consists of a straightforward writeout of the ``GdkPixdata`` fields in network byte order, plus the ``pixel_data`` bytes the structure points to. The ``pixdata`` contents are reconstructed byte by byte and are checked for validity. This function may fail with ``GDK_PIXBUF_ERROR_CORRUPT_IMAGE`` or ``GDK_PIXBUF_ERROR_UNKNOWN_TYPE``\. .. deprecated:: 2.32 Use ``GResource`` instead. :param stream: stream of bytes containing a serialized :obj:`~gi.repository.GdkPixdata.Pixdata` structure. .. method:: serialize() -> list[int] Serializes a :obj:`~gi.repository.GdkPixdata.Pixdata` structure into a byte stream. The byte stream consists of a straightforward writeout of the :obj:`~gi.repository.GdkPixdata.Pixdata` fields in network byte order, plus the ``pixel_data`` bytes the structure points to. .. deprecated:: 2.32 Use :obj:`~gi.repository.Gio.Resource` instead. .. method:: to_csource(name: str, dump_type: ~gi.repository.GdkPixdata.PixdataDumpType) -> ~gi.repository.GLib.String Generates C source code suitable for compiling images directly into programs. GdkPixbuf ships with a program called ``gdk-pixbuf-csource``\, which offers a command line interface to this function. .. deprecated:: 2.32 Use :obj:`~gi.repository.Gio.Resource` instead. :param name: used for naming generated data structures or macros :param dump_type: the kind of C source to be generated Fields ------ .. rst-class:: interim-class .. class:: Pixdata :no-index: .. attribute:: height Height of the image in pixels .. attribute:: length Less than 1 to disable length checks, otherwise ``GDK_PIXDATA_HEADER_LENGTH`` plus the length of ``pixel_data`` .. attribute:: magic Magic number. A valid ``GdkPixdata`` structure must have ``GDK_PIXBUF_MAGIC_NUMBER`` here .. attribute:: pixdata_type Information about colorspace, sample width and encoding, in a ``GdkPixdataType`` .. attribute:: pixel_data ``width`` x ``height`` pixels, encoded according to ``pixdata_type`` and ``rowstride`` .. attribute:: rowstride Distance in bytes between rows .. attribute:: width Width of the image in pixels