See ITU-T H.273
Image creator
```c
#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);
// 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);
}
}
```
a new [class@Creator]
A null-terminated string.
a new [class@NewFrame]
Texture data
a new [class@NewFrame]
@stride
Texture data
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.
`TRUE` if format supports key-value storage.
A null-terminated string.
A null-terminated string.
The encoded image.
Asynchronous version of [method@Creator.create].
A [class@Gio.Cancellable] to cancel the operation
A callback to call when the operation is complete
Data to pass to @callback
Finishes the [method@Creator.create_async] call.
Encoded image.
A `GAsyncResult`
`TRUE` if the format supports compression setting.
Value between 0 and 100
`TRUE` if format supports a quality setting.
Value between 0 and 100
Selects which sandbox mechanism should be used. The default without calling this function is [enum@SandboxSelector]`.AUTO`.
Method by which the sandbox mechanism is selected
Encoded image
The encoded image data
A frame of an image often being the complete image.
Image data arranged according to [method@Frame.get_memory_format]
Image data
Returns the CICP (coding-independent code point) for the frames texture.
This value is `NULL` if no CICP is used.
CICP
Duration to show frame for animations.
If the value is zero, the image is not animated.
Duration in microseconds.
Height for image data in pixels
Height in pixels
Format of the image data in [method@Gly.Frame.get_buf_bytes]
Format of image data
Width of a row for image data in bytes
Row stride in bytes
Width for image data in pixels
Width in pixels
Defines which parts of an image to load.
::: warning
Loaders can and frequently will ignore instructions set in
`GlyFrameRequest`. The reason is that for most loaders
many instructions don't have a meaningful interpretation.
Creates a new frame request.
a new [class@FrameRequest]
Controls if first frame is returned after last frame
By default, this option is set to `TRUE`, returning the first frame, if
the previously requested frame was the last frame.
Set maximum dimensions for the frame. The texture will be scaled
to be within the maximum dimensions while keeping its aspect ratio.
This option is especially useful to SVGs which will be rendered at
the respective size.
::: warning
Most loaders will ignore this option. Currently, only the SVG
loader is known to obay it.
Maximum width
Maximum height
Image handle containing metadata and allowing frame requests.
See [method@Image.get_width]
height
Get metadata that are stored as key-value pairs.
A prominent example are PNG's `tEXt` and `zTXt` chunks.
::: note
In contrast to gdk-pixbuf's *option* feature, the
keys do not carry prefixes like `tEXt::` or `zTXt::`.
The UTF-8 encoded value associated with `key`.
A null-terminated string.
Get the list of available keys for [method@Image.get_metadata_key_value].
List of existing keys.
Returns detected MIME type of the file
MIME type
Loaded frame.
Asynchronous version of [method@Image.get_specific_frame].
A [class@Gio.Cancellable] to cancel the operation
A callback to call when the operation is complete
Data to pass to @callback
Finishes the [method@Image.get_specific_frame_async] call.
Loaded frame.
a `GAsyncResult`
Get the image orientation
The image orientation is given in Exif format. The function is
guaranteed to only return values from 1 to 8.
If [method@Loader.set_apply_transformations] is set to `FALSE`,
the orientation has to be corrected manually to dispaly the image
correctly.
Early width information.
This information is often correct. However, it should only be used for
an early rendering estimates. For everything else, the specific frame
information should be used. See [method@Frame.get_width].
Width
Synchronously loads texture and information of the next frame.
For single still images, this can only be called once.
For animated images, this function will loop to the first frame, when the last frame is reached.
a new [class@Frame] on success, or `NULL` with @error filled in
Asynchronous version of [method@Image.next_frame].
A [class@Gio.Cancellable] to cancel the operation
A callback to call when the operation is complete
Data to pass to @callback
Finishes the [method@Image.next_frame_async] call.
Loaded frame.
a `GAsyncResult`
[class@Loader] prepares loading an image.
The following example shows how to obtain a `Gdk.Texture`. It uses
[GlyGtk4](https://gnome.pages.gitlab.gnome.org/glycin/libglycin-gtk4)
for this.
```c
#include <glycin-gtk4.h>
file = g_file_new_for_path ("test.png");
loader = gly_loader_new (file);
image = gly_loader_load (loader, NULL);
if (image)
{
frame = gly_image_next_frame (image, NULL);
if (frame)
{
texture = gly_gtk_frame_get_texture (frame);
g_print ("Image height: %d\n", gdk_texture_get_height (texture));
image_widget = gtk_image_new_from_paintable (GDK_PAINTABLE (texture));
}
}
```
Creates a new loader for a file.
a new [class@Loader]
A file from which to load the image data
Creates a new loader for bytes.
a new [class@Loader]
Data from which to load the image
Creates a new loader for a stream.
a new [class@Loader]
A stream from which to load the image data
Returns a list of MIME types currently supported for loading images.
This list is generated from the config on first use of a loader or
call of this function and cached afterwards. Hence, the first call
can be blocking.
List of supported MIME types
Async variant of [func@Loader.get_mime_types]
user data to pass to @callback
Finishes the [func@Loader.get_mime_types_async] call.
Mime types.
A `GAsyncResult`
Synchronously loads an image and returns an [class@Image] when successful.
a new [class@Image] on success, or `NULL` with @error filled in
Asynchronous version of [method@Loader.load].
A [class@Gio.Cancellable] to cancel the operation
A callback to call when the operation is complete
Data to pass to @callback
Finishes the [method@Loader.load_async] call.
Loaded image.
A `GAsyncResult`
Sets which memory formats can be returned by the loader
If the memory format doesn't match one of the selected formats, the
format will be transformed into the best suitable format selected.
Accepted memory formats
Set whether to apply transformations to texture
When enabled, transformations like image orientation are applied to the
texture data.
This option is enabled by default.
Selects which sandbox mechanism should be used. The default without calling this function is [enum@SandboxSelector]`.AUTO`.
Method by which the sandbox mechanism is selected
Errors that can appear while loading images.
Generic type for all other errors.
Unknown image format.
Reached last frame in an animation with [method@FrameRequest.set_loop_animation] to `FALSE`.
Error quark for [error@GlyLoaderError]
The error domain
Memory format
8-bit RGRA premultiplied
8-bit ARGB premultiplied
8-bit RGBA premultiplied
8-bit RGBA
8-bit AGBR
8-bit RGBA
8-bit ABGR
8-bit RGB
8-bit BGR
16-bit RGB
16-bit RGBA premultiplied
16-bit RGBA
16-bit float RGB
16-bit float RGBA
32-bit float RGB
32-bit float RGBA premultiplied
16-bit float RGBA
8-bit gray with alpha premultiplied
8-bit gray with alpha
8-bit gray
16-bit gray with alpha premultiplied
16-bit gray with alpha
16-bit gray
Whether a memory format has an alpha channel
Returns `TRUE` if the memory format has an alpha channel
Whether a memory format has an alpha channel and the color values are
premultiplied with the alpha value
Returns `TRUE` if color channels are premultiplied
Memory format selection
8-bit RGRA premultiplied
8-bit ARGB premultiplied
8-bit RGBA premultiplied
8-bit RGBA
8-bit AGBR
8-bit RGBA
8-bit ABGR
8-bit RGB
8-bit BGR
16-bit RGB
16-bit RGBA premultiplied
16-bit RGBA
16-bit float RGB
16-bit float RGBA
32-bit float RGB
32-bit float RGBA premultiplied
16-bit float RGBA
8-bit gray with alpha premultiplied
8-bit gray with alpha
8-bit gray
16-bit gray with alpha premultiplied
16-bit gray with alpha
16-bit gray
New frame
`TRUE` if format supports ICC color profiles.
ICC profile
Sandbox mechanisms
::: warning
Using @GLY_SANDBOX_SELECTOR_NOT_SANDBOXED will disable an important security layer that sandboxes loaders. It is only intended for testing and development purposes.
This mode selects `bwrap` outside of Flatpaks and usually
`flatpak-spawn` inside of Flatpaks. The sandbox is disabled
automatically inside of Flatpak development environments.
Inside of Flatpaks, `flatpak-spawn` is used to create the sandbox. This
mechanism starts an installed Flatpak with the same app id. For
development, Flatpak are usually not installed and the sandbox can
therefore not be used. If the sandbox has been started via
`flatpak-builder --run` (i.e. without installed Flatpak) and the app id
ends with `Devel`, the sandbox is disabled.
bwrap
flatpak-spawn
Disable sandbox. Unsafe, only use for testing and development.
Error quark for [error@GlyLoaderError]
The error domain
Whether a memory format has an alpha channel
Returns `TRUE` if the memory format has an alpha channel
Whether a memory format has an alpha channel and the color values are
premultiplied with the alpha value
Returns `TRUE` if color channels are premultiplied