Extract ICC profiles from gdk-pixbuf
This commit is contained in:
parent
f151fcb72b
commit
a5f64b1a65
16
fastiv-io.c
16
fastiv-io.c
@ -983,6 +983,8 @@ open_xcursor(const gchar *data, gsize len, GError **error)
|
||||
static cairo_surface_t *
|
||||
open_gdkpixbuf(const gchar *data, gsize len, GError **error)
|
||||
{
|
||||
// gdk-pixbuf controls the playback itself, there is no reliable method of
|
||||
// extracting individual frames (due to loops).
|
||||
GInputStream *is = g_memory_input_stream_new_from_data(data, len, NULL);
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_stream(is, NULL, error);
|
||||
g_object_unref(is);
|
||||
@ -991,6 +993,20 @@ open_gdkpixbuf(const gchar *data, gsize len, GError **error)
|
||||
|
||||
cairo_surface_t *surface =
|
||||
gdk_cairo_surface_create_from_pixbuf(pixbuf, 1, NULL);
|
||||
|
||||
// TODO(p): Also pass the pre-decoded Exif "orientation" option,
|
||||
// which is an ASCII digit from 1 to 8.
|
||||
const char *icc_profile = gdk_pixbuf_get_option(pixbuf, "icc-profile");
|
||||
if (icc_profile) {
|
||||
gsize out_len = 0;
|
||||
guchar *raw = g_base64_decode(icc_profile, &out_len);
|
||||
if (raw) {
|
||||
cairo_surface_set_user_data(surface, &fastiv_io_key_icc,
|
||||
g_bytes_new_take(raw, out_len),
|
||||
(cairo_destroy_func_t) g_bytes_unref);
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref(pixbuf);
|
||||
return surface;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ extern cairo_user_data_key_t fastiv_io_key_icc;
|
||||
extern cairo_user_data_key_t fastiv_io_key_frame_next;
|
||||
/// Frame duration in milliseconds as an intptr_t.
|
||||
extern cairo_user_data_key_t fastiv_io_key_frame_duration;
|
||||
/// How many times to repeat the animation, or zero for +inf, as an uintptr_t.
|
||||
/// How many times to repeat the animation, or zero for +inf, as a uintptr_t.
|
||||
extern cairo_user_data_key_t fastiv_io_key_loops;
|
||||
|
||||
cairo_surface_t *fastiv_io_open(const gchar *path, GError **error);
|
||||
|
Loading…
Reference in New Issue
Block a user