Mercurial > geeqie
diff src/pixbuf_util.c @ 839:14520c3a91f8
rotate thumbnails by exif
author | nadvornik |
---|---|
date | Sun, 15 Jun 2008 21:52:15 +0000 |
parents | fbebf5cf4a55 |
children | f40509d56fe3 |
line wrap: on
line diff
--- a/src/pixbuf_util.c Sun Jun 15 20:09:15 2008 +0000 +++ b/src/pixbuf_util.c Sun Jun 15 21:52:15 2008 +0000 @@ -13,6 +13,7 @@ #include "main.h" #include "pixbuf_util.h" +#include "exif.h" #include "icons/icons_inline.h" @@ -382,6 +383,53 @@ return dest; } +GdkPixbuf* pixbuf_apply_orientation(GdkPixbuf *pixbuf, gint orientation) +{ + GdkPixbuf *dest; + GdkPixbuf *tmp = NULL; + + switch (orientation) + { + case EXIF_ORIENTATION_TOP_LEFT: + dest = gdk_pixbuf_copy(pixbuf); + break; + case EXIF_ORIENTATION_TOP_RIGHT: + /* mirrored */ + dest = pixbuf_copy_mirror(pixbuf, TRUE, FALSE); + break; + case EXIF_ORIENTATION_BOTTOM_RIGHT: + /* upside down */ + dest = pixbuf_copy_mirror(pixbuf, TRUE, TRUE); + break; + case EXIF_ORIENTATION_BOTTOM_LEFT: + /* flipped */ + dest = pixbuf_copy_mirror(pixbuf, FALSE, TRUE); + break; + case EXIF_ORIENTATION_LEFT_TOP: + tmp = pixbuf_copy_mirror(pixbuf, FALSE, TRUE); + dest = pixbuf_copy_rotate_90(tmp, FALSE); + break; + case EXIF_ORIENTATION_RIGHT_TOP: + /* rotated -90 (270) */ + dest = pixbuf_copy_rotate_90(pixbuf, FALSE); + break; + case EXIF_ORIENTATION_RIGHT_BOTTOM: + tmp = pixbuf_copy_mirror(pixbuf, FALSE, TRUE); + dest = pixbuf_copy_rotate_90(tmp, TRUE); + break; + case EXIF_ORIENTATION_LEFT_BOTTOM: + /* rotated 90 */ + dest = pixbuf_copy_rotate_90(pixbuf, TRUE); + break; + default: + dest = gdk_pixbuf_copy(pixbuf); + break; + } + if (tmp) gdk_pixbuf_unref(tmp); + return dest; + +} + /* *-----------------------------------------------------------------------------