mirror of
https://github.com/swaywm/swaybg
synced 2024-09-28 03:20:26 +02:00
Correct for image orientation when loading image
JPEG and other image formats may include an EXIF orientation tag which indicates in what orientation (rotation and mirroring) the image should be displayed. libgdk-pixbuf does not correct for this when loading an image, but provides a function to apply the transform after the fact, which this commit uses.
This commit is contained in:
parent
87ca82d887
commit
b4fda8146c
1 changed files with 5 additions and 1 deletions
|
@ -31,8 +31,12 @@ cairo_surface_t *load_background_image(const char *path) {
|
|||
err->message);
|
||||
return NULL;
|
||||
}
|
||||
image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf);
|
||||
// Correct for embedded image orientation; typical images are not
|
||||
// rotated and will be handled efficiently
|
||||
GdkPixbuf *oriented = gdk_pixbuf_apply_embedded_orientation(pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
image = gdk_cairo_image_surface_create_from_pixbuf(oriented);
|
||||
g_object_unref(oriented);
|
||||
#else
|
||||
image = cairo_image_surface_create_from_png(path);
|
||||
#endif // HAVE_GDK_PIXBUF
|
||||
|
|
Loading…
Reference in a new issue