Creator#

Added in version 2.0.

class Creator(**properties: Any)#

Superclasses: Object

Image creator

#include <glycin.h>

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#

class Creator
classmethod new(mime_type: str) Creator#

Added in version 2.0.

Parameters:

mime_type – A null-terminated string.

Methods#

class Creator
add_frame(width: int, height: int, memory_format: MemoryFormat, texture: Bytes) NewFrame#

Added in version 2.0.

Parameters:
  • width

  • height

  • memory_format

  • texture – Texture data

add_frame_with_stride(width: int, height: int, stride: int, memory_format: MemoryFormat, texture: Bytes) NewFrame#

Added in version 2.0.

Parameters:
  • width

  • heightstride

  • stride

  • memory_format

  • texture – Texture data

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.

Added in version 2.0.

Parameters:
  • key – A null-terminated string.

  • value – A null-terminated string.

create() EncodedImage | None#

Added in version 2.0.

async create_async(self) EncodedImage#

This is the awaitable version of create_async().

Added in version 2.0.

create_async(cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#

Asynchronous version of create.

Added in version 2.0.

Parameters:
  • cancellable – A Cancellable to cancel the operation

  • callback – A callback to call when the operation is complete

  • user_data – Data to pass to callback

create_finish(result: AsyncResult) EncodedImage#

Finishes the create_async call.

Added in version 2.0.

Parameters:

result – A GAsyncResult

set_encoding_compression(compression: int) bool#

Added in version 2.0.

Parameters:

compression – Value between 0 and 100

set_encoding_quality(quality: int) bool#

Added in version 2.0.

Parameters:

quality – Value between 0 and 100

set_sandbox_selector(sandbox_selector: SandboxSelector) bool#

Selects which sandbox mechanism should be used. The default without calling this function is SandboxSelector``.AUTO``.

Added in version 2.0.

Parameters:

sandbox_selector – Method by which the sandbox mechanism is selected

Properties#

class Creator
props.mime_type: str#

The type of the None singleton.

props.sandbox_selector: SandboxSelector#

The type of the None singleton.