:right-sidebar: True Creator =================================================================== .. currentmodule:: gi.repository.Gly .. versionadded:: 2.0 .. class:: Creator(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Image creator .. code-block:: c :dedent: #include GlyCreator *creator = gly_creator_new("image/jpeg", NULL); if (!creator) return; // Create frame with a single red pixel guint8 data[] = {255, 0, 0}; gsize length = sizeof(data); GBytes *texture = g_bytes_new(data, length); GlyNewFrame *new_frame = gly_creator_add_frame(creator, 1, 1, GLY_MEMORY_R8G8B8, texture, NULL); // Create JPEG GlyEncodedImage *encoded_image = gly_creator_create(creator, NULL); if (encoded_image) { GBytes *binary_data = gly_encoded_image_get_data(encoded_image); if (binary_data) { // Write image to file GFile *file = g_file_new_for_path("test.jpg"); g_file_replace_contents( file, g_bytes_get_data(binary_data, NULL), g_bytes_get_size(binary_data), NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL, NULL); } } Constructors ------------ .. rst-class:: interim-class .. class:: Creator :no-index: .. classmethod:: new(mime_type: str) -> ~gi.repository.Gly.Creator .. versionadded:: 2.0 :param mime_type: A null-terminated string. Methods ------- .. rst-class:: interim-class .. class:: Creator :no-index: .. method:: add_frame(width: int, height: int, memory_format: ~gi.repository.Gly.MemoryFormat, texture: ~gi.repository.GLib.Bytes) -> ~gi.repository.Gly.NewFrame .. versionadded:: 2.0 :param width: :param height: :param memory_format: :param texture: Texture data .. method:: add_frame_with_stride(width: int, height: int, stride: int, memory_format: ~gi.repository.Gly.MemoryFormat, texture: ~gi.repository.GLib.Bytes) -> ~gi.repository.Gly.NewFrame .. versionadded:: 2.0 :param width: :param height: ``stride`` :param stride: :param memory_format: :param texture: Texture data .. method:: add_metadata_key_value(key: str, value: str) -> bool Add metadata that are stored as key-value pairs. A prominent example are PNG's ``tEXt`` chunks. If an entry with ``key`` already exists, it will be replaced. .. versionadded:: 2.0 :param key: A null-terminated string. :param value: A null-terminated string. .. method:: create() -> ~gi.repository.Gly.EncodedImage | None .. versionadded:: 2.0 .. method:: create_async(self) -> ~gi.repository.Gly.EncodedImage :async: This is the `awaitable `_ version of :meth:`create_async`. .. versionadded:: 2.0 .. method:: create_async(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~collections.abc.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronous version of :obj:`~gi.repository.Creator.create`\. .. versionadded:: 2.0 :param cancellable: A :obj:`~gi.repository.Gio.Cancellable` to cancel the operation :param callback: A callback to call when the operation is complete :param user_data: Data to pass to ``callback`` .. method:: create_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gly.EncodedImage Finishes the :obj:`~gi.repository.Creator.create_async` call. .. versionadded:: 2.0 :param result: A ``GAsyncResult`` .. method:: set_encoding_compression(compression: int) -> bool .. versionadded:: 2.0 :param compression: Value between 0 and 100 .. method:: set_encoding_quality(quality: int) -> bool .. versionadded:: 2.0 :param quality: Value between 0 and 100 .. method:: set_sandbox_selector(sandbox_selector: ~gi.repository.Gly.SandboxSelector) -> bool Selects which sandbox mechanism should be used. The default without calling this function is :obj:`~gi.repository.Gly.SandboxSelector```.AUTO``\. .. versionadded:: 2.0 :param sandbox_selector: Method by which the sandbox mechanism is selected Properties ---------- .. rst-class:: interim-class .. class:: Creator :no-index: .. attribute:: props.mime_type :type: str The type of the None singleton. .. attribute:: props.sandbox_selector :type: ~gi.repository.Gly.SandboxSelector The type of the None singleton.